Use DynamicDependencyAttribute#37780
Conversation
|
Should we use this as an opportunity to clean these up?
|
Yes, let's remove them
I disagree at BCL level we should be explicit where possible |
I meant places like the |
|
I would probably postpone converting For this conversion itself, there are basically 3 cases:
|
The plan was to be explicit with the attributes until we can turn on the linker analysis, and have a test that covers the dependency is kept. Once we have linker analysis enabled (and it breaking the build if this gets broken) and a test that covers these reflection usages, I'd prefer we keep being explicit. |
f2b00da to
1c28e36
Compare
|
For now I have added comments about the ones that should be converted to |
There was a problem hiding this comment.
I've moved this attribute closer to the internalcall that depends on it. Does that make sense?
- Use typeof in more places - Add comments about DynamicallyAccessedMembers - Add comments about cases where we work around linker limitations - Also move AssemblyBuilder`s DynamicDependency closer to where it is actually needed.
e11faf6 to
e4171bf
Compare
| } | ||
| #endif | ||
|
|
||
| // These PreserveDependency attributes are a workaround for https://github.com/dotnet/runtime/issues/19348. |
There was a problem hiding this comment.
Not for you to fix here, but reading this message, it sounds like we should move these to a “library build” xml descriptor file instead. That way we don’t need to hack around this with ILKeepDepsAttributes=false. I’ll open an issue for this on Monday.
On down-level platforms where DynamicDependencyAttribute doesn't exist in corelib, this includes it in the OOB assemblies.
bac058e to
a6f3e39
Compare
Fixes #37475. I'm still waiting for dependency flow (dotnet/linker#1262 allows keeping members by name like
PreserveDependencydid), but opening this for review in the meantime.