-
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
DynamicallyAccessedMembers with a string TypeName of a generic type with different assemblies doesn't appear to work #1536
Comments
@eerhardt What have you done 😄 - as I dig into this I find more and more "broken things". I'm working on a PR which will fix the immediate problem of not looking in the right assembly. But that alone will probably not fix the original issue since then it hits the problem of not being able to lazy-load assemblies. To fix that we will need to add Only semi-related: |
The failure to resolve the assembly is because of facades .. booo. |
I filed #1542 to track the problem with not seeing through facades. |
As a side note: Why do we have For example in the test app, the I can understand having two similar facades due to backward compatibility reasons, but if I start a new .NET 5 app, I would expect we always use only one of those facades. |
I think the linker works correctly now:
I don't see anything which should force The "normal" way the code gets the information via IL2026: Using method 'System.ComponentModel.TypeDescriptor.GetProperties(object)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered. I don't know why |
Sorry, I should have said more above. Change: var xel = new XElement("someElement");
var props = TypeDescriptor.GetProperties(xel); to var props = TypeDescriptor.GetProperties(typeof(XElement)); You'll still get an But now instead of 21 properties, you get back 15. The 6 that are missing are the ones injected by
The reason for this, as far as I can tell, is because the
Since the type
It looks to be that way in .NET Framework as well: https://referencesource.microsoft.com/#System.Xml.Linq/System/Xml/Linq/XComponentModel.cs,13. I assume the reason they did this was so they didn't have to duplicate 3 sets of classes for |
#2099 adds a simpler test case for the same issue. |
I see this is still in the ".NET 6" milestone. Are we expecting to resolve this issue for 6? I am moving the blocked issue in dotnet/runtime (dotnet/runtime#39709) to 7.0, because I don't believe the scenario that found this linker issue is necessary for 6.0. But I'm wondering if the underlying linker issue will be fixed for 6. |
Is this targeting 7 now? |
Sorry we dropped the ball on this. I'll try to get to this (or find somebody to look into it). |
See dotnet/runtime#39709 for the tests that found this issue.
Using the following code:
Run the above program without trimming, and you get:
Run the above program after it has been trimmed (TrimMode=link) and you get:
The
TypeDescriptionProvider
attribute is attributed withDynamicallyAccessedMembers
. However, the value being passed in is causing problems for the linker.It appears this code is the problem:
https://github.com/mono/linker/blob/90fd1feac709a910ba2aa849657b0c04777fc67d/src/linker/Linker/TypeNameResolver.cs#L63-L66
This code assumes that the generic type argument is in the same assembly as the outer generic type. But this is not the case above - the outer generic type is in
System.ComponentModel.TypeConverter
. While the generic argument is inSystem.Xml.Linq
.I tried fixing this myself, but then I ran into that
_context.GetLoadedAssembly("System.Xml.Linq")
was returningnull
for some reason. We should investigate this complete scenario and ensure it works properly.cc @mateoatr @vitek-karas @marek-safar
The text was updated successfully, but these errors were encountered: