Browse Source

Fix warnings and diagnostics

Ian Griffiths 6 months ago
parent
commit
0c0261b35e

+ 8 - 0
Rx.NET/Test/Gauntlet/.editorconfig

@@ -10,3 +10,11 @@ dotnet_diagnostic.IDE0063.severity = silent
 dotnet_diagnostic.IDE0028.severity = none
 dotnet_diagnostic.IDE0305.severity = none
 dotnet_diagnostic.IDE0306.severity = none
+
+# While removing var in the main Rx.NET codebase would be a) not the highest priority
+# use of time and b) unpopular, I have to live with that horror, but since RxGauntlet is
+# a self-contained project that was written without var from the start, there's no
+# sense wasting time making it conform to the time-and-energy-consuming var-everywhere
+# conventions of the rest of the project
+csharp_style_var_elsewhere = false
+csharp_style_var_for_built_in_types = false

+ 7 - 7
Rx.NET/Test/Gauntlet/RxGauntlet.Common/Build/ModifiedProjectClone.cs

@@ -4,14 +4,14 @@ namespace RxGauntlet.Build;
 
 public sealed class ModifiedProjectClone : IDisposable
 {
-    private readonly string copyPath;
+    private readonly string _copyPath;
 
     private ModifiedProjectClone(string copyPath)
     {
-        this.copyPath = copyPath;
+        _copyPath = copyPath;
     }
 
-    public string ClonedProjectFolderPath => copyPath;
+    public string ClonedProjectFolderPath => _copyPath;
 
     public static ModifiedProjectClone Create(
         string sourceProjectFolder,
@@ -43,7 +43,7 @@ public sealed class ModifiedProjectClone : IDisposable
                         break;
 
                     case ".csproj":
-                        ProjectFileRewriter projectFileRewriter = ProjectFileRewriter.CreateForCsProj(file);
+                        var projectFileRewriter = ProjectFileRewriter.CreateForCsProj(file);
                         modifyProjectFile(projectFileRewriter);
                         projectFileRewriter.WriteModified(destinationPath);
                         break;
@@ -94,9 +94,9 @@ public sealed class ModifiedProjectClone : IDisposable
 
     public void Dispose()
     {
-        if (Directory.Exists(copyPath))
+        if (Directory.Exists(_copyPath))
         {
-            Directory.Delete(copyPath, true);
+            Directory.Delete(_copyPath, true);
         }
     }
 
@@ -127,7 +127,7 @@ public sealed class ModifiedProjectClone : IDisposable
             // Comment this out to see the output in the console window
             //CreateNoWindow = true,
             Arguments = args,
-            WorkingDirectory = copyPath,
+            WorkingDirectory = _copyPath,
         };
 
         using var process = new Process { StartInfo = startInfo };

+ 11 - 11
Rx.NET/Test/Gauntlet/RxGauntlet.Common/Build/ProjectFileRewriter.cs

@@ -6,16 +6,16 @@ namespace RxGauntlet.Build;
 
 public class ProjectFileRewriter
 {
-    private readonly XmlDocument document = new();
+    private readonly XmlDocument _document = new();
 
     private ProjectFileRewriter(string template)
     {
-        document.Load(template);
+        _document.Load(template);
     }
 
     public void SetTargetFramework(string targetFrameworkMoniker)
     {
-        XmlNode targetFrameworkNode = document.GetRequiredNode("/Project/PropertyGroup/TargetFramework");
+        XmlNode targetFrameworkNode = _document.GetRequiredNode("/Project/PropertyGroup/TargetFramework");
         targetFrameworkNode.InnerText = targetFrameworkMoniker;
     }
 
@@ -31,13 +31,13 @@ public class ProjectFileRewriter
 
     public void ReplaceProperty(string propertyName, string newValue)
     {
-        XmlNode propertyNode = document.GetRequiredNode($"/Project/PropertyGroup/{propertyName}");
+        XmlNode propertyNode = _document.GetRequiredNode($"/Project/PropertyGroup/{propertyName}");
         propertyNode.InnerText = newValue;
     }
 
     public void ReplacePackageReference(string packageId, PackageIdAndVersion[] replacementPackages)
     {
-        XmlNode packageRefNode = document.GetRequiredNode($"/Project/ItemGroup/PackageReference[@Include='{packageId}']");
+        XmlNode packageRefNode = _document.GetRequiredNode($"/Project/ItemGroup/PackageReference[@Include='{packageId}']");
 
         if (replacementPackages is [PackageIdAndVersion singleReplacement])
         {
@@ -56,21 +56,21 @@ public class ProjectFileRewriter
         string targetCsProjNameWithoutDirectory,
         PackageIdAndVersion[] replacementPackages)
     {
-        XmlNode projectRefNode = document.GetRequiredNode($"/Project/ItemGroup/ProjectReference[contains(@Include, '{targetCsProjNameWithoutDirectory}')]");
+        XmlNode projectRefNode = _document.GetRequiredNode($"/Project/ItemGroup/ProjectReference[contains(@Include, '{targetCsProjNameWithoutDirectory}')]");
         ReplaceNodeWithPackageReferences(projectRefNode, replacementPackages);
     }
 
     public void AddPropertyGroup(IEnumerable<KeyValuePair<string, string>> properties)
     {
-        XmlNode propertyGroupNode = document.CreateElement("PropertyGroup");
+        XmlNode propertyGroupNode = _document.CreateElement("PropertyGroup");
         foreach ((string name, string value) in properties)
         {
-            XmlNode propertyNode = document.CreateElement(name);
+            XmlNode propertyNode = _document.CreateElement(name);
             propertyNode.InnerText = value;
             propertyGroupNode.AppendChild(propertyNode);
         }
 
-        document.SelectSingleNode("/Project")!.AppendChild(propertyGroupNode);
+        _document.SelectSingleNode("/Project")!.AppendChild(propertyGroupNode);
     }
 
     public void AddUseUiFrameworksIfRequired(bool? useWpf, bool? useWindowsForms)
@@ -95,7 +95,7 @@ public class ProjectFileRewriter
 
     internal void WriteModified(string destinationPath)
     {
-        document.Save(destinationPath);
+        _document.Save(destinationPath);
     }
 
     private static void ReplaceNodeWithPackageReferences(
@@ -121,7 +121,7 @@ public class ProjectFileRewriter
 
     public void FixUpProjectReferences(string templateProjectFolder)
     {
-        if (document.SelectNodes("/Project/ItemGroup/ProjectReference") is XmlNodeList projectReferences)
+        if (_document.SelectNodes("/Project/ItemGroup/ProjectReference") is XmlNodeList projectReferences)
         {
             foreach (XmlElement projectReference in projectReferences.OfType<XmlElement>())
             {