Skip to content

[API Proposal]: adding C# option to the [StringSyntaxAttribute] #122604

@HakamFostok

Description

@HakamFostok

Background and motivation

It would be very helpful for the source generator scenario if we had a StringSyntax for C#:

  1. syntax error checking
  2. code completion inside strings

API Proposal

namespace System.Diagnostics.CodeAnalysis;

public sealed class StringSyntaxAttribute : Attribute
{
    public const string CSharp = "C#";
}

API Usage

using System.Diagnostics.CodeAnalysis;

public class Class 
{
	[StringSyntax(StringSyntaxAttribute.CSharp)]
   	public string? CodeForSourceGenerator = " ... c# code here";
}

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions