PowerToys/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/ApplicationActivationHelper.cs

49 lines
2.3 KiB
C#
Raw Normal View History

// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
Enable Static Analysis on programs plugin (#5847) * Removing unused ProgramSettings constructor paramaters. * Fix for: Severity Code Description Project File Line Suppression State Error CA1829 Use the "Count" property instead of Enumerable.Count(). Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 182 Active Severity Code Description Project File Line Suppression State Error CA1827 Count() is used where Any() could be used instead to improve performance. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 287 Active * Fixes for CA1031: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * More fixes(Suppression) for CA1031 (Catching base exception) https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * Fix for nested types being externally visible. CA1034 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Fix for CA1028 If possible, make the underlying type of Hresult System.Int32 instead of uint. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Programs\UWP.cs 236 Active * Fix for CA2227 Collection properties should be readonly. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019 Fix rror CA2211 Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * CA2208: Instantiate argument exceptions correctly https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2208?view=vs-2019 * Win32.cs Static analysis fixes: CA2200: Rethrow to preserve stack details https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200?view=vs-2019 CA1825: Avoid zero-length array allocations https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1825?view=vs-2019 CA2211: Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * More Win32.cs static analysis fixes: CA1307: Specify StringComparison https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1307?view=vs-2019 Verifying query is not null before using it. CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 * UWPApplication. CA2007: Do not directly await a Task https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019 * Error CA2010 Consume the hresult returned by method 'Microsoft.Plugin.Program.Programs.AppxPackageHelper.IAppxManifestApplication.GetStringValue(string, out string)' and call Marshal.ThrowExceptionForHR. Note: CA2010 has been removed from future FXCop versions as it can provide incorrect advice for methods that don't return hresult (possibly when [PreserveSig] has been incorrectly labeled.) I've verified the methods in question do still return hresults. * More fixes for Error CA2010 Consume the hresult returned by method and call Marshal.ThrowExceptionForHR. * Fixes for: Error CA2000 Call System.IDisposable.Dispose on object created before all references to it are out of scope. * Suppress CA1031:Do not catch general exception types * Fixes for Error CA1034 Do not nest type ... * Fixing Unit tests that were broken as per a previous fix. * Fix for: CA1034: Nested types should not be visible: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Suppressing CA1707 for native/com types. CA1707:Identifiers should not contain underscores * Fix for Error CA1307 The behavior of 'string.Replace(string, string?)' could vary based on the current user's locale settings. * Fixes for Error CA1825 Avoid unnecessary zero-length array allocations. Use Array.Empty<string>() instead. * Fix for: Error CA1823 Unused field 'IndexLock'. * Fixes for CA1822: Mark members as static: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1822?view=vs-2019 * Fix for Error CA1819 Properties should not return arrays * Fix for Error CA1806 ContextMenus calls Trim but does not use the new string instance that the method returns. Pass the instance as an argument to another method, assign the instance to a variable, or remove the call if it is unnecessary. * Fix for Error CA1801 Parameter settings of method UpdateSettings is never used. Remove the parameter or use it in the method body. * Fix for Error CA1724 The type name Settings conflicts in whole or in part with the namespace name 'Microsoft.PowerToys.Settings'. * Includes FxCop for static analysis * Fix for Error CA1717 Only FlagsAttribute enums should have plural names * Suppress Stgm flags: Error CA1714 Flags enums should have plural names Microsoft.Plugin.Program * Rename Win32 to Win32Program Fix for: Error CA1724 The type name Win32 conflicts in whole or in part with the namespace name 'Microsoft.Win32' defined in the .NET Framework. Rename the type to eliminate the conflict. * Fixes for Error CA1507 Use nameof in place of string literal * Using ordinal instead of invariant culture when not symbolic comparison * CA1308: Normalize strings to uppercase https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1308?view=vs-2019 * CA1304: Specify CultureInfo CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304?view=vs-2019 * CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 * CA1056: URI properties should not be strings https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1056?view=vs-2019 Fix: Making LogoURi private, as it is only used internally and operated on as a string * Warning CA1052 Type 'AppxPackageHelper' is a static holder type but is neither static nor NotInheritable * CA1060: Move P/Invokes to NativeMethods class https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1060?view=vs-2019 * Programs Plugin - Treat warnings as errors true * CA1031:Do not catch general exception types Missed release only compile issue. Making debug and release behave the same. * Renaming 'Create' to 'CreateWin32Program' based on PR feedback.
2020-08-12 00:08:44 +08:00
namespace Microsoft.Plugin.Program.Programs.ApplicationActivationHelper
{
// Reference : https://github.com/MicrosoftEdge/edge-launcher/blob/108e63df0b4cb5cd9d5e45aa7a264690851ec51d/MIcrosoftEdgeLauncherCsharp/Program.cs
2020-08-14 06:31:14 +08:00
[Flags]
Enable Static Analysis on programs plugin (#5847) * Removing unused ProgramSettings constructor paramaters. * Fix for: Severity Code Description Project File Line Suppression State Error CA1829 Use the "Count" property instead of Enumerable.Count(). Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 182 Active Severity Code Description Project File Line Suppression State Error CA1827 Count() is used where Any() could be used instead to improve performance. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 287 Active * Fixes for CA1031: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * More fixes(Suppression) for CA1031 (Catching base exception) https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * Fix for nested types being externally visible. CA1034 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Fix for CA1028 If possible, make the underlying type of Hresult System.Int32 instead of uint. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Programs\UWP.cs 236 Active * Fix for CA2227 Collection properties should be readonly. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019 Fix rror CA2211 Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * CA2208: Instantiate argument exceptions correctly https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2208?view=vs-2019 * Win32.cs Static analysis fixes: CA2200: Rethrow to preserve stack details https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200?view=vs-2019 CA1825: Avoid zero-length array allocations https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1825?view=vs-2019 CA2211: Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * More Win32.cs static analysis fixes: CA1307: Specify StringComparison https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1307?view=vs-2019 Verifying query is not null before using it. CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 * UWPApplication. CA2007: Do not directly await a Task https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019 * Error CA2010 Consume the hresult returned by method 'Microsoft.Plugin.Program.Programs.AppxPackageHelper.IAppxManifestApplication.GetStringValue(string, out string)' and call Marshal.ThrowExceptionForHR. Note: CA2010 has been removed from future FXCop versions as it can provide incorrect advice for methods that don't return hresult (possibly when [PreserveSig] has been incorrectly labeled.) I've verified the methods in question do still return hresults. * More fixes for Error CA2010 Consume the hresult returned by method and call Marshal.ThrowExceptionForHR. * Fixes for: Error CA2000 Call System.IDisposable.Dispose on object created before all references to it are out of scope. * Suppress CA1031:Do not catch general exception types * Fixes for Error CA1034 Do not nest type ... * Fixing Unit tests that were broken as per a previous fix. * Fix for: CA1034: Nested types should not be visible: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Suppressing CA1707 for native/com types. CA1707:Identifiers should not contain underscores * Fix for Error CA1307 The behavior of 'string.Replace(string, string?)' could vary based on the current user's locale settings. * Fixes for Error CA1825 Avoid unnecessary zero-length array allocations. Use Array.Empty<string>() instead. * Fix for: Error CA1823 Unused field 'IndexLock'. * Fixes for CA1822: Mark members as static: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1822?view=vs-2019 * Fix for Error CA1819 Properties should not return arrays * Fix for Error CA1806 ContextMenus calls Trim but does not use the new string instance that the method returns. Pass the instance as an argument to another method, assign the instance to a variable, or remove the call if it is unnecessary. * Fix for Error CA1801 Parameter settings of method UpdateSettings is never used. Remove the parameter or use it in the method body. * Fix for Error CA1724 The type name Settings conflicts in whole or in part with the namespace name 'Microsoft.PowerToys.Settings'. * Includes FxCop for static analysis * Fix for Error CA1717 Only FlagsAttribute enums should have plural names * Suppress Stgm flags: Error CA1714 Flags enums should have plural names Microsoft.Plugin.Program * Rename Win32 to Win32Program Fix for: Error CA1724 The type name Win32 conflicts in whole or in part with the namespace name 'Microsoft.Win32' defined in the .NET Framework. Rename the type to eliminate the conflict. * Fixes for Error CA1507 Use nameof in place of string literal * Using ordinal instead of invariant culture when not symbolic comparison * CA1308: Normalize strings to uppercase https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1308?view=vs-2019 * CA1304: Specify CultureInfo CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304?view=vs-2019 * CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 * CA1056: URI properties should not be strings https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1056?view=vs-2019 Fix: Making LogoURi private, as it is only used internally and operated on as a string * Warning CA1052 Type 'AppxPackageHelper' is a static holder type but is neither static nor NotInheritable * CA1060: Move P/Invokes to NativeMethods class https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1060?view=vs-2019 * Programs Plugin - Treat warnings as errors true * CA1031:Do not catch general exception types Missed release only compile issue. Making debug and release behave the same. * Renaming 'Create' to 'CreateWin32Program' based on PR feedback.
2020-08-12 00:08:44 +08:00
public enum ActivateOptions
{
Enable Static Analysis on programs plugin (#5847) * Removing unused ProgramSettings constructor paramaters. * Fix for: Severity Code Description Project File Line Suppression State Error CA1829 Use the "Count" property instead of Enumerable.Count(). Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 182 Active Severity Code Description Project File Line Suppression State Error CA1827 Count() is used where Any() could be used instead to improve performance. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 287 Active * Fixes for CA1031: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * More fixes(Suppression) for CA1031 (Catching base exception) https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * Fix for nested types being externally visible. CA1034 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Fix for CA1028 If possible, make the underlying type of Hresult System.Int32 instead of uint. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Programs\UWP.cs 236 Active * Fix for CA2227 Collection properties should be readonly. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019 Fix rror CA2211 Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * CA2208: Instantiate argument exceptions correctly https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2208?view=vs-2019 * Win32.cs Static analysis fixes: CA2200: Rethrow to preserve stack details https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200?view=vs-2019 CA1825: Avoid zero-length array allocations https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1825?view=vs-2019 CA2211: Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * More Win32.cs static analysis fixes: CA1307: Specify StringComparison https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1307?view=vs-2019 Verifying query is not null before using it. CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 * UWPApplication. CA2007: Do not directly await a Task https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019 * Error CA2010 Consume the hresult returned by method 'Microsoft.Plugin.Program.Programs.AppxPackageHelper.IAppxManifestApplication.GetStringValue(string, out string)' and call Marshal.ThrowExceptionForHR. Note: CA2010 has been removed from future FXCop versions as it can provide incorrect advice for methods that don't return hresult (possibly when [PreserveSig] has been incorrectly labeled.) I've verified the methods in question do still return hresults. * More fixes for Error CA2010 Consume the hresult returned by method and call Marshal.ThrowExceptionForHR. * Fixes for: Error CA2000 Call System.IDisposable.Dispose on object created before all references to it are out of scope. * Suppress CA1031:Do not catch general exception types * Fixes for Error CA1034 Do not nest type ... * Fixing Unit tests that were broken as per a previous fix. * Fix for: CA1034: Nested types should not be visible: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Suppressing CA1707 for native/com types. CA1707:Identifiers should not contain underscores * Fix for Error CA1307 The behavior of 'string.Replace(string, string?)' could vary based on the current user's locale settings. * Fixes for Error CA1825 Avoid unnecessary zero-length array allocations. Use Array.Empty<string>() instead. * Fix for: Error CA1823 Unused field 'IndexLock'. * Fixes for CA1822: Mark members as static: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1822?view=vs-2019 * Fix for Error CA1819 Properties should not return arrays * Fix for Error CA1806 ContextMenus calls Trim but does not use the new string instance that the method returns. Pass the instance as an argument to another method, assign the instance to a variable, or remove the call if it is unnecessary. * Fix for Error CA1801 Parameter settings of method UpdateSettings is never used. Remove the parameter or use it in the method body. * Fix for Error CA1724 The type name Settings conflicts in whole or in part with the namespace name 'Microsoft.PowerToys.Settings'. * Includes FxCop for static analysis * Fix for Error CA1717 Only FlagsAttribute enums should have plural names * Suppress Stgm flags: Error CA1714 Flags enums should have plural names Microsoft.Plugin.Program * Rename Win32 to Win32Program Fix for: Error CA1724 The type name Win32 conflicts in whole or in part with the namespace name 'Microsoft.Win32' defined in the .NET Framework. Rename the type to eliminate the conflict. * Fixes for Error CA1507 Use nameof in place of string literal * Using ordinal instead of invariant culture when not symbolic comparison * CA1308: Normalize strings to uppercase https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1308?view=vs-2019 * CA1304: Specify CultureInfo CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304?view=vs-2019 * CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 * CA1056: URI properties should not be strings https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1056?view=vs-2019 Fix: Making LogoURi private, as it is only used internally and operated on as a string * Warning CA1052 Type 'AppxPackageHelper' is a static holder type but is neither static nor NotInheritable * CA1060: Move P/Invokes to NativeMethods class https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1060?view=vs-2019 * Programs Plugin - Treat warnings as errors true * CA1031:Do not catch general exception types Missed release only compile issue. Making debug and release behave the same. * Renaming 'Create' to 'CreateWin32Program' based on PR feedback.
2020-08-12 00:08:44 +08:00
None = 0x00000000,
DesignMode = 0x00000001,
NoErrorUI = 0x00000002,
NoSplashScreen = 0x00000004,
}
2020-08-14 06:31:14 +08:00
// ApplicationActivationManager
[ComImport]
[Guid("2e941141-7f97-4756-ba1d-9decde894a3d")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
Enable Static Analysis on programs plugin (#5847) * Removing unused ProgramSettings constructor paramaters. * Fix for: Severity Code Description Project File Line Suppression State Error CA1829 Use the "Count" property instead of Enumerable.Count(). Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 182 Active Severity Code Description Project File Line Suppression State Error CA1827 Count() is used where Any() could be used instead to improve performance. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 287 Active * Fixes for CA1031: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * More fixes(Suppression) for CA1031 (Catching base exception) https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * Fix for nested types being externally visible. CA1034 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Fix for CA1028 If possible, make the underlying type of Hresult System.Int32 instead of uint. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Programs\UWP.cs 236 Active * Fix for CA2227 Collection properties should be readonly. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019 Fix rror CA2211 Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * CA2208: Instantiate argument exceptions correctly https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2208?view=vs-2019 * Win32.cs Static analysis fixes: CA2200: Rethrow to preserve stack details https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200?view=vs-2019 CA1825: Avoid zero-length array allocations https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1825?view=vs-2019 CA2211: Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * More Win32.cs static analysis fixes: CA1307: Specify StringComparison https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1307?view=vs-2019 Verifying query is not null before using it. CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 * UWPApplication. CA2007: Do not directly await a Task https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019 * Error CA2010 Consume the hresult returned by method 'Microsoft.Plugin.Program.Programs.AppxPackageHelper.IAppxManifestApplication.GetStringValue(string, out string)' and call Marshal.ThrowExceptionForHR. Note: CA2010 has been removed from future FXCop versions as it can provide incorrect advice for methods that don't return hresult (possibly when [PreserveSig] has been incorrectly labeled.) I've verified the methods in question do still return hresults. * More fixes for Error CA2010 Consume the hresult returned by method and call Marshal.ThrowExceptionForHR. * Fixes for: Error CA2000 Call System.IDisposable.Dispose on object created before all references to it are out of scope. * Suppress CA1031:Do not catch general exception types * Fixes for Error CA1034 Do not nest type ... * Fixing Unit tests that were broken as per a previous fix. * Fix for: CA1034: Nested types should not be visible: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Suppressing CA1707 for native/com types. CA1707:Identifiers should not contain underscores * Fix for Error CA1307 The behavior of 'string.Replace(string, string?)' could vary based on the current user's locale settings. * Fixes for Error CA1825 Avoid unnecessary zero-length array allocations. Use Array.Empty<string>() instead. * Fix for: Error CA1823 Unused field 'IndexLock'. * Fixes for CA1822: Mark members as static: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1822?view=vs-2019 * Fix for Error CA1819 Properties should not return arrays * Fix for Error CA1806 ContextMenus calls Trim but does not use the new string instance that the method returns. Pass the instance as an argument to another method, assign the instance to a variable, or remove the call if it is unnecessary. * Fix for Error CA1801 Parameter settings of method UpdateSettings is never used. Remove the parameter or use it in the method body. * Fix for Error CA1724 The type name Settings conflicts in whole or in part with the namespace name 'Microsoft.PowerToys.Settings'. * Includes FxCop for static analysis * Fix for Error CA1717 Only FlagsAttribute enums should have plural names * Suppress Stgm flags: Error CA1714 Flags enums should have plural names Microsoft.Plugin.Program * Rename Win32 to Win32Program Fix for: Error CA1724 The type name Win32 conflicts in whole or in part with the namespace name 'Microsoft.Win32' defined in the .NET Framework. Rename the type to eliminate the conflict. * Fixes for Error CA1507 Use nameof in place of string literal * Using ordinal instead of invariant culture when not symbolic comparison * CA1308: Normalize strings to uppercase https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1308?view=vs-2019 * CA1304: Specify CultureInfo CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304?view=vs-2019 * CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 * CA1056: URI properties should not be strings https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1056?view=vs-2019 Fix: Making LogoURi private, as it is only used internally and operated on as a string * Warning CA1052 Type 'AppxPackageHelper' is a static holder type but is neither static nor NotInheritable * CA1060: Move P/Invokes to NativeMethods class https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1060?view=vs-2019 * Programs Plugin - Treat warnings as errors true * CA1031:Do not catch general exception types Missed release only compile issue. Making debug and release behave the same. * Renaming 'Create' to 'CreateWin32Program' based on PR feedback.
2020-08-12 00:08:44 +08:00
public interface IApplicationActivationManager
{
2020-08-14 06:31:14 +08:00
IntPtr ActivateApplication([In] string appUserModelId, [In] string arguments, [In] ActivateOptions options, [Out] out uint processId);
2020-08-14 06:31:14 +08:00
IntPtr ActivateForFile([In] string appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] string verb, [Out] out uint processId);
2020-08-14 06:31:14 +08:00
IntPtr ActivateForProtocol([In] string appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out uint processId);
Enable Static Analysis on programs plugin (#5847) * Removing unused ProgramSettings constructor paramaters. * Fix for: Severity Code Description Project File Line Suppression State Error CA1829 Use the "Count" property instead of Enumerable.Count(). Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 182 Active Severity Code Description Project File Line Suppression State Error CA1827 Count() is used where Any() could be used instead to improve performance. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 287 Active * Fixes for CA1031: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * More fixes(Suppression) for CA1031 (Catching base exception) https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * Fix for nested types being externally visible. CA1034 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Fix for CA1028 If possible, make the underlying type of Hresult System.Int32 instead of uint. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Programs\UWP.cs 236 Active * Fix for CA2227 Collection properties should be readonly. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019 Fix rror CA2211 Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * CA2208: Instantiate argument exceptions correctly https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2208?view=vs-2019 * Win32.cs Static analysis fixes: CA2200: Rethrow to preserve stack details https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200?view=vs-2019 CA1825: Avoid zero-length array allocations https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1825?view=vs-2019 CA2211: Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * More Win32.cs static analysis fixes: CA1307: Specify StringComparison https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1307?view=vs-2019 Verifying query is not null before using it. CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 * UWPApplication. CA2007: Do not directly await a Task https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019 * Error CA2010 Consume the hresult returned by method 'Microsoft.Plugin.Program.Programs.AppxPackageHelper.IAppxManifestApplication.GetStringValue(string, out string)' and call Marshal.ThrowExceptionForHR. Note: CA2010 has been removed from future FXCop versions as it can provide incorrect advice for methods that don't return hresult (possibly when [PreserveSig] has been incorrectly labeled.) I've verified the methods in question do still return hresults. * More fixes for Error CA2010 Consume the hresult returned by method and call Marshal.ThrowExceptionForHR. * Fixes for: Error CA2000 Call System.IDisposable.Dispose on object created before all references to it are out of scope. * Suppress CA1031:Do not catch general exception types * Fixes for Error CA1034 Do not nest type ... * Fixing Unit tests that were broken as per a previous fix. * Fix for: CA1034: Nested types should not be visible: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Suppressing CA1707 for native/com types. CA1707:Identifiers should not contain underscores * Fix for Error CA1307 The behavior of 'string.Replace(string, string?)' could vary based on the current user's locale settings. * Fixes for Error CA1825 Avoid unnecessary zero-length array allocations. Use Array.Empty<string>() instead. * Fix for: Error CA1823 Unused field 'IndexLock'. * Fixes for CA1822: Mark members as static: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1822?view=vs-2019 * Fix for Error CA1819 Properties should not return arrays * Fix for Error CA1806 ContextMenus calls Trim but does not use the new string instance that the method returns. Pass the instance as an argument to another method, assign the instance to a variable, or remove the call if it is unnecessary. * Fix for Error CA1801 Parameter settings of method UpdateSettings is never used. Remove the parameter or use it in the method body. * Fix for Error CA1724 The type name Settings conflicts in whole or in part with the namespace name 'Microsoft.PowerToys.Settings'. * Includes FxCop for static analysis * Fix for Error CA1717 Only FlagsAttribute enums should have plural names * Suppress Stgm flags: Error CA1714 Flags enums should have plural names Microsoft.Plugin.Program * Rename Win32 to Win32Program Fix for: Error CA1724 The type name Win32 conflicts in whole or in part with the namespace name 'Microsoft.Win32' defined in the .NET Framework. Rename the type to eliminate the conflict. * Fixes for Error CA1507 Use nameof in place of string literal * Using ordinal instead of invariant culture when not symbolic comparison * CA1308: Normalize strings to uppercase https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1308?view=vs-2019 * CA1304: Specify CultureInfo CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304?view=vs-2019 * CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 * CA1056: URI properties should not be strings https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1056?view=vs-2019 Fix: Making LogoURi private, as it is only used internally and operated on as a string * Warning CA1052 Type 'AppxPackageHelper' is a static holder type but is neither static nor NotInheritable * CA1060: Move P/Invokes to NativeMethods class https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1060?view=vs-2019 * Programs Plugin - Treat warnings as errors true * CA1031:Do not catch general exception types Missed release only compile issue. Making debug and release behave the same. * Renaming 'Create' to 'CreateWin32Program' based on PR feedback.
2020-08-12 00:08:44 +08:00
}
Enable Static Analysis on programs plugin (#5847) * Removing unused ProgramSettings constructor paramaters. * Fix for: Severity Code Description Project File Line Suppression State Error CA1829 Use the "Count" property instead of Enumerable.Count(). Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 182 Active Severity Code Description Project File Line Suppression State Error CA1827 Count() is used where Any() could be used instead to improve performance. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 287 Active * Fixes for CA1031: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * More fixes(Suppression) for CA1031 (Catching base exception) https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * Fix for nested types being externally visible. CA1034 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Fix for CA1028 If possible, make the underlying type of Hresult System.Int32 instead of uint. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Programs\UWP.cs 236 Active * Fix for CA2227 Collection properties should be readonly. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019 Fix rror CA2211 Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * CA2208: Instantiate argument exceptions correctly https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2208?view=vs-2019 * Win32.cs Static analysis fixes: CA2200: Rethrow to preserve stack details https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200?view=vs-2019 CA1825: Avoid zero-length array allocations https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1825?view=vs-2019 CA2211: Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * More Win32.cs static analysis fixes: CA1307: Specify StringComparison https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1307?view=vs-2019 Verifying query is not null before using it. CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 * UWPApplication. CA2007: Do not directly await a Task https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019 * Error CA2010 Consume the hresult returned by method 'Microsoft.Plugin.Program.Programs.AppxPackageHelper.IAppxManifestApplication.GetStringValue(string, out string)' and call Marshal.ThrowExceptionForHR. Note: CA2010 has been removed from future FXCop versions as it can provide incorrect advice for methods that don't return hresult (possibly when [PreserveSig] has been incorrectly labeled.) I've verified the methods in question do still return hresults. * More fixes for Error CA2010 Consume the hresult returned by method and call Marshal.ThrowExceptionForHR. * Fixes for: Error CA2000 Call System.IDisposable.Dispose on object created before all references to it are out of scope. * Suppress CA1031:Do not catch general exception types * Fixes for Error CA1034 Do not nest type ... * Fixing Unit tests that were broken as per a previous fix. * Fix for: CA1034: Nested types should not be visible: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Suppressing CA1707 for native/com types. CA1707:Identifiers should not contain underscores * Fix for Error CA1307 The behavior of 'string.Replace(string, string?)' could vary based on the current user's locale settings. * Fixes for Error CA1825 Avoid unnecessary zero-length array allocations. Use Array.Empty<string>() instead. * Fix for: Error CA1823 Unused field 'IndexLock'. * Fixes for CA1822: Mark members as static: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1822?view=vs-2019 * Fix for Error CA1819 Properties should not return arrays * Fix for Error CA1806 ContextMenus calls Trim but does not use the new string instance that the method returns. Pass the instance as an argument to another method, assign the instance to a variable, or remove the call if it is unnecessary. * Fix for Error CA1801 Parameter settings of method UpdateSettings is never used. Remove the parameter or use it in the method body. * Fix for Error CA1724 The type name Settings conflicts in whole or in part with the namespace name 'Microsoft.PowerToys.Settings'. * Includes FxCop for static analysis * Fix for Error CA1717 Only FlagsAttribute enums should have plural names * Suppress Stgm flags: Error CA1714 Flags enums should have plural names Microsoft.Plugin.Program * Rename Win32 to Win32Program Fix for: Error CA1724 The type name Win32 conflicts in whole or in part with the namespace name 'Microsoft.Win32' defined in the .NET Framework. Rename the type to eliminate the conflict. * Fixes for Error CA1507 Use nameof in place of string literal * Using ordinal instead of invariant culture when not symbolic comparison * CA1308: Normalize strings to uppercase https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1308?view=vs-2019 * CA1304: Specify CultureInfo CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304?view=vs-2019 * CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 * CA1056: URI properties should not be strings https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1056?view=vs-2019 Fix: Making LogoURi private, as it is only used internally and operated on as a string * Warning CA1052 Type 'AppxPackageHelper' is a static holder type but is neither static nor NotInheritable * CA1060: Move P/Invokes to NativeMethods class https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1060?view=vs-2019 * Programs Plugin - Treat warnings as errors true * CA1031:Do not catch general exception types Missed release only compile issue. Making debug and release behave the same. * Renaming 'Create' to 'CreateWin32Program' based on PR feedback.
2020-08-12 00:08:44 +08:00
// Application Activation Manager Class
2020-08-14 06:31:14 +08:00
[ComImport]
[Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
Enable Static Analysis on programs plugin (#5847) * Removing unused ProgramSettings constructor paramaters. * Fix for: Severity Code Description Project File Line Suppression State Error CA1829 Use the "Count" property instead of Enumerable.Count(). Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 182 Active Severity Code Description Project File Line Suppression State Error CA1827 Count() is used where Any() could be used instead to improve performance. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 287 Active * Fixes for CA1031: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * More fixes(Suppression) for CA1031 (Catching base exception) https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * Fix for nested types being externally visible. CA1034 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Fix for CA1028 If possible, make the underlying type of Hresult System.Int32 instead of uint. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Programs\UWP.cs 236 Active * Fix for CA2227 Collection properties should be readonly. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019 Fix rror CA2211 Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * CA2208: Instantiate argument exceptions correctly https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2208?view=vs-2019 * Win32.cs Static analysis fixes: CA2200: Rethrow to preserve stack details https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200?view=vs-2019 CA1825: Avoid zero-length array allocations https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1825?view=vs-2019 CA2211: Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * More Win32.cs static analysis fixes: CA1307: Specify StringComparison https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1307?view=vs-2019 Verifying query is not null before using it. CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 * UWPApplication. CA2007: Do not directly await a Task https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019 * Error CA2010 Consume the hresult returned by method 'Microsoft.Plugin.Program.Programs.AppxPackageHelper.IAppxManifestApplication.GetStringValue(string, out string)' and call Marshal.ThrowExceptionForHR. Note: CA2010 has been removed from future FXCop versions as it can provide incorrect advice for methods that don't return hresult (possibly when [PreserveSig] has been incorrectly labeled.) I've verified the methods in question do still return hresults. * More fixes for Error CA2010 Consume the hresult returned by method and call Marshal.ThrowExceptionForHR. * Fixes for: Error CA2000 Call System.IDisposable.Dispose on object created before all references to it are out of scope. * Suppress CA1031:Do not catch general exception types * Fixes for Error CA1034 Do not nest type ... * Fixing Unit tests that were broken as per a previous fix. * Fix for: CA1034: Nested types should not be visible: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Suppressing CA1707 for native/com types. CA1707:Identifiers should not contain underscores * Fix for Error CA1307 The behavior of 'string.Replace(string, string?)' could vary based on the current user's locale settings. * Fixes for Error CA1825 Avoid unnecessary zero-length array allocations. Use Array.Empty<string>() instead. * Fix for: Error CA1823 Unused field 'IndexLock'. * Fixes for CA1822: Mark members as static: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1822?view=vs-2019 * Fix for Error CA1819 Properties should not return arrays * Fix for Error CA1806 ContextMenus calls Trim but does not use the new string instance that the method returns. Pass the instance as an argument to another method, assign the instance to a variable, or remove the call if it is unnecessary. * Fix for Error CA1801 Parameter settings of method UpdateSettings is never used. Remove the parameter or use it in the method body. * Fix for Error CA1724 The type name Settings conflicts in whole or in part with the namespace name 'Microsoft.PowerToys.Settings'. * Includes FxCop for static analysis * Fix for Error CA1717 Only FlagsAttribute enums should have plural names * Suppress Stgm flags: Error CA1714 Flags enums should have plural names Microsoft.Plugin.Program * Rename Win32 to Win32Program Fix for: Error CA1724 The type name Win32 conflicts in whole or in part with the namespace name 'Microsoft.Win32' defined in the .NET Framework. Rename the type to eliminate the conflict. * Fixes for Error CA1507 Use nameof in place of string literal * Using ordinal instead of invariant culture when not symbolic comparison * CA1308: Normalize strings to uppercase https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1308?view=vs-2019 * CA1304: Specify CultureInfo CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304?view=vs-2019 * CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 * CA1056: URI properties should not be strings https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1056?view=vs-2019 Fix: Making LogoURi private, as it is only used internally and operated on as a string * Warning CA1052 Type 'AppxPackageHelper' is a static holder type but is neither static nor NotInheritable * CA1060: Move P/Invokes to NativeMethods class https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1060?view=vs-2019 * Programs Plugin - Treat warnings as errors true * CA1031:Do not catch general exception types Missed release only compile issue. Making debug and release behave the same. * Renaming 'Create' to 'CreateWin32Program' based on PR feedback.
2020-08-12 00:08:44 +08:00
public class ApplicationActivationManager : IApplicationActivationManager
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)/*, PreserveSig*/]
2020-08-14 06:31:14 +08:00
public extern IntPtr ActivateApplication([In] string appUserModelId, [In] string arguments, [In] ActivateOptions options, [Out] out uint processId);
Enable Static Analysis on programs plugin (#5847) * Removing unused ProgramSettings constructor paramaters. * Fix for: Severity Code Description Project File Line Suppression State Error CA1829 Use the "Count" property instead of Enumerable.Count(). Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 182 Active Severity Code Description Project File Line Suppression State Error CA1827 Count() is used where Any() could be used instead to improve performance. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 287 Active * Fixes for CA1031: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * More fixes(Suppression) for CA1031 (Catching base exception) https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * Fix for nested types being externally visible. CA1034 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Fix for CA1028 If possible, make the underlying type of Hresult System.Int32 instead of uint. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Programs\UWP.cs 236 Active * Fix for CA2227 Collection properties should be readonly. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019 Fix rror CA2211 Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * CA2208: Instantiate argument exceptions correctly https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2208?view=vs-2019 * Win32.cs Static analysis fixes: CA2200: Rethrow to preserve stack details https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200?view=vs-2019 CA1825: Avoid zero-length array allocations https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1825?view=vs-2019 CA2211: Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * More Win32.cs static analysis fixes: CA1307: Specify StringComparison https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1307?view=vs-2019 Verifying query is not null before using it. CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 * UWPApplication. CA2007: Do not directly await a Task https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019 * Error CA2010 Consume the hresult returned by method 'Microsoft.Plugin.Program.Programs.AppxPackageHelper.IAppxManifestApplication.GetStringValue(string, out string)' and call Marshal.ThrowExceptionForHR. Note: CA2010 has been removed from future FXCop versions as it can provide incorrect advice for methods that don't return hresult (possibly when [PreserveSig] has been incorrectly labeled.) I've verified the methods in question do still return hresults. * More fixes for Error CA2010 Consume the hresult returned by method and call Marshal.ThrowExceptionForHR. * Fixes for: Error CA2000 Call System.IDisposable.Dispose on object created before all references to it are out of scope. * Suppress CA1031:Do not catch general exception types * Fixes for Error CA1034 Do not nest type ... * Fixing Unit tests that were broken as per a previous fix. * Fix for: CA1034: Nested types should not be visible: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Suppressing CA1707 for native/com types. CA1707:Identifiers should not contain underscores * Fix for Error CA1307 The behavior of 'string.Replace(string, string?)' could vary based on the current user's locale settings. * Fixes for Error CA1825 Avoid unnecessary zero-length array allocations. Use Array.Empty<string>() instead. * Fix for: Error CA1823 Unused field 'IndexLock'. * Fixes for CA1822: Mark members as static: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1822?view=vs-2019 * Fix for Error CA1819 Properties should not return arrays * Fix for Error CA1806 ContextMenus calls Trim but does not use the new string instance that the method returns. Pass the instance as an argument to another method, assign the instance to a variable, or remove the call if it is unnecessary. * Fix for Error CA1801 Parameter settings of method UpdateSettings is never used. Remove the parameter or use it in the method body. * Fix for Error CA1724 The type name Settings conflicts in whole or in part with the namespace name 'Microsoft.PowerToys.Settings'. * Includes FxCop for static analysis * Fix for Error CA1717 Only FlagsAttribute enums should have plural names * Suppress Stgm flags: Error CA1714 Flags enums should have plural names Microsoft.Plugin.Program * Rename Win32 to Win32Program Fix for: Error CA1724 The type name Win32 conflicts in whole or in part with the namespace name 'Microsoft.Win32' defined in the .NET Framework. Rename the type to eliminate the conflict. * Fixes for Error CA1507 Use nameof in place of string literal * Using ordinal instead of invariant culture when not symbolic comparison * CA1308: Normalize strings to uppercase https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1308?view=vs-2019 * CA1304: Specify CultureInfo CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304?view=vs-2019 * CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 * CA1056: URI properties should not be strings https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1056?view=vs-2019 Fix: Making LogoURi private, as it is only used internally and operated on as a string * Warning CA1052 Type 'AppxPackageHelper' is a static holder type but is neither static nor NotInheritable * CA1060: Move P/Invokes to NativeMethods class https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1060?view=vs-2019 * Programs Plugin - Treat warnings as errors true * CA1031:Do not catch general exception types Missed release only compile issue. Making debug and release behave the same. * Renaming 'Create' to 'CreateWin32Program' based on PR feedback.
2020-08-12 00:08:44 +08:00
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
2020-08-14 06:31:14 +08:00
public extern IntPtr ActivateForFile([In] string appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] string verb, [Out] out uint processId);
Enable Static Analysis on programs plugin (#5847) * Removing unused ProgramSettings constructor paramaters. * Fix for: Severity Code Description Project File Line Suppression State Error CA1829 Use the "Count" property instead of Enumerable.Count(). Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 182 Active Severity Code Description Project File Line Suppression State Error CA1827 Count() is used where Any() could be used instead to improve performance. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Views\ProgramSetting.xaml.cs 287 Active * Fixes for CA1031: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * More fixes(Suppression) for CA1031 (Catching base exception) https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1031?view=vs-2019 * Fix for nested types being externally visible. CA1034 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Fix for CA1028 If possible, make the underlying type of Hresult System.Int32 instead of uint. Microsoft.Plugin.Program C:\Repos\PowerToys\src\modules\launcher\Plugins\Microsoft.Plugin.Program\Programs\UWP.cs 236 Active * Fix for CA2227 Collection properties should be readonly. https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019 Fix rror CA2211 Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * CA2208: Instantiate argument exceptions correctly https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2208?view=vs-2019 * Win32.cs Static analysis fixes: CA2200: Rethrow to preserve stack details https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200?view=vs-2019 CA1825: Avoid zero-length array allocations https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1825?view=vs-2019 CA2211: Non-constant fields should not be visible https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2211?view=vs-2019 * More Win32.cs static analysis fixes: CA1307: Specify StringComparison https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1307?view=vs-2019 Verifying query is not null before using it. CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 * UWPApplication. CA2007: Do not directly await a Task https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2007?view=vs-2019 * Error CA2010 Consume the hresult returned by method 'Microsoft.Plugin.Program.Programs.AppxPackageHelper.IAppxManifestApplication.GetStringValue(string, out string)' and call Marshal.ThrowExceptionForHR. Note: CA2010 has been removed from future FXCop versions as it can provide incorrect advice for methods that don't return hresult (possibly when [PreserveSig] has been incorrectly labeled.) I've verified the methods in question do still return hresults. * More fixes for Error CA2010 Consume the hresult returned by method and call Marshal.ThrowExceptionForHR. * Fixes for: Error CA2000 Call System.IDisposable.Dispose on object created before all references to it are out of scope. * Suppress CA1031:Do not catch general exception types * Fixes for Error CA1034 Do not nest type ... * Fixing Unit tests that were broken as per a previous fix. * Fix for: CA1034: Nested types should not be visible: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1034?view=vs-2019 * Suppressing CA1707 for native/com types. CA1707:Identifiers should not contain underscores * Fix for Error CA1307 The behavior of 'string.Replace(string, string?)' could vary based on the current user's locale settings. * Fixes for Error CA1825 Avoid unnecessary zero-length array allocations. Use Array.Empty<string>() instead. * Fix for: Error CA1823 Unused field 'IndexLock'. * Fixes for CA1822: Mark members as static: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1822?view=vs-2019 * Fix for Error CA1819 Properties should not return arrays * Fix for Error CA1806 ContextMenus calls Trim but does not use the new string instance that the method returns. Pass the instance as an argument to another method, assign the instance to a variable, or remove the call if it is unnecessary. * Fix for Error CA1801 Parameter settings of method UpdateSettings is never used. Remove the parameter or use it in the method body. * Fix for Error CA1724 The type name Settings conflicts in whole or in part with the namespace name 'Microsoft.PowerToys.Settings'. * Includes FxCop for static analysis * Fix for Error CA1717 Only FlagsAttribute enums should have plural names * Suppress Stgm flags: Error CA1714 Flags enums should have plural names Microsoft.Plugin.Program * Rename Win32 to Win32Program Fix for: Error CA1724 The type name Win32 conflicts in whole or in part with the namespace name 'Microsoft.Win32' defined in the .NET Framework. Rename the type to eliminate the conflict. * Fixes for Error CA1507 Use nameof in place of string literal * Using ordinal instead of invariant culture when not symbolic comparison * CA1308: Normalize strings to uppercase https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1308?view=vs-2019 * CA1304: Specify CultureInfo CA1305: Specify IFormatProvider https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1305?view=vs-2019 https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1304?view=vs-2019 * CA1062: Validate arguments of public methods https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062?view=vs-2019 * CA1056: URI properties should not be strings https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1056?view=vs-2019 Fix: Making LogoURi private, as it is only used internally and operated on as a string * Warning CA1052 Type 'AppxPackageHelper' is a static holder type but is neither static nor NotInheritable * CA1060: Move P/Invokes to NativeMethods class https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1060?view=vs-2019 * Programs Plugin - Treat warnings as errors true * CA1031:Do not catch general exception types Missed release only compile issue. Making debug and release behave the same. * Renaming 'Create' to 'CreateWin32Program' based on PR feedback.
2020-08-12 00:08:44 +08:00
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
2020-08-14 06:31:14 +08:00
public extern IntPtr ActivateForProtocol([In] string appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out uint processId);
}
}