Skip to content

Remove SonarAnalyzer.CSharp and disable CA1508 for build perf#7357

Draft
stephentoub wants to merge 1 commit intodotnet:mainfrom
stephentoub:buildperf
Draft

Remove SonarAnalyzer.CSharp and disable CA1508 for build perf#7357
stephentoub wants to merge 1 commit intodotnet:mainfrom
stephentoub:buildperf

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Mar 5, 2026

Address #7012 by removing the SonarAnalyzer.CSharp package (SymbolicExecutionRunner ~30s analyzer time) and disabling CA1508 (dead conditional code, ~5s, was only suggestion-level).

Cleanup: removed all in-source Sonar pragma suppressions (142 files), SuppressMessage attributes (44 files), Sonar rules from 6 .editorconfig files, S3236 NoWarn from Directory.Build.targets, and CA1508 pragmas from 2 test files.

Microsoft Reviewers: Open in CodeFlow

Address dotnet#7012 by removing the SonarAnalyzer.CSharp package
(SymbolicExecutionRunner ~30s analyzer time) and disabling CA1508 (dead
conditional code, ~5s, was only suggestion-level).

Cleanup: removed all in-source Sonar pragma suppressions (142 files),
SuppressMessage attributes (44 files), Sonar rules from 6 .editorconfig
files, S3236 NoWarn from Directory.Build.targets, and CA1508 pragmas
from 2 test files.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings March 5, 2026 04:31
@stephentoub stephentoub requested review from a team as code owners March 5, 2026 04:31
@stephentoub stephentoub requested review from ericstj and joperezr March 5, 2026 04:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the SonarAnalyzer.CSharp dependency and cleans up repository-wide in-source suppressions/overrides (pragmas, SuppressMessage attributes, and editorconfig rule entries) to improve build/analyzer performance.

Changes:

  • Remove SonarAnalyzer.CSharp from analyzer package references.
  • Delete Sonar-specific pragma / SuppressMessage suppressions across the codebase (and related NoWarn entries).
  • Remove remaining CA1508 in-source pragmas (rule handled via configuration instead of per-file suppression).

Reviewed changes

Copilot reviewed 190 out of 191 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/Shared/Throw/ThrowTest.cs Remove Sonar pragma suppression (S3236)
test/Shared/Throw/LongTests.cs Remove Sonar pragma suppression (S3236)
test/Shared/Throw/IntegerTests.cs Remove Sonar pragma suppression (S3236)
test/Shared/Throw/DoubleTests.cs Remove Sonar pragma suppression (S3236)
test/Shared/JsonSchemaExporter/TestTypes.cs Remove Sonar pragma suppressions (S2344/S3604/S1121)
test/Libraries/Microsoft.Extensions.Telemetry.Tests/Logging/JustInTimeRedactorTests.cs Remove Sonar pragma suppression (S103)
test/Libraries/Microsoft.Extensions.Telemetry.Tests/Logging/ExtendedLoggerFactoryTests.cs Remove Sonar pragma suppression (S3966)
test/Libraries/Microsoft.Extensions.Telemetry.Tests/Latency/Internal/LatencyContextTests.cs Remove Sonar pragma suppression (S3966)
test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Polly/HttpTimeoutStrategyOptionsTests.cs Remove Sonar pragma suppression (S2330)
test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Polly/HttpRetryStrategyOptionsTests.cs Remove Sonar pragma suppression (S2330)
test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Polly/HttpRateLimiterStrategyOptionsTests.cs Remove Sonar pragma suppression (S2330)
test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Polly/HttpClientResiliencePredicatesTests.cs Remove Sonar pragma suppression (S2330)
test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Polly/HttpCircuitBreakerStrategyOptionsTests.cs Remove Sonar pragma suppression (S2330)
test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Internal/RandomizerTest.cs Remove Sonar pragma suppression (S3257)
test/Libraries/Microsoft.Extensions.Hosting.Testing.Tests/FakeHostTests.cs Remove Sonar pragma suppression (S3966)
test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/FakePerformanceCounter.cs Remove Sonar pragma suppression (S3604)
test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV1Tests.cs Remove Sonar SuppressMessage attribute (S3937)
test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxCountersTests.cs Remove Sonar pragma suppression (S103)
test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/AcceptanceTest.cs Remove Sonar SuppressMessage/pragma suppressions (S3257/S1067/S107)
test/Libraries/Microsoft.Extensions.DataIngestion.Tests/IngestionPipelineTests.cs Remove Sonar pragma suppression (S881)
test/Libraries/Microsoft.Extensions.Compliance.Redaction.Tests/HmacRedactorTest.cs Remove Sonar pragma suppressions (S103/S3257)
test/Libraries/Microsoft.Extensions.Compliance.Abstractions.Tests/Classification/DataClassificationTypeConverterTests.cs Remove Sonar pragma suppressions (S3459/S1144)
test/Libraries/Microsoft.Extensions.Compliance.Abstractions.Tests/Classification/DataClassificationSetTests.cs Remove in-source CA1508 pragmas
test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/UnreliableL2Tests.cs Remove Sonar SuppressMessage (S4586)
test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/TypeTests.cs Remove Sonar SuppressMessage attributes (S1144)
test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/TestEventListener.cs Remove Sonar SuppressMessage (S1244)
test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/StampedeTests.cs Remove Sonar SuppressMessage attributes (S5034)
test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SizeTests.cs Remove Sonar SuppressMessage (S107)
test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/ServiceConstructionTests.cs Remove Sonar SuppressMessage (S107)
test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SampleUsage.cs Remove Sonar SuppressMessage (S3398)
test/Libraries/Microsoft.Extensions.AI.Tests/Image/ImageGeneratorBuilderTests.cs Remove Sonar pragma suppression (S3604)
test/Libraries/Microsoft.Extensions.AI.Tests/Functions/AIFunctionFactoryTest.cs Remove Sonar pragmas (S103/S107/S2760/S3358/S5034/S3717)
test/Libraries/Microsoft.Extensions.AI.Tests/Embeddings/EmbeddingGeneratorBuilderTests.cs Remove Sonar pragma suppression (S3604)
test/Libraries/Microsoft.Extensions.AI.Tests/ChatReduction/SummarizingChatReducerTests.cs Remove Sonar pragma suppression (S103)
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/ImageGeneratingChatClientTests.cs Remove in-source CA1508 pragmas
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/ChatClientStructuredOutputExtensionsTests.cs Remove Sonar pragma suppression (S103)
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/ChatClientBuilderTest.cs Remove Sonar pragma suppression (S3604)
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAISpeechToTextClientTests.cs Remove Sonar pragma suppression (S103)
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs Remove Sonar pragma suppression (S103) / whitespace cleanup
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIEmbeddingGeneratorTests.cs Remove Sonar pragma suppression (S103)
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIChatClientTests.cs Remove Sonar pragma suppression (S103)
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIAssistantChatClientTests.cs Remove Sonar pragma suppression (S103)
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIAssistantChatClientIntegrationTests.cs Remove Sonar pragma suppression (S1135)
test/Libraries/Microsoft.Extensions.AI.OllamaSharp.Integration.Tests/IntegrationTestHelpers.cs Remove Sonar pragma suppression (S125)
test/Libraries/Microsoft.Extensions.AI.Integration.Tests/VerbatimMultiPartHttpHandler.cs Remove Sonar pragma suppression (S3996)
test/Libraries/Microsoft.Extensions.AI.Integration.Tests/VerbatimHttpHandler.cs Remove Sonar pragma suppression (S108)
test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ReducingChatClientTests.cs Remove Sonar pragma suppression (S103)
test/Libraries/Microsoft.Extensions.AI.Integration.Tests/PromptBasedFunctionCallingChatClient.cs Remove Sonar pragma suppressions (S1144/S3459)
test/Libraries/Microsoft.Extensions.AI.Integration.Tests/EmbeddingGeneratorIntegrationTests.cs Remove Sonar pragma suppression (S3967)
test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ChatClientIntegrationTests.cs Remove Sonar pragmas (S103/S1144/S3604/S3459)
test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ScenarioRunResultTests.cs Remove Sonar pragma suppression (S1067)
test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/ResultsTests.cs Remove Sonar pragma suppression (S1067)
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Image/ImageGeneratorTests.cs Remove Sonar pragma suppression (S3966)
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Image/DelegatingImageGeneratorTests.cs Remove Sonar pragma suppression (S3966)
test/Libraries/Microsoft.AspNetCore.Testing.Tests/TestResources/Startup.cs Remove Sonar SuppressMessage (S3257)
test/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware.Tests/Logging/AcceptanceTests.cs Remove Sonar SuppressMessage attributes (S1144)
test/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware.Tests/Logging/AcceptanceTests.Routing.cs Remove Sonar SuppressMessage attributes (S1144)
test/Libraries/Microsoft.AspNetCore.Diagnostics.Middleware.Tests/Logging/AcceptanceTests.Mvc.cs Remove Sonar SuppressMessage attributes (S1144)
test/Generators/Microsoft.Gen.Logging/Unit/ParserTests.cs Remove Sonar pragma suppression (S107)
test/Generators/Microsoft.Gen.Logging/Unit/EmitterTests.cs Remove Sonar pragma suppression (S1067)
test/Generators/Microsoft.Gen.Logging/TestClasses/TemplateTestExtensions.cs Remove Sonar pragma suppression (S107)
test/Generators/Microsoft.Gen.Logging/TestClasses/SensitiveRecordExtensions.cs Remove Sonar SuppressMessage (S2376)
test/Generators/Microsoft.Gen.Logging/TestClasses/PrimaryConstructorsExtensions.cs Remove Sonar SuppressMessage (S3604)
test/Generators/Microsoft.Gen.Logging/TestClasses/NullableTestExtensions.cs Remove Sonar pragma suppression (S107)
test/Generators/Microsoft.Gen.Logging/TestClasses/LogPropertiesExtensions.cs Remove Sonar SuppressMessage (S2376)
test/Generators/Microsoft.Gen.Logging/TestClasses/EnumerableTestExtensions.cs Remove Sonar pragma suppression (S107)
test/Generators/Microsoft.Gen.Logging/TestClasses/ConstraintsTestExtensions.cs Remove Sonar pragma suppression (S1186)
test/Generators/Microsoft.Gen.Logging/TestClasses/CollectionTestExtensions.cs Remove Sonar pragma suppression (S107)
test/Generators/Microsoft.Gen.Logging/TestClasses/AttributeTestExtensions.cs Remove Sonar SuppressMessage (S107)
test/Generators/Microsoft.Gen.Logging/TestClasses/ArgTestExtensions.cs Remove Sonar pragma suppression (S107)
test/Generators/Microsoft.Gen.Logging/Generated/LogMethodTests.cs Remove Sonar SuppressMessage (S4056)
test/Generators/Microsoft.Gen.ContextualOptions/TestClasses/ClassWithNoAttribute.cs Remove Sonar SuppressMessage (S2333)
test/Analyzers/Microsoft.Analyzers.Local.Tests/Resources/RoslynTestUtils.cs Remove Sonar SuppressMessage (S107)
test/Analyzers/Microsoft.Analyzers.Local.Tests/Json/JsonValueTest.cs Remove Sonar pragma suppression (S3655)
test/Analyzers/Microsoft.Analyzers.Extra.Tests/Resources/RoslynTestUtils.cs Remove Sonar SuppressMessage (S107)
src/Shared/Throw/Throw.cs Remove Sonar SuppressMessage/pragmas (S4136/S2333/S1940/S1244)
src/Shared/ServerSentEvents/SseParser_1.cs Remove Sonar pragma suppression (S109)
src/Shared/ServerSentEvents/SseParser.cs Remove Sonar pragma suppression (S2333)
src/Shared/ServerSentEvents/Helpers.cs Remove Sonar pragma suppression (S2333)
src/Shared/ServerSentEvents/ArrayBuffer.cs Remove Sonar pragma suppressions (S3358/S109)
src/Shared/DiagnosticIds/DiagnosticIds.cs Remove Sonar pragmas (S1144/S1075)
src/Shared/Data.Validation/ValidationContextExtensions.cs Remove Sonar pragma suppression (S1168)
src/Libraries/Microsoft.Extensions.TimeProvider.Testing/Timer.cs Remove Sonar pragma suppression (S3236)
src/Libraries/Microsoft.Extensions.TimeProvider.Testing/FakeTimeProvider.cs Remove Sonar pragma suppression (S3236)
src/Libraries/Microsoft.Extensions.Telemetry/Sampling/LogSamplingRuleSelector.cs Remove Sonar pragma suppression (S2302)
src/Libraries/Microsoft.Extensions.Telemetry/Logging/JustInTimeRedactor.cs Remove Sonar pragma suppression (S1199)
src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/ProviderAliasUtilities.cs Remove Sonar pragma suppression (S1128)
src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/NullScope.cs Remove Sonar pragma suppression (S1186)
src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerRuleSelector.cs Remove Sonar pragma suppression (S2302)
src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerInformation.cs Remove Sonar pragma suppression (S1128)
src/Libraries/Microsoft.Extensions.Telemetry/Logging/Import/LoggerFactoryScopeProvider.cs Remove Sonar pragma suppression (S2551)
src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLoggerFactory.cs Remove Sonar pragma suppression (S1226)
src/Libraries/Microsoft.Extensions.Telemetry/Enrichment/ProcessLogEnricher.cs Remove Sonar pragma suppression (S2696)
src/Libraries/Microsoft.Extensions.Telemetry/Buffering/LogBufferingFilterRuleSelector.cs Remove Sonar pragma suppression (S2302)
src/Libraries/Microsoft.Extensions.Options.Contextual/ContextualOptionsServiceCollectionExtensions.cs Remove Sonar pragma suppression (S3872)
src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/WeightedGroups/WeightedGroupsRoutingStrategyFactory.cs Remove Sonar pragma suppression (S3366)
src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/OrderedGroups/OrderedGroupsRoutingStrategyFactory.cs Remove Sonar pragma suppression (S3366)
src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/ResilienceHttpClientBuilderExtensions.Resilience.cs Remove Sonar pragma suppression (S1075)
src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResiliencePipelineBuilderExtensions.cs Remove Sonar pragma suppression (S3872)
src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/StandardHedgingHandlerBuilderExtensions.cs Remove Sonar pragma suppression (S3872)
src/Libraries/Microsoft.Extensions.Http.Diagnostics/Http/HttpDependencyMetadataResolver.cs Remove Sonar pragma suppression (S127) / formatting
src/Libraries/Microsoft.Extensions.Hosting.Testing/FakeHostingExtensions.cs Remove Sonar SuppressMessage (S3872)
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsSnapshotProvider.cs Remove Sonar pragma suppression (S107)
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsContainerSnapshotProvider.cs Remove Sonar pragma suppression (S1450)
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/Interop/BOOL.cs Remove Sonar pragma suppression (S1939)
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceQuotaProvider.cs Remove Sonar pragma suppression (S1694)
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitorService.cs Remove Sonar SuppressMessage (S2190)
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationProvider.cs Remove Sonar pragma suppression (S1450)
src/Libraries/Microsoft.Extensions.Diagnostics.Probes/TcpEndpointProbesService.cs Remove Sonar SuppressMessage (S2190)
src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/ManualHealthCheck.cs Remove Sonar SuppressMessage (S3366)
src/Libraries/Microsoft.Extensions.DataIngestion/Log.cs Remove Sonar pragma suppression (S109)
src/Libraries/Microsoft.Extensions.DataIngestion.Markdig/MarkdownParser.cs Remove Sonar pragma suppression (S3967)
src/Libraries/Microsoft.Extensions.DataIngestion.Abstractions/IngestionDocumentElement.cs Remove Sonar pragma suppression (S3967)
src/Libraries/Microsoft.Extensions.Compliance.Abstractions/Redaction/Redactor.cs Remove Sonar SuppressMessage (S3247)
src/Libraries/Microsoft.Extensions.Caching.Hybrid/Internal/TagSet.cs Remove Sonar SuppressMessage (S3877/S3928)
src/Libraries/Microsoft.Extensions.Caching.Hybrid/Internal/RecyclableArrayBufferWriter.cs Remove Sonar SuppressMessage (S125/S3928)
src/Libraries/Microsoft.Extensions.Caching.Hybrid/Internal/ImmutableTypeCache.cs Remove Sonar SuppressMessage (S2178)
src/Libraries/Microsoft.Extensions.Caching.Hybrid/Internal/HybridCachePayload.cs Remove Sonar SuppressMessage (S2344)
src/Libraries/Microsoft.Extensions.Caching.Hybrid/Internal/DefaultHybridCache.StampedeKey.cs Remove Sonar SuppressMessage (S2178)
src/Libraries/Microsoft.Extensions.AsyncState/IAsyncLocalContext.cs Remove Sonar pragma suppression (S4023)
src/Libraries/Microsoft.Extensions.AI/SpeechToText/OpenTelemetrySpeechToTextClient.cs Remove Sonar pragma suppression (S3358)
src/Libraries/Microsoft.Extensions.AI/OpenTelemetryConsts.cs Remove Sonar pragma suppression (S4041)
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs Remove Sonar pragma suppressions (S2219/S3353)
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/ChatClientStructuredOutputExtensions.cs Remove Sonar pragma suppression (S2333)
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAISpeechToTextClient.cs Remove Sonar pragma suppression (S3011)
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs Remove Sonar pragma suppressions (S1226/S3011/S3254)
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIEmbeddingGenerator.cs Remove Sonar pragma suppression (S3011)
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs Remove Sonar pragma suppression (S3011)
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIAssistantsChatClient.cs Remove Sonar pragma suppressions (S125/S1751/S3011)
src/Libraries/Microsoft.Extensions.AI.OpenAI/MicrosoftExtensionsAIResponsesExtensions.cs Remove Sonar pragma suppression (S3254)
src/Libraries/Microsoft.Extensions.AI.Evaluation/Utilities/ModelInfo.cs Remove Sonar pragma suppression (S2219)
src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyService.cs Remove Sonar pragma suppression (S125)
src/Libraries/Microsoft.Extensions.AI.Evaluation.Safety/ContentSafetyEvaluator.cs Remove Sonar pragma suppression (S125)
src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Azure/Storage/AzureStorageResultStore.cs Remove Sonar pragma suppression (S3254)
src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.Create.cs Remove Sonar pragma suppressions (S1075/S1199/S1696)
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionFactory.cs Remove Sonar pragma suppression (S3011)
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunctionArguments.cs Remove Sonar pragma suppression (S4039)
src/Libraries/Microsoft.Extensions.AI.Abstractions/AdditionalPropertiesDictionary{TValue}.cs Remove Sonar pragmas (S4039/S2365)
src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderKey.cs Remove Sonar SuppressMessage (S2931)
src/LegacySupport/TrimAttributes/UnconditionalSuppressMessageAttribute.cs Remove Sonar pragma suppression (S3903)
src/LegacySupport/TrimAttributes/RequiresUnreferencedCodeAttribute.cs Remove Sonar pragma suppressions (S3903/S3996)
src/LegacySupport/TrimAttributes/RequiresDynamicCodeAttribute.cs Remove Sonar pragma suppressions (S3903/S3996)
src/LegacySupport/TrimAttributes/RequiresAssemblyFilesAttribute.cs Remove Sonar pragma suppressions (S3903/S3996)
src/LegacySupport/TrimAttributes/DynamicallyAccessedMembersAttribute.cs Remove Sonar pragma suppression (S3903)
src/LegacySupport/TrimAttributes/DynamicallyAccessedMemberTypes.cs Remove Sonar pragma suppression (S4070)
src/LegacySupport/TrimAttributes/DynamicDependencyAttribute.cs Remove Sonar pragma suppression (S3903)
src/LegacySupport/SystemIndex/Index.cs Remove Sonar pragma suppressions (S3427/S3928) / formatting
src/LegacySupport/StringHash/StringHash.cs Remove Sonar pragma suppression (S3903)
src/LegacySupport/PlatformAttributes/PlatformAttributes.cs Remove Sonar pragma suppressions (S1694/S3996)
src/LegacySupport/ObsoleteAttribute/ObsoleteAttribute.cs Remove Sonar pragma suppression (S3996)
src/LegacySupport/NullabilityInfoContext/NullabilityInfoHelpers.cs Remove Sonar pragma suppression (S3011)
src/LegacySupport/NullabilityInfoContext/NullabilityInfoContext.cs Remove Sonar pragma suppressions (S109/S1067/S4136)
src/LegacySupport/IsExternalInit/IsExternalInit.cs Remove Sonar pragma suppression (S3903)
src/LegacySupport/ExperimentalAttribute/ExperimentalAttribute.cs Remove Sonar pragma suppression (S3996)
src/LegacySupport/DiagnosticAttributes/NullableAttributes.cs Remove Sonar pragma suppression (S3903)
src/LegacySupport/BitOperations/BitOperations.cs Remove Sonar pragma suppression (S109)
src/Generators/Microsoft.Gen.Metrics/Parser.cs Remove Sonar pragma suppression (S107)
src/Generators/Microsoft.Gen.Logging/Parsing/TemplateProcessor.cs Remove Sonar pragma suppression (S109)
src/Generators/Microsoft.Gen.Logging/Parsing/SymbolLoader.cs Remove Sonar pragma suppression (S1067)
src/Generators/Microsoft.Gen.Logging/Parsing/Parser.cs Remove Sonar pragmas (S1067/S125)
src/Generators/Microsoft.Gen.Logging/Parsing/Parser.TagProvider.cs Remove Sonar pragma suppression (S1067)
src/Generators/Microsoft.Gen.Logging/Parsing/Parser.LogProperties.cs Remove Sonar pragmas (S1067/S125)
src/Generators/Microsoft.Gen.Logging/Emission/Emitter.Utils.cs Remove Sonar pragmas (S109/S1643)
src/Generators/Microsoft.Gen.BuildMetadata/Emitter.cs Remove Sonar SuppressMessage and related pragma
src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Utils.cs Remove Sonar pragma suppression (S109)
src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonValue.cs Remove Sonar SuppressMessage/pragmas (S1244/S2589/S1168/S1144)
src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonReader.cs Remove Sonar pragma suppression (S109)
src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonObject.cs Remove Sonar SuppressMessage (S1144)
src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonArray.cs Remove Sonar SuppressMessage (S1144)
src/Analyzers/Microsoft.Analyzers.Extra/CallAnalysis/Fixers/LegacyLoggingFixer.FixDetails.cs Remove Sonar pragma suppression (S109)
eng/Tools/DiagConfig/SaveEditorConfigCmd.cs Remove Sonar pragmas (S3459/S1144)
eng/Tools/DiagConfig/MergeAnalyzersCmd.cs Remove Sonar pragma suppression (S3885)
eng/Tools/DiagConfig/ConfigStore/Metadata.cs Remove Sonar pragma suppression (S3996)
eng/Tools/ApiChief/Processing/PublicFilterVisitor.cs Remove Sonar pragma suppression (S1067)
eng/Tools/ApiChief/Processing/ApiProcessor.cs Remove Sonar SuppressMessage (S1067)
eng/Tools/ApiChief/Format/FormattingExtensions.cs Remove Sonar pragmas (S127/S2583/S1067)
eng/Tools/ApiChief/Commands/EmitSummary.cs Remove Sonar SuppressMessage args metadata
eng/Tools/ApiChief/Commands/EmitReview.cs Remove Sonar SuppressMessage + pragma (S109)
eng/Tools/ApiChief/Commands/EmitDelta.cs Remove Sonar SuppressMessage args metadata
eng/Tools/ApiChief/Commands/EmitBaseline.cs Remove Sonar SuppressMessage args metadata
eng/Tools/ApiChief/Commands/CheckBreakingChanges.cs Remove Sonar SuppressMessage args metadata
eng/MSBuild/Analyzers.props Remove SonarAnalyzer.CSharp package reference
bench/Libraries/Microsoft.Extensions.Telemetry.PerformanceTests/ClassicCodeGen.cs Remove Sonar pragma suppressions
bench/Libraries/Microsoft.Extensions.Http.Diagnostics.PerformanceTests/DropMessageLoggerProvider.cs Remove Sonar SuppressMessage (S1186)
Directory.Build.targets Remove Sonar-specific NoWarn (S3236)

Comment on lines 122 to 123
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After removing the in-source suppression, using System.Diagnostics.CodeAnalysis; at the top of this file is no longer used. Please remove the unused using to prevent IDE0005 warnings during build.

Copilot uses AI. Check for mistakes.
Comment on lines 81 to 83
private async Task OpenTcpAsync(CancellationToken cancellationToken)
{
while (true)
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using System.Diagnostics.CodeAnalysis; is now unused in this file after removing the SuppressMessage attribute. Please remove the unused using to avoid IDE0005 warnings.

Copilot uses AI. Check for mistakes.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using System.Diagnostics.CodeAnalysis; is no longer referenced in this file after removing the SuppressMessage attribute. Please remove the unused using to prevent IDE0005 warnings.

Suggested change
using System.Diagnostics.CodeAnalysis;

Copilot uses AI. Check for mistakes.
Comment on lines 131 to 133
private static void ProcessMethods(ITypeDefinition type, ApiType finalTypeApi, ApiStage classStage)
{
var methods = type.Methods
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using System.Diagnostics.CodeAnalysis; appears unused in this file now that the SuppressMessage attribute was removed. Please remove the unused using to avoid IDE0005 warnings.

Copilot uses AI. Check for mistakes.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using System.Diagnostics.CodeAnalysis; is now unused in this file (the only SuppressMessage was removed). Please remove the unused using to avoid IDE0005 warnings.

Suggested change
using System.Diagnostics.CodeAnalysis;

Copilot uses AI. Check for mistakes.
@dariusclay
Copy link
Member

The data is compelling, and I agree that analyzer perf (especially SymbolicExecutionRunner) is a real problem that needs to be addressed.
Where I'm uncomfortable is that this change goes beyond addressing the slow analyzers and effectively resets the static-analysis policy for the entire repo. Can we do a more targeted approach here?

@dariusclay
Copy link
Member

@stephentoub have we considered alternatives like https://github.com/dotnet/roslynator? Again, I'm all for improving the DX here. Maybe we first go with this update, then look at the long-term plan.

@stephentoub
Copy link
Member Author

@dariusclay, which diagnostics from SonarAnalyzers in particular are you concerned about? Beyond perf, in my experience with this repo, they've been almost entirely noise. You can see in the diff the hundreds upon hundreds of suppressions that were necessary to stay building, which is after many of the rules were individually disabled because of significant disruption. And when these rules have flagged things that we've decided to "fix" rather than suppress, the vast majority case is that it's not actually making anything better, just adhering to someone's opinion on a "code smell".

@dariusclay
Copy link
Member

@dariusclay, which diagnostics from SonarAnalyzers in particular are you concerned about? Beyond perf, in my experience with this repo, they've been almost entirely noise. You can see in the diff the hundreds upon hundreds of suppressions that were necessary to stay building, which is after many of the rules were individually disabled because of significant disruption. And when these rules have flagged things that we've decided to "fix" rather than suppress, the vast majority case is that it's not actually making anything better, just adhering to someone's opinion on a "code smell".

Not any specific rule, actually. Removing static analysis doesn't remove opinions...it just makes them implicit.
We, as maintainers, still need to agree on what the quality bar is and how it's enforced.
That broader alignment feels outside the scope of this PR, but it's an important conversation to have.

Copy link
Member

@evgenyfedorov2 evgenyfedorov2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this file eng/Diags/SonarAnalyzer.CSharp.yml and Microsoft.Extensions.StaticAnalysis package which still includes Sonar rules?

@evgenyfedorov2
Copy link
Member

evgenyfedorov2 commented Mar 5, 2026

Beyond perf

but we are removing the perf here too, so what's the replacement? @stephentoub

@stephentoub
Copy link
Member Author

Removing static analysis doesn't remove opinions...it just makes them implicit

I don't understand this statement. Turning off SonarAnalyzer is removing the enforcement of its opinions; it can of course still have them, but they don't matter.

We, as maintainers, still need to agree on what the quality bar is and how it's enforced.

I agree. I'm just not seeing this package increasing quality.

As far as I can tell, when this repo was set up, various analyzer packages were added under the assumption that they're all good and everything was turned up to 11. I've not seen evidence that it's actually made quality better, and from a maintenance perspective, in many ways I think it's made things worse and caused unnecessary developer slowdown and pain by enforcing unnecessary and unvaluable opinions.

I'd be very happy to have a conversation about turning on additional rules we all agree are valuable, including if there are any in SonarAnalyzers we think are actually really useful. Approaching it from the perspective of starting from a blank slate and adding in the useful ones is more appealing to me than having to wade through the noise looking for the signal, which is the path we've been on.

Do you want to set up a meeting to discuss?

but we are removing the perf here too, so what's the replacement?

@evgenyfedorov2, what do you mean? My performance comment was about these analyzers causing significant slowdown in build times. Are you asking about performance-focused analyzers? Which ones?

@stephentoub stephentoub marked this pull request as draft March 5, 2026 14:13
@evgenyfedorov2
Copy link
Member

evgenyfedorov2 commented Mar 5, 2026

what do you mean? My performance comment was about these analyzers causing significant slowdown in build times. Are you asking about performance-focused analyzers? Which ones?

ok I thought you were talking about perf-focused analyzer rules, yes :) quickly skimming through Sonar rules, they are mostly code smells of all kinds.

Anyway,

I'd be very happy to have a conversation about turning on additional rules we all agree are valuable, including if there are any in SonarAnalyzers we think are actually really useful. Approaching it from the perspective of starting from a blank slate and adding in the useful ones is more appealing to me than having to wade through the noise looking for the signal, which is the path we've been on.

it sounds great, as an idea - how about we disable all rules and then register an Issue to go through each Sonar rule and see whether it makes sense to enable it or not.

@dariusclay
Copy link
Member

@stephentoub fundamentally agree here. This isn't about SonarAnalyzer, and it has its own problems even outside of build-time costs (licensing model).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants