Skip to content

AttributeUsage AllowMultiple and AttributeTargets is not inherited #9256

Closed

Description

@NinoFloris

AttributeUsage AllowMultiple is not inherited
HttpGet is failing, HttpMethod works (this mirrors the attributes from aspnet mvc)

open System

[<AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)>]
type HttpMethodAttribute() = inherit Attribute()
type HttpGetAttribute() = inherit HttpMethodAttribute()

[<HttpGet; HttpGet>] // this shouldn't error like 
[<HttpMethod; HttpMethod>] // this doesn't
type C() =
    member _.M() = ()

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AbEAzAzgHwgAcYA7AAgGUBPXAFxgFsBYAKDYG0AeAQTrqgBLYAFcGAVVwBDAOYwAFHwHCxMACpSocurgB0AYQxTcuNOR4YMEAO4BZERjqCiGGOQC85ASJhmAkqQAFjBCDAAmHl5QPgCUAHwAumx01CTkABL8RLYwdIEQYUpCogzyMZGCQSGCdOb8xaplyalumXREAOK5RSql5Z6VwaEZWTl5BT0lCjFsnFxtnbkA3CPtXXSJcwtj+WEr27m7m6wpafplHmzk1+SMTMAh5AD6urYXnmVAA=

Activity

  1. added this to the Backlog milestone on Sep 1, 2020
  2. dsyme commented on Sep 3, 2020

    @dsyme
    Contributor

    Agreed we should be looking at the inherited AttributeUsage

  3. added
    Impact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.
    on Sep 3, 2020
  4. changed the title [-]AttributeUsage AllowMultiple is not inherited[/-] [+]AttributeUsage AllowMultiple and AttributeTargets is not inherited[/+] on Sep 3, 2020
  5. ErikSchierboom commented on Dec 30, 2020

    @ErikSchierboom
    Contributor

    I've been looking into fixing this issue, but I have some issues understanding exactly how to do this. I know that the AllowMultiple check is being done in the CheckAttribs function (source). That function then calls the TryFindAttributeUsageAttribute function which is defined here, which itself depends on TryBindTyconRefAttribute (source). It does indeed look like the code never checks if the attribute itself has inherited attributes. My main question is: how can I best approach this? I've tried to get to an attribute's parent type, but so far have failed in my attempts.

  6. baronfel commented on Jan 4, 2021

    @baronfel
    Member

    @ErikSchierboom take a look at PR 10834, I made a helper function that walks the inheritance hierarchy for a type that seems to do the job.

  7. ErikSchierboom commented on Jan 4, 2021

    @ErikSchierboom
    Contributor

    @baronfel Ah interesting! Thanks for the heads-up.

  8. modified the milestones: Backlog, 16.10 on Feb 6, 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(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions