Open
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")>] CartCreated
now 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
AttributeTarget
should library authors be specifying for attributes intended for application to union cases?
cc @bartelink
Metadata
Metadata
Assignees
Type
Projects
Status
New