Skip to content

Stack overflow with self-annotating attribute on a property #2196

@vitek-karas

Description

@vitek-karas
class AttributeRequiresAllProperties : Attribute
{
    public AttributeRequiresAllProperties (
         [DynamicallyAccessedMembersAttribute (DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)] Type type)
    {
    }
}

class TestPropertyWithAttributeMarkingSelfType
{
    [AttributeRequiresAllProperties (typeof (TestPropertyWithAttributeMarkingSelfType))]
    public static bool TestProperty { get; set; }
}

This causes endless recursion in the linker. The problem is that MarkProperty calls MarkCustomAttributes without a check if the property was already processed or not (unlike for example MarkType which first calls CheckProcessed).

The same problem probably exists for events. It doesn't seem to be a problem for types, fields and methods (as those do call CheckProcessed). It might be a problem for interfaces though (MarkInterfaceImplementation calls MarkCustomAttributes without a guard in place I think).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions