Skip to content

Array.Initialize should be marked with RequiresUnreferenceCode #77426

@jkotas

Description

@jkotas

Array.Initialize calls value type default constructor via reflection. There is nothing preventing the value type default constructor from getting trimmed. See discussion in #77336 (comment)

However, adding RequiresUnreferencedCode on Array.Initialize has a ripple effect. It introduces warnings in situations where array type is passed into DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All). We have some instances of this problem in our own libraries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions