Skip to content

Attribute defined on second method of property is ignored #11529

@BoundedChenn31

Description

@BoundedChenn31

F# allows to declare get and set parts of property separately and in any order, like so

member _.A with get () = internalValue
member _.A with set (value) = internalValue <- value

However, attributes that are defined on second part (get or set, doesn't matter) are ignored.

Repro steps

  1. Create project with the following code or use sharplab:
type Foo() =
  let mutable internalValue = 1
  member _.A with get () = internalValue
  [<System.Obsolete>] member _.A with set (v: int) = internalValue <- v
  1. Compile and observe IL

Expected behavior

Property A is marked as obsolete or compiler warning if current behavior is intentional.

Actual behavior

Property A is not obsolete. Attribute is missing from IL.

Known workarounds
Combined syntax member _.Prop with get () = 1 and set (v: int) = () or attribute on first method of property.

Related information
dotnet version: 5.0.202

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions