-
Notifications
You must be signed in to change notification settings - Fork 127
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
Non constant BindingFlags causes ILLinker to trim required methods #1617
Comments
#1619 has a sample test case for this. The bug is that we only recognize binding flags if they are constants. If not, we actually behave as if an overload of The correct behavior is to fallback to "annotations" (in spirit, not in implementation) and mark all methods on the affected type. Basically the same thing we do if IgnoreCase binding flag is specified. This bug likely affects fields and properties and potentially other things as well. |
@tlakollo could you please take a look at this and possibly fix it? |
Make XmlSerializer work correctly with ILLinker trimming. 1. Use constant BindingFlags to work around dotnet/linker#1617 2. Annotate CodeGenerator.CreateTypeBuilder correctly to preserve base class members Fix dotnet#41389
* XmlSerializer.Serialize doesn't work when using TrimMode=link Make XmlSerializer work correctly with ILLinker trimming. 1. Use constant BindingFlags to work around dotnet/linker#1617 2. Annotate CodeGenerator.CreateTypeBuilder correctly to preserve base class members Fix #41389 * Update ILLinker suppressions file. * PR feedback. Fix ILLinker suppresions.
When a non-public method is called through Reflection, but the
BindingFlags
parameter is not a constant, the ILLinker won't preserve the called method, and it won't log a warning. Thus the user thinks their app will work successfully, but the app doesn't since the called method is trimmed.This scenario was found in System.Private.Xml and is one of the underlying causes of issue dotnet/runtime#41389.
https://github.com/dotnet/runtime/blob/819a3cc69e2bf606787a44f9f107ebbbed0fcb11/src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeGenerator.cs#L24-L28
Example
Fully trim the following application:
When trimmed, the application will throw:
cc @vitek-karas
The text was updated successfully, but these errors were encountered: