Remove more `[PublicApi]` usages and unused code by andrewlock ยท Pull Request #7786 ยท DataDog/dd-trace-dotnet

added 3 commits

November 6, 2025 13:02

chatgpt-codex-connector[bot]

@andrewlock

bouwkast

lucaspimentel

lucaspimentel

lucaspimentel

zacharycmontoya

andrewlock added a commit that referenced this pull request

Nov 10, 2025
## Summary of changes

Deletes a bunch of enum members from `PublicApiUsage` which are unused

## Reason for change

These were unused or _couldn't_ logically be called in production code,
so were just adding overhead as we allocate the array to record them.

Fixed one case where we _Should_ have been recording it, but weren't

## Implementation details

FindAllReferences on each member => if it's not used in Datadog.Trace,
remove it

## Test coverage

Covered by existing

## Other details

Part of a stack

- #7786
- #7787 ๐Ÿ‘ˆ
- #7788

andrewlock added a commit that referenced this pull request

Nov 14, 2025
## Summary of changes

Repurposes the now-defunct `PublicApiAnalyzer` to an
`InternalForTestingAnalyzer`

## Reason for change

We have various methods in `Datadog.Trace` that should never be called
by production code, and are only exposed to make testing functionality
easier. Currently we rely on method names and comments to avoid this.
With this change, we can add an attribute instead, and using the method
from Datadog.Trace etc becomes a build error.

## Implementation details

- Basically just renamed `PublicApi*` -> `InternalForTesting*`
- Decorated methods that were currently relying on comments/naming to
avoid being called

## Test coverage

Refactored the analyzer tests, so should still be covered the same

## Other details

Note that there are a bunch of comments for methods `// internal for
testing` which are a bit different. In those cases, we _do_ call it in
Datadog.Trace, the comment is just explaining why the method isn't
`private`. Those remain as-is, this attribute is purely if you have a
"don't call this method in production code, use that other one instead"
method ๐Ÿ˜„

Part of a stack

- #7786
- #7787
- #7788 ๐Ÿ‘ˆ