-
Notifications
You must be signed in to change notification settings - Fork 834
Open
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checking
Milestone
Description
I noticed the following regression when trying to build an old F# project using the .NET 9 sdk. The following code
open System.Runtime.Serialization
type CartEvent =
| [<DataMember(Name = "cartCreated")>] CartCreatednow fails to compile with the error
error FS0842: This attribute is not valid for use on this language element
Technically, this error is correct because DataMemberAttribute specifies AttributeTarget.Field ||| AttributeTarget.Property however this is breaking a common pattern used when serializing events modelled as discriminated unions.
So I have the following questions:
- Was this change made intentionally rectifying lack of attribute target validation by the compiler?
- What attribute
AttributeTargetshould library authors be specifying for attributes intended for application to union cases?
cc @bartelink
bartelinkbartelink and embix
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checking
Type
Projects
Status
New