-
Notifications
You must be signed in to change notification settings - Fork 128
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
Consider allowing DynamicallyAccessedMembers on types #1196
Comments
What about interfaces - the famous |
Can you remind me of the If it's the latter, it would still have the problem with:
|
I don't know for sure, but I think it's the "DI-like" behavior - so this attribute alone would not solve the whole problem. But it could be a part of the solution:
I do agree that recognizing the general pattern would be hard, but we could possibly handle some special pattern which would help with that. In the end this is problematic because it's likely that those types are stored in a collection and we don't have an annotation for collection members really. |
This would also help analyzing |
Two questions:
|
Yep, the purpose is to make
I think you're looking at it from an implementation perspective. From a user perspective, this is doing the same thing - it ensures the |
Could this functionality be used to make ASP.NET MVC linker-safe? cc @davidfowl In MVC, there is a base class |
If the pattern is "dig though all types in an assembly and find the ones that derive from What is being proposed here is to allow making a connection starting from This wouldn't work so nicely for the patterns where someone goes over all types in an assembly, filters them with something horrible like a lambda with a capture that
That kinds of patterns could probably only be made safe (with reasonable effort) by adding a dedicated new API (e.g. |
This pattern is so common, it would be awesome to have an API that was declarative like this in the BCL. |
This might be one way for us to solve #1806 which I just filed today. Bringing this topic back up since we're trying to annotate ASP.NET Core and EF for 6.0. |
Can this be closed? Looks like dotnet/runtime#49778 and #1929 solve this. |
Yup. |
👍🏾 |
We don't currently allow this. The semantic would be "keep the specified member types on this type and all derived types".
Blazor has a pattern where it does
Object.GetType
on an unsealed type and then goes over the properties on that type. This annotation would make it so that the result ofObject.GetType
is an annotatedSystem.Type
instance (the annotation would be an aggregate of all DynamicallyAccessedMemberKinds specified on the type ofthis
for theGetType
call and its base types).This would make the
GetProperties
call provably linker-safe extra annotations/suppressions.The text was updated successfully, but these errors were encountered: