Skip to content

Conversation

@jkotas
Copy link
Member

@jkotas jkotas commented Jul 17, 2021

CustomAttributeData is meant to be abstract base class of reflection object model. Move the runtime-specific part
into a separate RuntimeCustomAttributeData type.

This avoids bugs like #55726 by construction.

CustomAttributeData is meant to be abstract base class of reflection object model. Move the runtime-specific part
into a separate RuntimeCustomAttributeData type.
@jkotas jkotas force-pushed the customattributedata branch from 231025c to c1bb326 Compare July 17, 2021 14:43
bool first = true;

int count = ConstructorArguments.Count;
IList<CustomAttributeTypedArgument> constructorArguments = ConstructorArguments;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache in locals to avoid redundant interface calls.

public virtual Type AttributeType => Constructor.DeclaringType!;

// Expected to be overriden
public virtual ConstructorInfo Constructor => null!;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the existing Mono behavior. The existing CoreCLR behavior is to throw NullReferenceException in some of these.

@jkotas jkotas force-pushed the customattributedata branch from 74a6760 to 00aa646 Compare July 17, 2021 15:31
@jkotas jkotas merged commit 8c48f94 into dotnet:main Jul 17, 2021
@jkotas jkotas deleted the customattributedata branch July 17, 2021 22:32
@ghost ghost locked as resolved and limited conversation to collaborators Aug 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

3 participants