-
Notifications
You must be signed in to change notification settings - Fork 128
Description
The TypeForwardedFromAttribute allows for serializers (i.e. BinaryFormatter and XmlSerializer) to write Type names using a "stable" assembly name - one that won't change from version-to-version even if the Type moves assemblies.
These attributes typically point to facade assemblies.
The issue is that trimming will remove the facade assemblies. Thus code in XmlSerializer, which tries loading that assembly, is going to fail.
If the trimmer sees a TypeForwardedFromAttribute to a facade assembly, it is going to need to preserve that facade assembly after trimming.
I tried to find other attributes that have this same issue, and came up with 2 other instances of attributes taking assembly names:
- InternalsVisibleToAttribute
- DynamicDependencyAttribute
We may need to handle DynamicDependency similar to TypeForwardedFrom - if the attribute is referencing an assembly, that assembly can't be trimmed. My initial thoughts for InternalsVisibleTo is that it shouldn't matter if the assembly is trimmed.
If this pattern exists for more places than these attributes, we may have to add a new annotation that tells the trimmer the string is an "assembly name". Similarly to how [DynamicallyAccessedMembersAttribute] on a string tells the trimmer the string is a Type name.