Repository navigation
AttributeUsage doesn't distinguish AttributeTargets.Class and AttributeTargets.Struct #13526
Copy link
Copy link
Closed
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.good first issuehelp wanted
Milestone
Description
Activity
- addedArea-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checking
on Sep 9, 2022 @auduchinok Could you check the title of this bug please? It says
.Constructorbut doesn't mention that in the description?Seems there are three problems:
- CustomStruct can be targeted at class incorrectly
- CustomClass can be targeted at struct incorrectly
- CustomMethod can be targeted at a constructor incorrectly
This seem ok:
- CustomConstructor can't be targeted at a method
Example this works but shouldn't:
open System [<AttributeUsage(AttributeTargets.Method)>] type CustomMethodAttribute() = inherit Attribute() type Class [<CustomMethod>] () = class end type Struct [<CustomMethod>] (x: int) = struct end``` and this works (as expected: ```fsharp [<AttributeUsage(AttributeTargets.Constructor)>] type CustomConstructorAttribute() = inherit Attribute() type Class [<CustomConstructor>] () = class end type Struct [<CustomConstructor>] (x: int) = struct end
- addedImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
on Sep 21, 2022 @dsyme Yes, I think it was about structs.
- changed the title
[-]`AttributeUsage` doesn't distinguish `AttributeTargets.Class` and `AttributeTargets.Constructor`[/-][+]`AttributeUsage` doesn't distinguish `AttributeTargets.Class` and `AttributeTargets.Struct`[/+]on Sep 22, 2022
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.good first issuehelp wanted
Type
Projects
- StatusShow more project fieldsDone
Struct and class attributes seem to be allowed to be used interchangeably: