KEMBAR78
AttributeTargets.Class and AttributeTargets.Struct can be targeted in an enum incorrectly by edgarfgp · Pull Request #16887 · dotnet/fsharp · GitHub
Skip to content

Conversation

@edgarfgp
Copy link
Contributor

@edgarfgp edgarfgp commented Mar 18, 2024

Description

Fixes #16843

Before

[CompilationMapping(SourceConstructFlags.Module)]
public static class @_
{
    [Serializable]
    [AttributeUsage(AttributeTargets.Struct)]
    [CompilationMapping(SourceConstructFlags.ObjectType)]
    public class CustomStructAttribute : Attribute
    {
    }


    [Serializable]
    [AttributeUsage(AttributeTargets.Class)]
    [CompilationMapping(SourceConstructFlags.ObjectType)]
    public class CustomClassAttribute : Attribute
    {
    }


    [Serializable]
    [CustomStruct]
    [CustomClass]
    [CompilationMapping(SourceConstructFlags.ObjectType)]
    public enum Color
    {
        Red,
        Green,
        Blue
    }
}

After

Error 842 "This attribute is not valid for use on this language element" should be reported.

Checklist

  • Test cases added

  • Performance benchmarks added in case of performance changes

  • Release notes entry updated:

    Please make sure to add an entry with short succinct description of the change as well as link to this pull request to the respective release notes file, if applicable.

    Release notes files:

    • If anything under src/Compiler has been changed, please make sure to make an entry in docs/release-notes/.FSharp.Compiler.Service/<version>.md, where <version> is usually "highest" one, e.g. 42.8.200
    • If language feature was added (i.e. LanguageFeatures.fsi was changed), please add it to docs/releae-notes/.Language/preview.md
    • If a change to FSharp.Core was made, please make sure to edit docs/release-notes/.FSharp.Core/<version>.md where version is "highest" one, e.g. 8.0.200.

    Information about the release notes entries format can be found in the documentation.
    Example:

    If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

@edgarfgp edgarfgp requested a review from a team as a code owner March 18, 2024 12:04
@edgarfgp edgarfgp changed the title AttributeTargets.Class and AttributeTargets.Struct can be targeted in an enum AttributeTargets.Class and AttributeTargets.Struct can be targeted in an enum incorrectly Mar 18, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2024

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/FSharp.Core docs/release-notes/.FSharp.Core/8.0.300.md
src/Compiler docs/release-notes/.FSharp.Compiler.Service/8.0.300.md

@vzarytovskii
Copy link
Member

It seems that RQA needs addition of Enum target as well.

@edgarfgp
Copy link
Contributor Author

edgarfgp commented Mar 18, 2024

It seems that RQA needs addition of Enum target as well.

Yeah, wanted to check what the CI said about prim-types

@edgarfgp
Copy link
Contributor Author

This is ready

Copy link
Contributor

@psfinaki psfinaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

AttributeTargets.Class and AttributeTargets.Struct can be targeted in an enum incorrectly

4 participants