-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Strip the ILLinkTrim.xml file from the System.ComponentModel.TypeConverter assembly #37402
Conversation
Tagging subscribers to this area: @safern |
@layomia could you point me to the docs for the attributes? |
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/ComponentModel/DefaultValueAttribute.cs
Show resolved
Hide resolved
There are docs in the class XML: Lines 8 to 19 in bd6cbe3
and also these docs: |
Looks like you need to update to @MichalStrehovsky's latest change #37297
|
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have one question on the placement of the DynamicallyAccessedMembersAttribute
on ComObjectType
for @MichalStrehovsky (or @vitek-karas). Pending the answer of that question, this looks good to me.
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
Outdated
Show resolved
Hide resolved
The ComObjectType property annotation needs to be fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @layomia.
@@ -2319,7 +2319,7 @@ public static void Refresh(Assembly assembly) | |||
[EditorBrowsable(EditorBrowsableState.Advanced)] | |||
public static Type ComObjectType | |||
{ | |||
[DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] | |||
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) - this may be a preference thing, but IMO it feels more natural for this attribute to be applied to the property:
[EditorBrowsable(EditorBrowsableState.Advanced)]
[DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public static Type ComObjectType
{
get => typeof(TypeDescriptorComObject);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually not sure linker will be able to handle this - the attribute on a property works for implicit getters/setters, but for those with explicit bodies it might not be reliable (since we need to detect the backing field if there's one to annotate it as well, and that detection is tricky/impossible for random properties).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that if it doesn't work linker will not warn - TODO - I created dotnet/linker#1248 to get that fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually not sure linker will be able to handle this - the attribute on a property works for implicit getters/setters, but for those with explicit bodies it might not be reliable (since we need to detect the backing field if there's one to annotate it as well, and that detection is tricky/impossible for random properties).
The behavior is that if the annotation is placed on the property, the annotation is propagated to the return value of the getter and the parameter of the setter. If this is an auto property, the annotation is also propagated to the backing field. Otherwise, this won't propagate to the backing field, even if it looks "obvious". One will get a warning and needs to annotate the backing field manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this case where there is no backing field? Does the TypeDescriptorComObject
type get annotated with [DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
if the attribute is applied to the property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this case where there is no backing field?
This part applies always: "The behavior is that if the annotation is placed on the property, the annotation is propagated to the return value of the getter and the parameter of the setter"
Does the TypeDescriptorComObject type get annotated with
Yes, because it's a value that was returned from a method that has the return parameter annotated (because the annotation was propagated from the property).
Contributes to #35199.