Skip to content

F# compiler doesn't respect different attribute targets when checking for Multiple appliance #17904

Open
@En3Tho

Description

@En3Tho

Initially found following semantic kernel tutorial here: https://learn.microsoft.com/en-us/semantic-kernel/get-started/quick-start-guide?pivots=programming-language-csharp

It seems that C# allows multiple attribute usage on a different targets e.g. return: in this case:

[AttributeUsage(AttributeTargets.All)]
public class Attr(string m) : Attribute;

public class Test()
{
    [Attr("Foo")]
    [return: Attr("Foo")]
    public void Foo() {}
}

C# compiles ok while in this case:

[<AttributeUsage(AttributeTargets.All)>]
type Attr(m: string) =
    inherit Attribute()

type Test() =
    [<Attr("foo")>]
    [<return: Attr("foo")>]
    member _.Foo() = ()

F# compiler is compaining that AttributeUsage is false. So my guess is that F# does not respect a different attribute target and simply checks if there are multiple attributes defined or not

I guess it is related to this: #11304 in some way

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions