[Infra] Suppress code analysis warnings#6905
Conversation
Suppress code analysis warnings I found from building the whole solution locally in Visual Studio 2026. Also applies some code formatting/refactoring suggestions in files I had to touch.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6905 +/- ##
========================================
Coverage 86.35% 86.36%
========================================
Files 263 263
Lines 12387 12563 +176
========================================
+ Hits 10697 10850 +153
- Misses 1690 1713 +23
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Pull request overview
This PR addresses code analysis warnings found when building the solution in Visual Studio (described as "Visual Studio 2026" which appears to be a typo). The changes include suppressing specific CA warnings (CA1873, CA2025) and applying modern C# syntax refactorings such as collection expressions and expression-bodied members.
Changes:
- Added CA1873 warning suppression for potentially expensive logging in test and doc projects
- Refactored code to use modern C# syntax: collection expressions (
[]), expression-bodied members, and field keyword for semi-auto properties - Added CA2025 warning suppression in ZipkinExporter for intentional blocking HTTP call pattern
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/OpenTelemetry.Tests/Logs/LogRecordTests.cs | Adds CA1873 suppression; refactors to use collection expressions, expression-bodied members, and field keyword |
| test/Benchmarks/Logs/LogBenchmarks.cs | Refactors benchmark methods to expression-bodied syntax; adds CA1873 suppression; contains invalid empty class syntax |
| src/OpenTelemetry.Exporter.Zipkin/ZipkinExporter.cs | Adds CA2025 suppression for synchronous HTTP call; converts method to expression-bodied syntax |
| docs/Directory.Build.props | Adds CA1873 to NoWarn list for documentation projects |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Move suppression from `Directory.Build.props` to `extending-the-sdk.csproj`.
Changes
Suppress code analysis warnings I found from building the whole solution locally in Visual Studio 2026.
Also applies some code formatting/refactoring suggestions in files I had to touch.
Merge requirement checklist
Unit tests added/updatedAppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)