-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Native host warnings fix #52109
Native host warnings fix #52109
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Native host warnings fix
src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs
Outdated
Show resolved
Hide resolved
...oreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/InMemoryAssemblyLoader.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.xml
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Suppressions.LibraryBuild.xml
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs
Outdated
Show resolved
Hide resolved
...oreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/InMemoryAssemblyLoader.cs
Outdated
Show resolved
Hide resolved
@elinor-fung, we expect trimming C++/CLI Assembly scenarios to be extremely rare and hence the property being prefixed with underscore. I added some description to the PR header to indicate the flow |
Re C++/CLI - I think we should be careful here. There are two distinct scenarios which have very different probabilities:
I think we need to find out which codepath is used when loading C++/CLI from managed code - the answer to that will answer what we need to do here. |
@LakshanF here's that basic example of a C# app using a C++/CLI library: https://github.com/elinor-fung/basic-cpp-cli |
src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.xml
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.xml
Outdated
Show resolved
Hide resolved
@@ -51,6 +51,7 @@ enum StatusCode | |||
HostPropertyNotFound = 0x800080a4, | |||
CoreHostIncompatibleConfig = 0x800080a5, | |||
HostApiUnsupportedScenario = 0x800080a6, | |||
HostFeatureDisabled = 0x800080a7, |
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.
Please add this to https://github.com/dotnet/runtime/blob/main/docs/design/features/host-error-codes.md as well.
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.
Should have been there in my commit
Co-authored-by: Vitek Karas <vitek.karas@microsoft.com>
…rs.xml Co-authored-by: Vitek Karas <vitek.karas@microsoft.com>
…rs.xml Co-authored-by: Vitek Karas <vitek.karas@microsoft.com>
Co-authored-by: Vitek Karas <vitek.karas@microsoft.com>
src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.xml
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs
Outdated
Show resolved
Hide resolved
...oreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/InMemoryAssemblyLoader.cs
Show resolved
Hide resolved
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.
Would it be worth adding a hosting test that turns off the ComponentActivator
feature switch? Or is something like that already wrapped up in broader testing somewhere?
Addressed the ComponentActivator suppressed warnings by bubbling them up to entry points. We were not rooting ComponentActivator and InMemoryAssemblyLoader that can be called by native hosts. Rooted these 2 types behind a feature switch similar to StartupHookProvider. These code should be used in rare circumstances with trimmed applications and the msbuild property related to this indicate that and we will generate a warning if trimming with the property set to true.
The full details are as below:
IsSupported
is set to false (these APIs will not work). The default behavior will also mean that for all developers who want to trim their application AND do not use these native host entry points, they will not see any trimmer warnings related to this API.IsSupported
will be true) when trimming. We assume the developer knows how to make the trimmed application work in this case (specifically, the managed API they are going to call from native side will exist). The trimmer warnings will now light up on this scenario to give some indication of the potential problem to the developer. Aside: the warning message should be something like "really???" but we use technical words along the line of "method might be missing..." since we expect developers who leverage this - calling this API on a self-contained trimmed applications - to know what they are doing and want to trim their application.