SqlString icon indicating copy to clipboard operation
SqlString copied to clipboard

Adds syntax highlighting to SQL in C# strings

SQL Embedded Language Prototype

Screenshot

This is a prototype for adding syntax highlighting to SQL inside of C# strings. It leverages internal extensibility points of Roslyn by forking parts of Roslyn and parts of ASP.NET Core--their route pattern syntax highlighting. It uses the SQL ScriptDOM library for parsing SQL. The code is inside SqlClassifier.cs.

Testing

To test the highlighting in Visual Studio, build the solution then run install.cmd as an administrator. Then create an ASP.NET Core project targeting .NET 8.0. After that, it should work on APIs annotated with [StringSyntax("Sql")].

Warning: Brittle

This code is very brittle and was created for a hackathon. It is hard-coded to VS 17.8 Preview 2 and .NET 8.0 RC 1.