-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Use UnsafeAccessor in System.Diagnostics.Debug.Tests #120732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 modernizes the System.Diagnostics.Debug.Tests by replacing reflection-based access to internal Debug and DebugProvider members with the more efficient and type-safe UnsafeAccessor pattern. This addresses issue #120722 and follows modern .NET best practices for accessing private/internal members in tests.
Key changes:
- Replaces reflection calls with UnsafeAccessor methods for accessing internal Debug provider functionality
- Adds a new public GetProvider() method to Debug class to support testing needs
- Updates compatibility suppressions to handle the new public API
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTests.cs | Replaces reflection-based field access with UnsafeAccessor methods for cleaner, more efficient test code |
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs | Adds public GetProvider() method to expose the internal provider for testing |
src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.ExtraApis.txt | Registers the new GetProvider method in the extra APIs list |
src/coreclr/System.Private.CoreLib/CompatibilitySuppressions.xml | Adds compatibility suppression for the new GetProvider method |
src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTests.cs
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTests.cs
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTests.cs
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTests.cs
Show resolved
Hide resolved
Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag |
src/coreclr/System.Private.CoreLib/CompatibilitySuppressions.xml
Outdated
Show resolved
Hide resolved
Cleanup this as well Lines 6 to 13 in 0327b0d
|
Fixes #120722