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

698 lines
27 KiB
C#
Raw Normal View History

2020-08-18 01:00:56 +08:00
// 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;
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
using System.Collections.Generic;
using System.Diagnostics;
2020-08-18 01:00:56 +08:00
using System.Globalization;
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
using System.IO;
using System.Linq;
2020-08-18 01:00:56 +08:00
using System.Reflection;
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
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
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
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Plugin.Program.Logger;
2020-08-18 01:00:56 +08:00
using Microsoft.Plugin.Program.Win32;
using Wox.Infrastructure;
2020-08-18 01:00:56 +08:00
using Wox.Infrastructure.Image;
using Wox.Infrastructure.Logger;
using Wox.Plugin;
using Wox.Plugin.SharedCommands;
2020-08-18 01:00:56 +08:00
using static Microsoft.Plugin.Program.Programs.UWP;
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
2020-08-18 01:00:56 +08:00
{
[Serializable]
public class UWPApplication : IProgram
{
public string AppListEntry { get; set; }
public string UniqueIdentifier { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public string UserModelId { get; set; }
public string BackgroundColor { get; set; }
public string EntryPoint { get; set; }
public string Name => DisplayName;
public string Location => Package.Location;
public bool Enabled { get; set; }
public bool CanRunElevated { get; set; }
public string LogoPath { get; set; }
public LogoType LogoType { get; set; }
2020-08-18 01:00:56 +08:00
public UWP Package { get; set; }
private string logoUri;
private const string ContrastWhite = "contrast-white";
private const string ContrastBlack = "contrast-black";
2020-08-18 01:00:56 +08:00
// Function to calculate the score of a result
private int Score(string query)
{
var displayNameMatch = StringMatcher.FuzzySearch(query, DisplayName);
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
var score = new[] { displayNameMatch.Score, descriptionMatch.Score / 2 }.Max();
return score;
}
// Function to set the subtitle based on the Type of application
private static string SetSubtitle(IPublicAPI api)
{
return api.GetTranslation("powertoys_run_plugin_program_packaged_application");
}
public Result Result(string query, IPublicAPI api)
{
if (api == null)
{
throw new ArgumentNullException(nameof(api));
}
var score = Score(query);
if (score <= 0)
{ // no need to create result if score is 0
return null;
}
var result = new Result
{
SubTitle = SetSubtitle(api),
Icon = Logo,
Score = score,
ContextData = this,
Action = e =>
{
Launch(api);
return true;
},
};
// To set the title to always be the displayname of the packaged application
result.Title = DisplayName;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;
var toolTipTitle = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", api.GetTranslation("powertoys_run_plugin_program_file_name"), result.Title);
var toolTipText = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", api.GetTranslation("powertoys_run_plugin_program_file_path"), Package.Location);
result.ToolTipData = new ToolTipData(toolTipTitle, toolTipText);
return result;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentially keeping the process alive.")]
public List<ContextMenuResult> ContextMenus(IPublicAPI api)
{
if (api == null)
{
throw new ArgumentNullException(nameof(api));
}
var contextMenus = new List<ContextMenuResult>();
if (CanRunElevated)
{
contextMenus.Add(
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_run_as_administrator"),
Glyph = "\xE7EF",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.Enter,
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
Action = _ =>
{
string command = "shell:AppsFolder\\" + UniqueIdentifier;
command = Environment.ExpandEnvironmentVariables(command.Trim());
var info = ShellCommand.SetProcessStartInfo(command, verb: "runas");
info.UseShellExecute = true;
Process.Start(info);
return true;
},
});
}
contextMenus.Add(
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.E,
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
Action = _ =>
{
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location));
return true;
},
});
contextMenus.Add(new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_in_console"),
Glyph = "\xE756",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.C,
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
Action = (context) =>
{
try
{
Helper.OpenInConsole(Package.Location);
return true;
}
catch (Exception e)
{
Log.Exception($"|Microsoft.Plugin.Program.UWP.ContextMenu| Failed to open {Name} in console, {e.Message}", e);
return false;
}
},
});
return contextMenus;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Intentially keeping the process alive, and showing the user an error message")]
private async void Launch(IPublicAPI api)
{
var appManager = new ApplicationActivationHelper.ApplicationActivationManager();
const string noArgs = "";
const ApplicationActivationHelper.ActivateOptions noFlags = ApplicationActivationHelper.ActivateOptions.None;
await Task.Run(() =>
{
try
{
appManager.ActivateApplication(UserModelId, noArgs, noFlags, out uint unusedPid);
}
catch (Exception)
{
var name = "Plugin: Program";
var message = $"Can't start UWP: {DisplayName}";
api.ShowMsg(name, message, string.Empty);
}
}).ConfigureAwait(false);
}
public UWPApplication(IAppxManifestApplication manifestApp, UWP package)
{
if (manifestApp == null)
{
throw new ArgumentNullException(nameof(manifestApp));
}
var hr = manifestApp.GetAppUserModelId(out var tmpUserModelId);
UserModelId = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpUserModelId);
hr = manifestApp.GetAppUserModelId(out var tmpUniqueIdentifier);
UniqueIdentifier = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpUniqueIdentifier);
hr = manifestApp.GetStringValue("DisplayName", out var tmpDisplayName);
DisplayName = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpDisplayName);
hr = manifestApp.GetStringValue("Description", out var tmpDescription);
Description = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpDescription);
hr = manifestApp.GetStringValue("BackgroundColor", out var tmpBackgroundColor);
BackgroundColor = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpBackgroundColor);
hr = manifestApp.GetStringValue("EntryPoint", out var tmpEntryPoint);
EntryPoint = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpEntryPoint);
Package = package ?? throw new ArgumentNullException(nameof(package));
DisplayName = ResourceFromPri(package.FullName, DisplayName);
Description = ResourceFromPri(package.FullName, Description);
logoUri = LogoUriFromManifest(manifestApp);
Enabled = true;
CanRunElevated = IfApplicationcanRunElevated();
}
private bool IfApplicationcanRunElevated()
{
if (EntryPoint == "Windows.FullTrustApplication")
{
return true;
}
else
{
var manifest = Package.Location + "\\AppxManifest.xml";
if (File.Exists(manifest))
{
var file = File.ReadAllText(manifest);
if (file.Contains("TrustLevel=\"mediumIL\"", StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
}
return false;
}
internal string ResourceFromPri(string packageFullName, string resourceReference)
{
const string prefix = "ms-resource:";
if (!string.IsNullOrWhiteSpace(resourceReference) && resourceReference.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
{
// magic comes from @talynone
// https://github.com/talynone/Wox.Plugin.WindowsUniversalAppLauncher/blob/master/StoreAppLauncher/Helpers/NativeApiHelper.cs#L139-L153
string key = resourceReference.Substring(prefix.Length);
string parsed;
if (key.StartsWith("//", StringComparison.Ordinal))
{
parsed = prefix + key;
}
else if (key.StartsWith("/", StringComparison.Ordinal))
{
parsed = prefix + "//" + key;
}
else if (key.Contains("resources", StringComparison.OrdinalIgnoreCase))
{
parsed = prefix + key;
}
else
{
parsed = prefix + "///resources/" + key;
}
var outBuffer = new StringBuilder(128);
string source = $"@{{{packageFullName}? {parsed}}}";
var capacity = (uint)outBuffer.Capacity;
var hResult = NativeMethods.SHLoadIndirectString(source, outBuffer, capacity, IntPtr.Zero);
if (hResult == Hresult.Ok)
{
var loaded = outBuffer.ToString();
if (!string.IsNullOrEmpty(loaded))
{
return loaded;
}
else
{
ProgramLogger.LogException(
$"|UWP|ResourceFromPri|{Package.Location}|Can't load null or empty result "
+ $"pri {source} in uwp location {Package.Location}", new NullReferenceException());
return string.Empty;
}
}
else
{
// https://github.com/Wox-launcher/Wox/issues/964
// known hresult 2147942522:
// 'Microsoft Corporation' violates pattern constraint of '\bms-resource:.{1,256}'.
// for
// Microsoft.MicrosoftOfficeHub_17.7608.23501.0_x64__8wekyb3d8bbwe: ms-resource://Microsoft.MicrosoftOfficeHub/officehubintl/AppManifest_GetOffice_Description
// Microsoft.BingFoodAndDrink_3.0.4.336_x64__8wekyb3d8bbwe: ms-resource:AppDescription
var e = Marshal.GetExceptionForHR((int)hResult);
ProgramLogger.LogException($"|UWP|ResourceFromPri|{Package.Location}|Load pri failed {source} with HResult {hResult} and location {Package.Location}", e);
return string.Empty;
}
}
else
{
return resourceReference;
}
}
internal string LogoUriFromManifest(IAppxManifestApplication app)
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
{
var logoKeyFromVersion = new Dictionary<PackageVersion, string>
{
{ PackageVersion.Windows10, "Square44x44Logo" },
{ PackageVersion.Windows81, "Square30x30Logo" },
{ PackageVersion.Windows8, "SmallLogo" },
2020-08-18 01:00:56 +08:00
};
if (logoKeyFromVersion.ContainsKey(Package.Version))
{
var key = logoKeyFromVersion[Package.Version];
var hr = app.GetStringValue(key, out var logoUri);
_ = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, logoUri);
return logoUri;
}
else
{
return string.Empty;
}
}
public void UpdatePath(Theme theme)
{
LogoPathFromUri(this.logoUri, theme);
2020-08-18 01:00:56 +08:00
}
private bool SetScaleIcons(string path, string colorscheme, bool highContrast = false)
2020-08-18 01:00:56 +08:00
{
var extension = Path.GetExtension(path);
if (extension != null)
{
var end = path.Length - extension.Length;
var prefix = path.Substring(0, end);
var paths = new List<string> { };
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
var scaleFactors = new Dictionary<PackageVersion, List<int>>
{
// scale factors on win10: https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-app-assets#asset-size-tables,
{ PackageVersion.Windows10, new List<int> { 100, 125, 150, 200, 400 } },
{ PackageVersion.Windows81, new List<int> { 100, 120, 140, 160, 180 } },
{ PackageVersion.Windows8, new List<int> { 100 } },
2020-08-18 01:00:56 +08:00
};
if (!highContrast)
{
paths.Add(path);
}
2020-08-18 01:00:56 +08:00
if (scaleFactors.ContainsKey(Package.Version))
{
foreach (var factor in scaleFactors[Package.Version])
{
if (highContrast)
{
paths.Add($"{prefix}.scale-{factor}_{colorscheme}{extension}");
paths.Add($"{prefix}.{colorscheme}_scale-{factor}{extension}");
}
else
{
paths.Add($"{prefix}.scale-{factor}{extension}");
}
2020-08-18 01:00:56 +08:00
}
}
var selectedIconPath = paths.FirstOrDefault(File.Exists);
if (!string.IsNullOrEmpty(selectedIconPath))
2020-08-18 01:00:56 +08:00
{
LogoPath = selectedIconPath;
if (highContrast)
{
LogoType = LogoType.HighContrast;
}
else
{
LogoType = LogoType.Colored;
}
return true;
2020-08-18 01:00:56 +08:00
}
}
2020-08-18 01:00:56 +08:00
return false;
}
2020-08-18 01:00:56 +08:00
private bool SetTargetSizeIcon(string path, string colorscheme, bool highContrast = false)
{
var extension = Path.GetExtension(path);
if (extension != null)
{
var end = path.Length - extension.Length;
var prefix = path.Substring(0, end);
var paths = new List<string> { };
int appIconSize = 36;
var targetSizes = new List<int> { 16, 24, 30, 36, 44, 60, 72, 96, 128, 180, 256 }.AsParallel();
var pathFactorPairs = new Dictionary<string, int>();
foreach (var factor in targetSizes)
{
if (highContrast)
{
string suffixThemePath = $"{prefix}.targetsize-{factor}_{colorscheme}{extension}";
string prefixThemePath = $"{prefix}.{colorscheme}_targetsize-{factor}{extension}";
2020-08-18 01:00:56 +08:00
paths.Add(suffixThemePath);
paths.Add(prefixThemePath);
pathFactorPairs.Add(suffixThemePath, factor);
pathFactorPairs.Add(prefixThemePath, factor);
}
else
{
string simplePath = $"{prefix}.targetsize-{factor}{extension}";
string altformUnPlatedPath = $"{prefix}.targetsize-{factor}_altform-unplated{extension}";
paths.Add(simplePath);
paths.Add(altformUnPlatedPath);
pathFactorPairs.Add(simplePath, factor);
pathFactorPairs.Add(altformUnPlatedPath, factor);
}
}
2020-08-18 01:00:56 +08:00
var selectedIconPath = paths.OrderBy(x => Math.Abs(pathFactorPairs.GetValueOrDefault(x) - appIconSize)).FirstOrDefault(File.Exists);
if (!string.IsNullOrEmpty(selectedIconPath))
{
LogoPath = selectedIconPath;
if (highContrast)
2020-08-18 01:00:56 +08:00
{
LogoType = LogoType.HighContrast;
2020-08-18 01:00:56 +08:00
}
else
{
LogoType = LogoType.Colored;
2020-08-18 01:00:56 +08:00
}
return true;
2020-08-18 01:00:56 +08:00
}
}
return false;
}
private bool SetColoredIcon(string path, string colorscheme)
{
var isSetColoredScaleIcon = SetScaleIcons(path, colorscheme);
if (isSetColoredScaleIcon)
{
return true;
}
var isSetColoredTargetIcon = SetTargetSizeIcon(path, colorscheme);
if (isSetColoredTargetIcon)
{
return true;
}
var isSetHighContrastScaleIcon = SetScaleIcons(path, colorscheme, true);
if (isSetHighContrastScaleIcon)
{
return true;
}
var isSetHighContrastTargetIcon = SetTargetSizeIcon(path, colorscheme, true);
if (isSetHighContrastTargetIcon)
{
return true;
}
return false;
}
private bool SetHighContrastIcon(string path, string colorscheme)
{
var isSetHighContrastScaleIcon = SetScaleIcons(path, colorscheme, true);
if (isSetHighContrastScaleIcon)
{
return true;
}
var isSetHighContrastTargetIcon = SetTargetSizeIcon(path, colorscheme, true);
if (isSetHighContrastTargetIcon)
{
return true;
}
var isSetColoredScaleIcon = SetScaleIcons(path, colorscheme);
if (isSetColoredScaleIcon)
{
return true;
}
var isSetColoredTargetIcon = SetTargetSizeIcon(path, colorscheme);
if (isSetColoredTargetIcon)
{
return true;
}
return false;
}
internal void LogoPathFromUri(string uri, Theme theme)
{
// all https://msdn.microsoft.com/windows/uwp/controls-and-patterns/tiles-and-notifications-app-assets
// windows 10 https://msdn.microsoft.com/en-us/library/windows/apps/dn934817.aspx
// windows 8.1 https://msdn.microsoft.com/en-us/library/windows/apps/hh965372.aspx#target_size
// windows 8 https://msdn.microsoft.com/en-us/library/windows/apps/br211475.aspx
string path;
bool isLogoUriSet;
if (uri.Contains("\\", StringComparison.Ordinal))
{
path = Path.Combine(Package.Location, uri);
}
2020-08-18 01:00:56 +08:00
else
{
// for C:\Windows\MiracastView etc
path = Path.Combine(Package.Location, "Assets", uri);
}
if (theme == Theme.HighContrastBlack || theme == Theme.HighContrastOne || theme == Theme.HighContrastTwo)
{
isLogoUriSet = SetHighContrastIcon(path, ContrastBlack);
}
else if (theme == Theme.HighContrastWhite)
{
isLogoUriSet = SetHighContrastIcon(path, ContrastWhite);
}
else if (theme == Theme.Light)
{
isLogoUriSet = SetColoredIcon(path, ContrastWhite);
}
else
{
isLogoUriSet = SetColoredIcon(path, ContrastBlack);
}
if (!isLogoUriSet)
{
LogoPath = string.Empty;
LogoType = LogoType.Error;
2020-08-18 01:00:56 +08:00
ProgramLogger.LogException(
$"|UWP|LogoPathFromUri|{Package.Location}" +
$"|{UserModelId} can't find logo uri for {uri} in package location: {Package.Location}", new FileNotFoundException());
2020-08-18 01:00:56 +08:00
}
}
public ImageSource Logo()
{
if (LogoType == LogoType.Colored)
{
var logo = ImageFromPath(LogoPath);
var platedImage = PlatedImage(logo);
return platedImage;
}
else
{
return ImageFromPath(LogoPath);
}
}
private ImageSource PlatedImage(BitmapImage image)
{
if (!string.IsNullOrEmpty(BackgroundColor))
{
string currentBackgroundColor;
if (BackgroundColor == "transparent")
{
currentBackgroundColor = SystemParameters.WindowGlassBrush.ToString(CultureInfo.InvariantCulture);
}
else
{
currentBackgroundColor = BackgroundColor;
}
var padding = 8;
var width = image.Width + (2 * padding);
var height = image.Height + (2 * padding);
var x = 0;
var y = 0;
var group = new DrawingGroup();
var converted = ColorConverter.ConvertFromString(currentBackgroundColor);
if (converted != null)
{
var color = (Color)converted;
var brush = new SolidColorBrush(color);
var pen = new Pen(brush, 1);
var backgroundArea = new Rect(0, 0, width, height);
var rectangleGeometry = new RectangleGeometry(backgroundArea);
var rectDrawing = new GeometryDrawing(brush, pen, rectangleGeometry);
group.Children.Add(rectDrawing);
var imageArea = new Rect(x + padding, y + padding, image.Width, image.Height);
var imageDrawing = new ImageDrawing(image, imageArea);
group.Children.Add(imageDrawing);
// http://stackoverflow.com/questions/6676072/get-system-drawing-bitmap-of-a-wpf-area-using-visualbrush
var visual = new DrawingVisual();
var context = visual.RenderOpen();
context.DrawDrawing(group);
context.Close();
const int dpiScale100 = 96;
var bitmap = new RenderTargetBitmap(
Convert.ToInt32(width),
Convert.ToInt32(height),
dpiScale100,
dpiScale100,
PixelFormats.Pbgra32);
bitmap.Render(visual);
return bitmap;
}
else
{
ProgramLogger.LogException(
$"|UWP|PlatedImage|{Package.Location}|Unable to convert background string {BackgroundColor} " +
$"to color for {Package.Location}", new InvalidOperationException());
return new BitmapImage(new Uri(Constant.ErrorIcon));
}
}
else
{
// todo use windows theme as background
return image;
}
2020-08-18 01:00:56 +08:00
}
private BitmapImage ImageFromPath(string path)
{
if (File.Exists(path))
{
MemoryStream memoryStream = new MemoryStream();
byte[] fileBytes = File.ReadAllBytes(path);
memoryStream.Write(fileBytes, 0, fileBytes.Length);
memoryStream.Position = 0;
var image = new BitmapImage();
image.BeginInit();
image.StreamSource = memoryStream;
image.EndInit();
return image;
}
else
{
ProgramLogger.LogException(
$"|UWP|ImageFromPath|{path}|Unable to get logo for {UserModelId} from {path} and" +
2020-08-18 01:00:56 +08:00
$" located in {Package.Location}", new FileNotFoundException());
return new BitmapImage(new Uri(ImageLoader.ErrorIconPath));
}
}
public override string ToString()
{
return $"{DisplayName}: {Description}";
}
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 LogoType
{
Error,
Colored,
HighContrast,
}
2020-08-18 01:00:56 +08:00
}