-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Enable setting the TypeMap entrypoint assembly via a RuntimeHostConfigurationOption #121513
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
entrypoint assembly for building the typemap.
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 implements a new feature that enables the TypeMap entrypoint assembly to be configured via a RuntimeHostConfigurationOption, allowing TypeMap to be used with Library output types instead of only executable output types. The change provides a way to specify which assembly should be scanned for TypeMap attributes when the entry point assembly is not appropriate (e.g., in library scenarios).
Key changes:
- Added support for
System.Runtime.InteropServices.TypeMappingEntryAssemblyconfiguration option across the CoreCLR compiler, trimmer, and runtime - Modified the
--featureflag in illink to accept string values in addition to boolean values - Added new tests to validate TypeMap entry assembly configuration works correctly
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs | Modified runtime to check AppContext for TypeMappingEntryAssembly override before falling back to entry assembly |
| src/coreclr/tools/aot/ILCompiler/Program.cs | Added runtime knob parsing to extract TypeMappingEntryAssembly and use it for TypeMap metadata |
| src/tools/illink/src/linker/Linker/Driver.cs | Modified --feature flag to accept and store string values alongside boolean values |
| src/tools/illink/src/linker/Linker/LinkContext.cs | Added Features dictionary to store string-valued features |
| src/tools/illink/src/linker/Linker.Steps/MarkStep.cs | Added logic to check Features for TypeMappingEntryAssembly override |
| src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/TrimmingDriver.cs | Added comment explaining test behavior with entry assembly |
| src/tests/Interop/TypeMap/*.cs | Added new runtime test files validating TypeMappingEntryAssembly configuration |
| src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/*.cs | Added trimmer test cases and updated existing tests for renamed method |
...libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs
Show resolved
Hide resolved
However, it's still necessary to set the RuntimeConfigurationOption for runtime behavior on CoreCLR.
MichalStrehovsky
left a comment
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.
Looks good otherwise!
src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/ILCompilerOptions.cs
Outdated
Show resolved
Hide resolved
| RuntimeAssembly? startingAssembly; | ||
| if (AppContext.GetData("System.Runtime.InteropServices.TypeMappingEntryAssembly") is string entryAssemblyName) | ||
| { | ||
| startingAssembly = Assembly.Load(entryAssemblyName) as RuntimeAssembly; |
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.
This is odd. The as operator implies the returned type could be a non RuntimeAssembly. I don't believe that is true. This is a confusing cast. It should just be (RuntimeAssembly).
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.
Ah, I forgot (RuntimeAssembly)null! returns null instead of throwing. Will update to make that clear.
Implements the alternative to #121138 mentioned in #121138 (comment)
Enables the TypeMap to be used in Library output types. Projects can set the following RuntimeHostConfigurationOption to enable this behavior. If it exists, this option takes priority over the entrypoint assembly.