Skip to content

Add string syntax attributes (.NET 7+) #4433

Closed

Description

@RenderMichael

I was recently using IgnoreAttribute.Until and noticed it wasn't getting syntax highlighting for a DateTime.

.NET 7 introduced StringSyntaxAttribute to allow IDEs to add syntax highlighting wherever developers request.

It would be nice to add these where relevant, guarded by ifdef's for .NET 7+

Activity

  1. OsirisTerje commented on Jul 25, 2023

    @OsirisTerje
    Member

    We don't have a target for .net 7 so not sure how that would work out. I assume the changes you propose will require a net 7 target. We're not likely to provide that since net 7 is not on LTS. We are currently working on having a net 6 target though for version 4, so if you can make it work for that, it could be doable.

  2. RenderMichael commented on Jul 25, 2023

    @RenderMichael
    ContributorAuthor

    @OsirisTerje Unfortunately this feature was introduced in .NET 7. .NET 8 is coming out in a few months, maybe this can be added now and it will lay dormant until then?

  3. OsirisTerje commented on Jul 25, 2023

    @OsirisTerje
    Member

    That's a good thought!

    However, we will follow new lifecycle policy for targeted frameworks that will follow the MIcrosoft framework lifecycles, but delayed around 6 months or so. And we will try to limit ourselves to supporting 2 target frameworks, this is about the size of the package - to avoid it being too large (that's only a choice of course).
    .Net 6 has end of support Nov 12 2024, so that will mean around May/June 2025.
    .Net framework 4.6.2 has end of support Jan 12 2027, so that will mean June/July 2028, and this will have to be updated through the other .net frameworks, 4.7 and 4.8 and so on.
    So if this should go in before mid 2025, we would have to consider adding another .net version to the package. @manfred-brands @stevenaw @jnm2 Comments?

  4. manfred-brands commented on Jul 26, 2023

    @manfred-brands
    Member

    Like with the CallerArgumentExpressionAttribute and previously the NotNullAttribute this isn't something the framework uses, but either the compiler or in this case it is the editor (Visual Studio, not sure about Code or Ryder) that uses the attribute.

    Nunit already uses the Nullable and IsExternalInit assemblies that supply attributes.
    I haven't seen one for the others, so we can add them conditionally ourselves.

    @RenderMichael Can you add the below to your PR (drop the .txt extension), build it and see if the editor picks it up.

    StringSyntaxAttribute.cs.txt

  5. RenderMichael commented on Jul 26, 2023

    @RenderMichael
    ContributorAuthor

    @manfred-brands That worked! I pushed the changes to the associated PR, but I wasn't sure where you prefer the string syntax attribute polyfill, or what copyright header the file should have.

  6. lahma commented on Jul 26, 2023

    @lahma
    Contributor

    Just throwing ideas from outside, but have you folks considered https://github.com/Sergio0694/PolySharp to get coherent polyfillls for missing features? There's also https://github.com/SimonCropp/Polyfill , they both aim to provide the features without creating a library dependency.

  7. manfred-brands commented on Jul 27, 2023

    @manfred-brands
    Member

    @lahma Thanks for that.
    We are already using Nullable and IsExternalInit to get Nullable attributes in.
    I did check to see if there was a matching one for the new arguments but didn't find it.

    Now you pointed them out, I will investigate them to replace the ones we currently use.

  8. added this to the 4.0 milestone on Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions