Update SonarAnalyzer.CSharp to latest#7092
Merged
stephentoub merged 1 commit intodotnet:mainfrom Dec 1, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the SonarAnalyzer.CSharp analyzer from version 8.56.0.67649 to 10.16.0.128591 and addresses the new analyzer warnings and suggestions introduced by this update. The changes are purely code quality improvements with no functional impact - they improve performance, code clarity, and consistency across the codebase.
Key Changes:
- Enhanced culture-aware DateTime/DateTimeOffset parsing in tests using
DateTimeFormatInfo.InvariantInfo - Optimized LINQ-to-Objects operations by replacing with more efficient array-based methods (
FirstOrDefault→Array.Find,Any→Array.Exists/List.Exists,All→Array.TrueForAll) - Improved structured logging with PascalCase template parameter names following Microsoft conventions
- Various code simplifications including boolean expression cleanup, named parameter usage, and control flow consolidation
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| eng/packages/General.props | Updates SonarAnalyzer.CSharp package version from 8.56.0.67649 to 10.16.0.128591 |
| test/.editorconfig | Configures new analyzer rules (S6672, S6966, S6967) and disables rules with too many false positives (S107, S3247, S6588) |
| src/Libraries/.editorconfig | Same analyzer rule configuration updates for source libraries |
| eng/Tools/.editorconfig | Same analyzer rule configuration updates for engineering tools |
| test/Libraries/Microsoft.Extensions.AI.Tests/Embeddings/DistributedCachingEmbeddingGeneratorTest.cs | Adds culture-aware DateTimeOffset parsing with InvariantInfo for test data |
| test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/DistributedCachingChatClientTest.cs | Adds culture-aware DateTime parsing with InvariantInfo for test assertions |
| test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Embeddings/EmbeddingTests.cs | Adds culture-aware DateTimeOffset parsing with InvariantInfo for test data |
| test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Embeddings/BinaryEmbeddingTests.cs | Adds culture-aware DateTimeOffset parsing with InvariantInfo for test data |
| test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/ChatCompletion/ChatResponseUpdateExtensionsTests.cs | Adds culture-aware DateTimeOffset parsing with InvariantInfo across multiple test scenarios |
| test/Generators/Microsoft.Gen.Logging/TestClasses/NonSensitiveRecordExtensions.cs | Simplifies record declaration syntax by removing empty parameter list |
| src/Shared/ServerSentEvents/SseItem.cs | Simplifies boolean comparisons by removing redundant is true checks |
| src/Shared/FxPolyfills/IPEndPoint.cs | Consolidates duplicate conditional branches with identical assignments |
| src/Libraries/Microsoft.Extensions.Telemetry/Buffering/GlobalLogBufferManager.cs | Adds closure-free GetOrAdd overload using static lambda for NET target framework |
| src/Libraries/Microsoft.Extensions.ServiceDiscovery.Dns/Resolver/DnsResolver.cs | Replaces LINQ methods with more efficient List methods (FirstOrDefault → Find, Any → Exists) |
| src/Libraries/Microsoft.Extensions.ServiceDiscovery.Dns/DnsServiceEndpointProviderBase.cs | Consolidates duplicate conditional branches with combined condition |
| src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationParserCgroupV2.cs | Optimizes string concatenation using string interpolation to avoid ToString() allocation |
| src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/Disk/DiskStatsReader.cs | Replaces LINQ Any with Array.Exists and removes unused System.Linq import |
| src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheck.cs | Uses named parameter syntax for better code clarity |
| src/Libraries/Microsoft.Extensions.DataIngestion.MarkItDown/MarkItDownMcpReader.cs | Uses named parameter syntax for better code clarity |
| src/Libraries/Microsoft.Extensions.DataIngestion.Abstractions/Microsoft.Extensions.DataIngestion.Abstractions.csproj | Suppresses additional SonarAnalyzer rule S2368 |
| src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs | Replaces LINQ Any with List.Exists for better performance |
| src/Libraries/Microsoft.Extensions.AI.OpenAI/MicrosoftExtensionsAIChatExtensions.cs | Uses named parameters for factory method calls to improve code clarity |
| src/Libraries/Microsoft.Extensions.AI.Evaluation/CompositeEvaluator.cs | Uses named parameter syntax for better code clarity |
| src/Libraries/Microsoft.Extensions.AI.Evaluation.Console/Telemetry/TelemetryHelper.cs | Updates logging statement to use structured logging with PascalCase parameter names |
| src/Libraries/Microsoft.Extensions.AI.Evaluation.Console/Telemetry/EnvironmentHelper.cs | Replaces LINQ All with Array.TrueForAll and removes unused System.Linq import |
| src/Libraries/Microsoft.Extensions.AI.Evaluation.Console/Commands/ReportCommand.cs | Updates logging template parameter names to PascalCase convention |
| src/Libraries/Microsoft.Extensions.AI.Evaluation.Console/Commands/CleanResultsCommand.cs | Updates logging template parameter names to PascalCase convention |
| src/Libraries/Microsoft.Extensions.AI.Evaluation.Console/Commands/CleanCacheCommand.cs | Updates logging template parameter names to PascalCase convention |
| src/Generators/Shared/DiagDescriptorsBase.cs | Uses named parameter syntax for DiagnosticDescriptor constructor |
| src/Generators/Microsoft.Gen.Logging/Parsing/Parser.cs | Replaces LINQ All with List.TrueForAll for consistency |
| src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonValue.cs | Adds culture-aware DateTime parsing with InvariantInfo and DateTimeStyles.None |
| src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/Json/JsonObject.cs | Fixes DebuggerDisplay attribute to reference correct field names |
| src/Analyzers/Microsoft.Analyzers.Local/ApiLifecycle/AssemblyAnalysis.cs | Replaces LINQ FirstOrDefault with Array.Find for better performance across multiple locations |
| bench/Libraries/Microsoft.Extensions.Telemetry.PerformanceTests/ModernCodeGen.cs | Replaces FormattableString.Invariant with string.Create for modern .NET optimization |
evgenyfedorov2
approved these changes
Dec 1, 2025
shyamnamboodiripad
approved these changes
Dec 1, 2025
This was referenced Dec 11, 2025
This was referenced Dec 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Microsoft Reviewers: Open in CodeFlow