Background and motivation
It would be very helpful for the source generator scenario if we had a StringSyntax for C#:
- syntax error checking
- 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