Update NetAnalyzers version (#54511)
authorStephen Toub <stoub@microsoft.com>
Wed, 23 Jun 2021 06:34:38 +0000 (02:34 -0400)
committerGitHub <noreply@github.com>
Wed, 23 Jun 2021 06:34:38 +0000 (08:34 +0200)
* Update NetAnalyzers version

* Add NetAnalyzers to dependency flow

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
eng/CodeAnalysis.ruleset
eng/Version.Details.xml
eng/Versions.props
src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs
src/libraries/Microsoft.Win32.Registry/src/Microsoft/Win32/RegistryKey.cs
src/libraries/System.Configuration.ConfigurationManager/src/System.Configuration.ConfigurationManager.csproj
src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj
src/libraries/System.Diagnostics.PerformanceCounter/src/System.Diagnostics.PerformanceCounter.csproj
src/libraries/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.UnixOrBrowser.cs
src/libraries/System.Speech/src/System.Speech.csproj
src/tasks/AndroidAppBuilder/ApkBuilder.cs

index 4631414..8faa50e 100644 (file)
     <Rule Id="CA1844" Action="Warning" />       <!-- Provide memory-based overrides of async methods when subclassing 'Stream' -->
     <Rule Id="CA1845" Action="Warning" />       <!-- Use span-based 'string.Concat' -->
     <Rule Id="CA1846" Action="Warning" />       <!-- Prefer 'AsSpan' over 'Substring' -->
+    <Rule Id="CA1847" Action="Warning" />       <!-- Use char literal for a single character lookup -->
     <Rule Id="CA2000" Action="None" />          <!-- Dispose objects before losing scope -->
     <Rule Id="CA2002" Action="None" />          <!-- Do not lock on objects with weak identity -->
     <Rule Id="CA2007" Action="Warning" />       <!-- Consider calling ConfigureAwait on the awaited task -->
index 99fb28c..5c1f457 100644 (file)
       <Uri>https://github.com/dotnet/runtime-assets</Uri>
       <Sha>8d7b898b96cbdb868cac343e938173105287ed9e</Sha>
     </Dependency>
+    <Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0-rc1.21320.2">
+      <Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
+      <Sha>fcddb771f42866f9521f23f093b1f30e129018bb</Sha>
+    </Dependency>
   </ToolsetDependencies>
 </Dependencies>
index b62b9b4..2295b6e 100644 (file)
     <MicrosoftCodeAnalysisVersion>3.8.0</MicrosoftCodeAnalysisVersion>
   </PropertyGroup>
   <PropertyGroup>
-    <MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-preview6.21281.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
+    <!-- Code analysis dependencies -->
     <MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.10.0-2.final</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
     <MicrosoftCodeAnalysisCSharpVersion>3.10.0-2.final</MicrosoftCodeAnalysisCSharpVersion>
+    <MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-rc1.21320.2</MicrosoftCodeAnalysisNetAnalyzersVersion>
     <!-- Arcade dependencies -->
     <MicrosoftDotNetApiCompatVersion>6.0.0-beta.21311.3</MicrosoftDotNetApiCompatVersion>
     <MicrosoftDotNetBuildTasksFeedVersion>6.0.0-beta.21311.3</MicrosoftDotNetBuildTasksFeedVersion>
index fda8cc8..80a0921 100644 (file)
@@ -406,8 +406,7 @@ namespace System.Data.Common
                 bool compValue = s_connectionStringValidValueRegex.IsMatch(keyvalue);
                 Debug.Assert((-1 == keyvalue.IndexOf('\u0000')) == compValue, "IsValueValid mismatch with regex");
 #endif
-                // string.Contains(char) is .NetCore2.1+ specific
-                return (-1 == keyvalue.IndexOf('\u0000'));
+                return (-1 == keyvalue.IndexOf('\u0000')); // string.Contains(char) is .NetCore2.1+ specific
             }
             return true;
         }
index 54054d8..ea5a833 100644 (file)
@@ -628,8 +628,7 @@ namespace Microsoft.Win32
         {
             Debug.Assert(name != null, "[FixupName]name!=null");
 
-            // string.Contains(char) is .NetCore2.1+ specific
-            if (name.IndexOf('\\') == -1)
+            if (!name.Contains('\\'))
             {
                 return name;
             }
index 104386d..209d36e 100644 (file)
@@ -3,6 +3,7 @@
     <TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461</TargetFrameworks>
     <!-- opt-out of trimming until it works https://github.com/dotnet/runtime/issues/49062 -->
     <SetIsTrimmable>false</SetIsTrimmable>
+    <NoWarn>$(NoWarn);CA1847</NoWarn>
   </PropertyGroup>
   <!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
   <PropertyGroup>
index 14a4d33..a093eb3 100644 (file)
@@ -2,7 +2,7 @@
   <PropertyGroup>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);netcoreapp3.1-windows;netcoreapp3.1;netstandard2.0;net461</TargetFrameworks>
-    <NoWarn>$(NoWarn);CA1838</NoWarn>
+    <NoWarn>$(NoWarn);CA1838;CA1847</NoWarn>
   </PropertyGroup>
   <!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
   <PropertyGroup>
index f66b352..600f6fc 100644 (file)
@@ -2,6 +2,7 @@
   <PropertyGroup>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);netcoreapp3.1-windows;netcoreapp3.1;netstandard2.0;net461</TargetFrameworks>
+    <NoWarn>$(NoWarn);CA1847</NoWarn>
   </PropertyGroup>
   <!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
   <PropertyGroup>
index 5189298..b39b223 100644 (file)
@@ -24,7 +24,7 @@ namespace System.IO
 
         private static string NormalizeDriveName(string driveName)
         {
-            if (driveName.Contains("\0")) // string.Contains(char) is .NetCore2.1+ specific
+            if (driveName.Contains('\0'))
             {
                 throw new ArgumentException(SR.Format(SR.Arg_InvalidDriveChars, driveName), nameof(driveName));
             }
index a38b451..8493864 100644 (file)
@@ -4,7 +4,7 @@
     <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);netcoreapp3.1-windows;netcoreapp3.1;netstandard2.0</TargetFrameworks>
     <!-- CS0649: uninitialized interop type fields -->
     <!-- SA1129: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3277 -->
-    <NoWarn>$(NoWarn);CS0649;SA1129</NoWarn>
+    <NoWarn>$(NoWarn);CS0649;SA1129;CA1847</NoWarn>
     <SetIsTrimmable>false</SetIsTrimmable>
   </PropertyGroup>
   <PropertyGroup>
index 346f854..b979ba3 100644 (file)
@@ -495,7 +495,7 @@ public class ApkBuilder
     {
         string? buildTools = Directory.GetDirectories(Path.Combine(androidSdkDir, "build-tools"))
             .Select(Path.GetFileName)
-            .Where(file => !file!.Contains("-"))
+            .Where(file => !file!.Contains('-'))
             .Select(file => { Version.TryParse(Path.GetFileName(file), out Version? version); return version; })
             .OrderByDescending(v => v)
             .FirstOrDefault()?.ToString();