Skip to content

AttributeUsage doesn't distinguish AttributeTargets.Class and AttributeTargets.Struct #13526

@auduchinok

Description

@auduchinok
open System

[<AttributeUsage(AttributeTargets.Class)>]
type CustomClassAttribute() =
    inherit Attribute()

[<AttributeUsage(AttributeTargets.Struct)>]
type CustomStructAttribute() =
    inherit Attribute()

[<AttributeUsage(AttributeTargets.Method)>]
type CustomMethodAttribute() =
    inherit Attribute()

[<CustomClass; CustomStruct; CustomMethod>]
type Class() = class end

[<CustomClass; CustomStruct; CustomMethod>]
type Struct(x: int) = struct end

Struct and class attributes seem to be allowed to be used interchangeably:

Screenshot 2022-07-19 at 18 10 26

Metadata

Metadata

Assignees

Labels

Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.good first issuehelp wanted

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions