Skip to content

Commit

Permalink
Rationalize analyzer warning numbers. (#4242)
Browse files Browse the repository at this point in the history
- Gets rid of many uses of R9 in the code base.

- Integrates latest analyzer warnings into the diag scheme.

Co-authored-by: Martin Taillefer <mataille@microsoft.com>
  • Loading branch information
geeknoid and Martin Taillefer authored Aug 7, 2023
1 parent a438cd8 commit 36412d0
Show file tree
Hide file tree
Showing 144 changed files with 4,729 additions and 4,840 deletions.
285 changes: 146 additions & 139 deletions bench/.editorconfig

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Microsoft.Gen.EnumStrings.Bench;

#pragma warning disable CA1822 // Mark members as static
#pragma warning disable R9A033 // Replace uses of 'Enum.GetName' and 'Enum.ToString' with the '[EnumStrings]' code generator for improved performance
#pragma warning disable EA0006 // Replace uses of 'Enum.GetName' and 'Enum.ToString' with the '[EnumStrings]' code generator for improved performance

[MemoryDiagnoser]
public class EnumStrings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public void GlobalSetup()
{
var serviceProvider = HttpClientFactory.InitializeServiceProvider(Type);
var factory = serviceProvider.GetRequiredService<IHttpClientFactory>();
#pragma warning disable R9A033 // Replace uses of 'Enum.GetName' and 'Enum.ToString' with the '[EnumStrings]' code generator for improved performance
#pragma warning disable EA0006 // Replace uses of 'Enum.GetName' and 'Enum.ToString' with the '[EnumStrings]' code generator for improved performance
_client = factory.CreateClient(Type.ToString());
#pragma warning restore R9A033 // Replace uses of 'Enum.GetName' and 'Enum.ToString' with the '[EnumStrings]' code generator for improved performance
#pragma warning restore EA0006 // Replace uses of 'Enum.GetName' and 'Enum.ToString' with the '[EnumStrings]' code generator for improved performance
}

[Params(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Telemetry.Metering;

#pragma warning disable R9A033 // Replace uses of 'Enum.GetName' and 'Enum.ToString' with the '[EnumStrings]' code generator for improved performance
#pragma warning disable EA0006 // Replace uses of 'Enum.GetName' and 'Enum.ToString' with the '[EnumStrings]' code generator for improved performance

namespace Microsoft.Extensions.Http.Resilience.Bench;

[Flags]
[SuppressMessage("Performance", "R9A031:Make types declared in an executable internal", Justification = "Needs to be public for BenchmarkDotNet consumption")]
[SuppressMessage("Performance", "EA0004:Make types declared in an executable internal", Justification = "Needs to be public for BenchmarkDotNet consumption")]
public enum HedgingClientType
{
Weighted = 1 << 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

namespace Microsoft.Extensions.Http.Resilience.Bench;

#pragma warning disable R9A044 // Assign array of literal values to a static field for improved performance

public class HttpResilienceBenchmark
{
private static readonly Uri _uri = new(HttpClientFactory.PrimaryEndpoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ private NoRemoteCallHandler(byte[] data)
_data = data;
}

[SuppressMessage("Performance", "R9A017:Switch to an asynchronous method for increased performance.",
Justification = "No async overload for `Directory.GetFiles`.")]
[SuppressMessage("Performance Analysis", "CPR120:File.ReadAllXXX should be replaced by using a StreamReader to avoid adding objects to the large object heap (LOH).",
Justification = "We can live with it here")]
public static NoRemoteCallHandler Create(string fileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ private NoRemoteCallNotSeekableHandler(byte[] data)
_data = data;
}

[SuppressMessage("Performance", "R9A017:Switch to an asynchronous method for increased performance.",
Justification = "No async overload for `Directory.GetFiles`.")]
[SuppressMessage("Performance Analysis", "CPR120:File.ReadAllXXX should be replaced by using a StreamReader to avoid adding objects to the large object heap (LOH).",
Justification = "We can live with it here")]
public static NoRemoteCallNotSeekableHandler Create(string fileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Diagnostics.CodeAnalysis;
using BenchmarkDotNet.Attributes;
using Microsoft.Extensions.Compliance.Redaction;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Telemetry.Enrichment;
using Microsoft.Extensions.Telemetry.Logging;

#pragma warning disable R9A000 // Switch to updated logging methods using the [LogMethod] attribute for additional performance.

namespace Microsoft.Extensions.Telemetry.Bench;

[MemoryDiagnoser]
Expand Down Expand Up @@ -80,6 +79,7 @@ private static ILogger GetLogger(LoggerFactoryVersions config)
}

[Benchmark]
[SuppressMessage("Performance", "EA0000:Use source generated logging methods for improved performance", Justification = "Benchmark")]
public void Classic_RefTypes()
{
var logger = _loggers[(int)Factory];
Expand All @@ -95,6 +95,7 @@ public void Classic_RefTypes()
}

[Benchmark]
[SuppressMessage("Performance", "EA0000:Use source generated logging methods for improved performance", Justification = "Benchmark")]
public void Classic_ValueTypes()
{
var logger = _loggers[(int)Factory];
Expand Down
4 changes: 2 additions & 2 deletions eng/Diags/ILLink.RoslynAnalyzer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Origin:
AssemblyName: ILLink.RoslynAnalyzer
Version: 8.0.8.26003
Version: 8.0.8.35901
Diagnostics:
IL2026:
Metadata:
Expand Down Expand Up @@ -545,7 +545,7 @@ Diagnostics:
IL2096:
Metadata:
Category: Trimming
Title: Call to 'Type.GetType' method can perform case insensitive lookup of the type, currently ILLink can not guarantee presence of all the matching types.
Title: Call to 'Type.GetType' method can perform case insensitive lookup of the type, currently trimming can not guarantee presence of all the matching types.
Description: ''
DefaultSeverity: Warning
Tier: 3
Expand Down
Loading

0 comments on commit 36412d0

Please sign in to comment.