Browse Source

Fixed warnings in UpdateInstaller and UpdateModule

ArtemK123 4 years ago
parent
commit
2cf721db58

+ 1 - 0
Custom.ruleset

@@ -3,5 +3,6 @@
     <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
     <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
         <Rule Id="SA1101" Action="None" />
         <Rule Id="SA1101" Action="None" />
         <Rule Id="SA1633" Action="None" />
         <Rule Id="SA1633" Action="None" />
+        <Rule Id="SA0001" Action="None" />
     </Rules>
     </Rules>
 </RuleSet>
 </RuleSet>

+ 9 - 5
PixiEditor.UpdateInstaller/AssemblyInfo.cs

@@ -1,10 +1,14 @@
 using System.Windows;
 using System.Windows;
 
 
 [assembly: ThemeInfo(
 [assembly: ThemeInfo(
-    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
-    //(used if a resource is not found in the page,
+    ResourceDictionaryLocation.None,
+    ResourceDictionaryLocation.SourceAssembly)
+
+    // ResourceDictionaryLocation.None - where theme specific resource dictionaries are located
+    // (used if a resource is not found in the page,
     // or application resource dictionaries)
     // or application resource dictionaries)
-    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
-    //(used if a resource is not found in the page,
+
+    // ResourceDictionaryLocation.SourceAssembly - where the generic resource dictionary is located
+    // (used if a resource is not found in the page,
     // app, or any theme specific resource dictionaries)
     // app, or any theme specific resource dictionaries)
-)]
+]

+ 5 - 5
PixiEditor.UpdateInstaller/Extensions.cs

@@ -7,10 +7,7 @@ namespace PixiEditor.UpdateInstaller
 {
 {
     public static class Extensions
     public static class Extensions
     {
     {
-        private static readonly int MaxPath = 255;
-
-        [DllImport("kernel32.dll")]
-        private static extern uint GetModuleFileName(IntPtr hModule, StringBuilder lpFilename, int nSize);
+        private const int MaxPath = 255;
 
 
         public static string GetExecutablePath()
         public static string GetExecutablePath()
         {
         {
@@ -21,7 +18,10 @@ namespace PixiEditor.UpdateInstaller
                 return sb.ToString();
                 return sb.ToString();
             }
             }
 
 
-            return Process.GetCurrentProcess().MainModule.FileName;
+            return Process.GetCurrentProcess().MainModule?.FileName;
         }
         }
+
+        [DllImport("kernel32.dll")]
+        private static extern uint GetModuleFileName(IntPtr hModule, StringBuilder lpFilename, int nSize);
     }
     }
 }
 }

+ 3 - 3
PixiEditor.UpdateInstaller/MainWindow.xaml.cs

@@ -7,9 +7,9 @@ using System.Windows;
 namespace PixiEditor.UpdateInstaller
 namespace PixiEditor.UpdateInstaller
 {
 {
     /// <summary>
     /// <summary>
-    ///     Interaction logic for MainWindow.xaml
+    ///     Interaction logic for MainWindow.xaml.
     /// </summary>
     /// </summary>
-    public partial class MainWindow : Window
+    public partial class MainWindow
     {
     {
         public MainWindow()
         public MainWindow()
         {
         {
@@ -19,7 +19,7 @@ namespace PixiEditor.UpdateInstaller
 
 
         private async void Window_Loaded(object sender, RoutedEventArgs e)
         private async void Window_Loaded(object sender, RoutedEventArgs e)
         {
         {
-            var vmm = (ViewModelMain) DataContext;
+            var vmm = (ViewModelMain)DataContext;
             await Task.Run(() =>
             await Task.Run(() =>
             {
             {
                 try
                 try

+ 5 - 2
PixiEditor.UpdateInstaller/ViewModelBase.cs

@@ -4,11 +4,14 @@ namespace PixiEditor.UpdateInstaller
 {
 {
     public class ViewModelBase : INotifyPropertyChanged
     public class ViewModelBase : INotifyPropertyChanged
     {
     {
-        public event PropertyChangedEventHandler PropertyChanged = delegate { };
+        public event PropertyChangedEventHandler PropertyChanged = (sender, e) => { };
 
 
         protected void RaisePropertyChanged(string property)
         protected void RaisePropertyChanged(string property)
         {
         {
-            if (property != null) PropertyChanged(this, new PropertyChangedEventArgs(property));
+            if (property != null)
+            {
+                PropertyChanged(this, new PropertyChangedEventArgs(property));
+            }
         }
         }
     }
     }
 }
 }

+ 1 - 0
PixiEditor.UpdateInstaller/ViewModelMain.cs

@@ -21,6 +21,7 @@ namespace PixiEditor.UpdateInstaller
         }
         }
 
 
         public ViewModelMain Current { get; }
         public ViewModelMain Current { get; }
+
         public UpdateModule.UpdateInstaller Installer { get; set; }
         public UpdateModule.UpdateInstaller Installer { get; set; }
 
 
         public string UpdateDirectory { get; }
         public string UpdateDirectory { get; }