diff --git a/eng/analyzers/Library.globalconfig b/eng/analyzers/Library.globalconfig index 2a816df636d..c317983435c 100644 --- a/eng/analyzers/Library.globalconfig +++ b/eng/analyzers/Library.globalconfig @@ -941,6 +941,7 @@ dotnet_diagnostic.CA1851.severity = suggestion # Help Link: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1852 # Tags : Telemetry, EnabledRuleInAggressiveMode, CompilationEnd dotnet_diagnostic.CA1852.severity = warning +dotnet_code_quality.CA1852.ignore_internalsvisibleto = true # Title : Unnecessary call to 'Dictionary.ContainsKey(key)' # Category : Performance diff --git a/src/Snippets/Docs/Chaos.Behavior.cs b/src/Snippets/Docs/Chaos.Behavior.cs index bfedb1a4111..e0cc93c17cd 100644 --- a/src/Snippets/Docs/Chaos.Behavior.cs +++ b/src/Snippets/Docs/Chaos.Behavior.cs @@ -86,7 +86,7 @@ public static void Pattern_InjectDelay() } } -internal class RedisConnectionException : Exception +internal sealed class RedisConnectionException : Exception { public RedisConnectionException() { diff --git a/src/Snippets/Docs/Chaos.Index.cs b/src/Snippets/Docs/Chaos.Index.cs index 9a6fa9e0755..0d02db88fa3 100644 --- a/src/Snippets/Docs/Chaos.Index.cs +++ b/src/Snippets/Docs/Chaos.Index.cs @@ -174,7 +174,7 @@ public static void CentralPipelineIntegration(IServiceCollection services) #region chaos-extension // Options that represent the chaos pipeline - public class MyChaosOptions + public sealed class MyChaosOptions { public ChaosFaultStrategyOptions Fault { get; set; } = new() { diff --git a/src/Snippets/Docs/DependencyInjection.cs b/src/Snippets/Docs/DependencyInjection.cs index 5ae5f1c1d19..251e30aa265 100644 --- a/src/Snippets/Docs/DependencyInjection.cs +++ b/src/Snippets/Docs/DependencyInjection.cs @@ -108,7 +108,7 @@ public static async Task KeyedServicesDefine(IServiceCollection services) #region di-keyed-services-use - public class MyApi + public sealed class MyApi { private readonly ResiliencePipeline _pipeline; private readonly ResiliencePipeline _genericPipeline; diff --git a/src/Snippets/Docs/Fallback.cs b/src/Snippets/Docs/Fallback.cs index 2699a8da426..495f21f8c9a 100644 --- a/src/Snippets/Docs/Fallback.cs +++ b/src/Snippets/Docs/Fallback.cs @@ -57,14 +57,14 @@ public static void Usage() #endregion } - public class UserAvatar + public sealed class UserAvatar { public static readonly UserAvatar Blank = new(); public static UserAvatar GetRandomAvatar() => new(); } - private class CustomNetworkException : Exception + private sealed class CustomNetworkException : Exception { public CustomNetworkException() { diff --git a/src/Snippets/Docs/Hedging.cs b/src/Snippets/Docs/Hedging.cs index d41db196fab..b3c7a8a1528 100644 --- a/src/Snippets/Docs/Hedging.cs +++ b/src/Snippets/Docs/Hedging.cs @@ -132,7 +132,7 @@ internal static class ResilienceKeys #region hedging-handler - internal class HedgingHandler : DelegatingHandler + internal sealed class HedgingHandler : DelegatingHandler { private readonly ResiliencePipeline _pipeline; diff --git a/src/Snippets/Docs/Performance.cs b/src/Snippets/Docs/Performance.cs index 5b0f6227a19..fb4bfc8cb9b 100644 --- a/src/Snippets/Docs/Performance.cs +++ b/src/Snippets/Docs/Performance.cs @@ -120,13 +120,13 @@ static async (context, state) => private static ValueTask GetMemberAsync(string id, CancellationToken token) => default; - public class Member + public sealed class Member { } #region perf-reuse-pipelines - public class MyApi + public sealed class MyApi { private readonly ResiliencePipelineRegistry _registry; diff --git a/src/Snippets/Docs/Telemetry.cs b/src/Snippets/Docs/Telemetry.cs index 2989c0ba84f..2d94357b433 100644 --- a/src/Snippets/Docs/Telemetry.cs +++ b/src/Snippets/Docs/Telemetry.cs @@ -82,7 +82,7 @@ public static void AddResiliencePipelineWithTelemetry() #region telemetry-listeners - internal class MyTelemetryListener : TelemetryListener + internal sealed class MyTelemetryListener : TelemetryListener { public override void Write(in TelemetryEventArguments args) { @@ -90,7 +90,7 @@ public override void Write(in TelemetryEventArguments(in EnrichmentContext context) { diff --git a/src/Snippets/Docs/Utils/SomeExceptionType.cs b/src/Snippets/Docs/Utils/SomeExceptionType.cs index d3a57b7911e..f55a9bb8006 100644 --- a/src/Snippets/Docs/Utils/SomeExceptionType.cs +++ b/src/Snippets/Docs/Utils/SomeExceptionType.cs @@ -1,6 +1,6 @@ namespace Snippets.Docs.Utils; -internal class SomeExceptionType : Exception +internal sealed class SomeExceptionType : Exception { public SomeExceptionType(string message) : base(message)