[API Proposal] Add StringSyntaxAttributes to SqlJson #3107
Labels
💡 Enhancement
Issues that are feature requests for the drivers we maintain.
✔️ Triage Done
Issues that are triaged by dev team and are in investigation.
Is your feature request related to a problem? Please describe.
.NET 7.0 introduced the StringSyntaxAttribute type, which allows fields, parameters and properties of type
string
to be marked as containing a specific kind of data. When a member has this attribute applied, data validation rules can be run by Roslyn and Visual Studio to perform static code analysis.This hasn't yet been threaded through to the new SqlJson type.
Describe the solution you'd like
I'm proposing the API surface change below:
After this change, a developer who instantiates a SqlJson instance with a hardcoded string will encounter a new warning in Visual Studio and Rider if that string isn't valid JSON: JSON001. These strings will also have their syntax highlighted.
The StringSyntaxAttribute class isn't available in .NET Framework, but the functionality will still work if an internal type with the same name and definition is part of the assembly. NUnit and part of the dotnet arcade repo do this.
Describe alternatives you've considered
This could be made .NET-only if we'd prefer not to duplicate the type definition.
Additional context
I skimmed the ref projects for SqlClient and didn't see any other places where we can add these attributes.
The text was updated successfully, but these errors were encountered: