Skip to content

AllowMultiple=false prevents adding attribute to both property and getter/setter #11304

Closed

Description

@chkn

C# allows adding an attribute with AllowMultiple=false to both a property and its getter and/or setter. F# allows adding the attribute to either the property or its getter/setter, but not both.

Repro steps

open System

[<AttributeUsage(AttributeTargets.Property ||| AttributeTargets.Method, AllowMultiple=false)>]
type FooAttribute() = inherit Attribute()

type C() =
    [<Foo>]
    member _.Foo
        with [<Foo>] get () = "bar"

Expected behavior

Should compile.

Actual behavior

error FS0429: The attribute type 'FooAttribute' has 'AllowMultiple=false'. Multiple instances of this attribute cannot be attached to a single language element.

Known workarounds

Unknown.

Related information

Provide any related information (optional):

  • Operating system: Mac OS X 10.15.7
  • .NET Runtime kind: .NET Core
  • Editing Tools (e.g. Visual Studio Version, Visual Studio): N/A

Activity

  1. added
    Impact-Low
    on Mar 26, 2021
  2. added this to the Backlog milestone on Mar 26, 2021
  3. added a commit that references this issue on Apr 3, 2021
    4efa522
  4. modified the milestones: Backlog, 16.10 on Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-Low

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions