diff --git a/Directory.Build.props b/Directory.Build.props index 520eb0976..ce53be91e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -102,11 +102,14 @@ - - + + + + $(userprofile)\.nuget\packages\msbuildtasks\1.5.0.235\tools\ + - + diff --git a/Greenshot/Greenshot.csproj b/Greenshot/Greenshot.csproj index 9419fb179..630501ce8 100644 --- a/Greenshot/Greenshot.csproj +++ b/Greenshot/Greenshot.csproj @@ -46,6 +46,13 @@ Always + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/Greenshot/Helpers/MailHelper.cs b/Greenshot/Helpers/MailHelper.cs index d3daaf446..a78799eae 100644 --- a/Greenshot/Helpers/MailHelper.cs +++ b/Greenshot/Helpers/MailHelper.cs @@ -174,7 +174,7 @@ namespace Greenshot.Helpers { /// public void ShowDialog() { // Create the mail message in an STA thread - var thread = new Thread(_ShowMail) + var thread = new Thread(ShowMail) { IsBackground = true, Name = "Create MAPI mail" @@ -202,7 +202,7 @@ namespace Greenshot.Helpers { /// /// Sends the mail message. /// - private void _ShowMail() { + private void ShowMail() { var message = new MapiHelperInterop.MapiMessage(); using var interopRecipients = Recipients.GetInteropRepresentation(); @@ -215,7 +215,7 @@ namespace Greenshot.Helpers { // Check if we need to add attachments if (Files.Count > 0) { // Add attachments - message.Files = _AllocAttachments(out message.FileCount); + message.Files = AllocAttachments(out message.FileCount); } // Signal the creating thread (make the remaining code async) @@ -227,7 +227,7 @@ namespace Greenshot.Helpers { if (Files.Count > 0) { // Deallocate the files - _DeallocFiles(message); + DeallocFiles(message); } MAPI_CODES errorCode = (MAPI_CODES)Enum.ToObject(typeof(MAPI_CODES), error); @@ -245,14 +245,14 @@ namespace Greenshot.Helpers { return; } Recipients = new RecipientCollection(); - _ShowMail(); + ShowMail(); } /// /// Deallocates the files in a message. /// /// The message to deallocate the files from. - private void _DeallocFiles(MapiHelperInterop.MapiMessage message) { + private void DeallocFiles(MapiHelperInterop.MapiMessage message) { if (message.Files != IntPtr.Zero) { Type fileDescType = typeof(MapiFileDescriptor); int fsize = Marshal.SizeOf(fileDescType); @@ -274,7 +274,7 @@ namespace Greenshot.Helpers { /// /// /// - private IntPtr _AllocAttachments(out int fileCount) { + private IntPtr AllocAttachments(out int fileCount) { fileCount = 0; if (Files == null) { return IntPtr.Zero; diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj index 2c4e72fe6..d37465111 100644 --- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj +++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj @@ -12,7 +12,7 @@ - - + + \ No newline at end of file diff --git a/GreenshotPlugin/Core/EmailConfigHelper.cs b/GreenshotPlugin/Core/EmailConfigHelper.cs index bbd816e96..354f02c33 100644 --- a/GreenshotPlugin/Core/EmailConfigHelper.cs +++ b/GreenshotPlugin/Core/EmailConfigHelper.cs @@ -20,6 +20,7 @@ */ using System.IO; +using Microsoft.Win32; namespace GreenshotPlugin.Core { /// @@ -27,16 +28,16 @@ namespace GreenshotPlugin.Core { /// public static class EmailConfigHelper { - public static string GetMapiClient() => RegistryHelper.ReadLocalMachineSoftwareKey(@"Clients\Mail"); + public static string GetMapiClient() => Registry.LocalMachine.ReadKey64Or32(@"Clients\Mail"); public static bool HasMapi() { - var value = RegistryHelper.ReadLocalMachineSoftwareKey(@"Microsoft\Windows Messaging Subsystem", "MAPI", "0"); + var value = Registry.LocalMachine.ReadKey64Or32(@"Microsoft\Windows Messaging Subsystem", "MAPI", "0"); return "1".Equals(value); } - public static string GetOutlookExePath() => RegistryHelper.ReadLocalMachineSoftwareKey(@"Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE"); + public static string GetOutlookExePath() => Registry.LocalMachine.ReadKey64Or32(@"Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE"); /// /// Check if Outlook is installed diff --git a/GreenshotPlugin/Core/RegistryHelper.cs b/GreenshotPlugin/Core/RegistryKeyExtensions.cs similarity index 82% rename from GreenshotPlugin/Core/RegistryHelper.cs rename to GreenshotPlugin/Core/RegistryKeyExtensions.cs index e5f068ab4..73fd66a47 100644 --- a/GreenshotPlugin/Core/RegistryHelper.cs +++ b/GreenshotPlugin/Core/RegistryKeyExtensions.cs @@ -27,22 +27,23 @@ namespace GreenshotPlugin.Core /// /// A helper class for accessing the registry /// - public static class RegistryHelper + public static class RegistryKeyExtensions { /// /// Retrieve a registry value /// + /// RegistryKey like Registry.LocalMachine /// string with the name of the key /// string with the name of the value below the key, null will retrieve the default /// string with the default value to return /// string with the value - public static string ReadLocalMachineSoftwareKey(string keyName, string value = null, string defaultValue = null) + public static string ReadKey64Or32(this RegistryKey registryKey, string keyName, string value = null, string defaultValue = null) { string result = null; value ??= string.Empty; if (Environment.Is64BitOperatingSystem) { - using var key = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\{keyName}", false); + using var key = registryKey.OpenSubKey($@"SOFTWARE\{keyName}", false); if (key != null) { @@ -52,7 +53,7 @@ namespace GreenshotPlugin.Core if (string.IsNullOrEmpty(result)) { - using var key = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\wow6432node\{keyName}", false); + using var key = registryKey.OpenSubKey($@"SOFTWARE\wow6432node\{keyName}", false); if (key != null) { diff --git a/GreenshotPlugin/GreenshotPlugin.csproj b/GreenshotPlugin/GreenshotPlugin.csproj index 3caa4a7c4..29371bcfd 100644 --- a/GreenshotPlugin/GreenshotPlugin.csproj +++ b/GreenshotPlugin/GreenshotPlugin.csproj @@ -13,9 +13,9 @@ - + - +