-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Put native format ToString
overrides under ifdef
#118723
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
I don't think anything calls these and because these are virtual, they cannot be trimmed.
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 optimizes the generated native format metadata reader by conditionally compiling ToString override methods under DEBUG preprocessor directives. The change prevents these virtual ToString methods from being included in release builds, improving code trimming efficiency since virtual methods cannot be trimmed by the compiler.
Key changes:
- Wrap all ToString override methods in #if DEBUG directives across handle types
- Update the code generator to emit the conditional compilation directives
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs | Wraps existing ToString overrides in #if DEBUG directives for all handle types |
src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/ReaderGen.cs | Updates the code generator to emit ToString methods under #if DEBUG |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
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.
I assume that we want to keep GetHashCode/Equals since they are used or to avoid generating fallback support for them.
I'm not sure... I can make a PR that replaces them with throws and run CI on it. Fallback support is generated either way because we don't have analysis for whether someone implemented GetHashCode as |
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
I don't think anything calls these and because these are virtual, they cannot be trimmed.
Cc @dotnet/ilc-contrib