[Infra] Add banned API analyzers#4131
Merged
martincostello merged 3 commits intoApr 17, 2026
Merged
Conversation
Add analyzers to prevent use of .NET APIs in production code that have preferred alternatives.
martincostello
had a problem deploying
to
external
April 16, 2026 10:03 — with
GitHub Actions
Failure
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4131 +/- ##
==========================================
- Coverage 72.89% 72.69% -0.20%
==========================================
Files 460 468 +8
Lines 18213 18256 +43
==========================================
- Hits 13276 13271 -5
- Misses 4937 4985 +48 Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
4 tasks
martincostello
had a problem deploying
to
external
April 16, 2026 12:38 — with
GitHub Actions
Failure
martincostello
marked this pull request as ready for review
April 16, 2026 12:50
martincostello
enabled auto-merge
April 16, 2026 12:50
Contributor
There was a problem hiding this comment.
Pull request overview
Adds infrastructure-level banned API enforcement for production projects to steer usage toward preferred HTTP helper patterns.
Changes:
- Add
Microsoft.CodeAnalysis.BannedApiAnalyzersas a global analyzer package reference. - Introduce
build/BannedSymbols.txtand wire it into production builds viaCommon.prod.props. - Include the new banned-symbols file in the solution items.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| opentelemetry-dotnet-contrib.slnx | Adds build/BannedSymbols.txt to solution items for visibility/editing. |
| build/Common.prod.props | Registers BannedSymbols.txt as an AdditionalFiles input for analyzers in production builds. |
| build/BannedSymbols.txt | Defines banned .NET HTTP APIs and suggested alternatives. |
| Directory.Packages.props | Adds global reference to Microsoft.CodeAnalysis.BannedApiAnalyzers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
martincostello
commented
Apr 16, 2026
Fix incorrect method signatures.
martincostello
had a problem deploying
to
external
April 16, 2026 12:59 — with
GitHub Actions
Failure
Kielek
approved these changes
Apr 17, 2026
Merged
via the queue into
open-telemetry:main
with commit Apr 17, 2026
09f26f5
328 of 329 checks passed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
Add analyzers to prevent use of .NET APIs in production code that have preferred alternatives.
Merge requirement checklist
Unit tests added/updatedAppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)