Skip to content

Array.Initialize should be marked with RequiresUnreferenceCode #77426

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

    area-Tools-ILLink.NET linker development as well as trimming analyzerslinkable-frameworkIssues associated with delivering a linker friendly framework

    Type

    No type

    Projects

    Status
    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions