PostgreSQL in a String for Visual Studio 2019This is a separate PostgreSQL in a String extension that targets only Visual Studio 2019. Extension for Visual Studio 2022 can be found on the here. PostgreSQL in a String is a Visual Studio extension that adds highlighting for PostgreSQL syntax in C# string literals. Applies only to C# Supports parametrized queries. Parameter placeholders prefixed with an Supports all string literal types!
Correctly handles string escape sequences. PostgreSQL in a String uses an ANTLR 4 lexer to tokenize PostgreSQL syntax. How to enable and disable highlightingThe extension does not automatically detect string literals with PostgreSQL syntax. The syntax highlighting must be explicitly enabled for a single string literal, a code region or whole project.
Inline rule configurationHighlighting can be enabled inline by prefixing a string literal with a comment containing
When the string literal is inside an enabled region, its highlighting can be disabled inline by prefixing it with a comment containing
Region rule configurationEnable or disable highlighting in code regions with rule configuration comments. A region configuration will override highlighting of every string literal after it, except for those prefixed with inline rule configuration, until the next region configuration or end of file. Short version:
Longer version:
The rule parts can be mixed, e.g. Project configurationTo have the highlighting enabled by default for an entire project, add the following section in the
This may be useful when you have a separate data access project where most of the strings are database queries. Adding/changing nodes in ExplanationsRule configuration comments can contain explanations similar to what ESLint rule configuration comments allow. To add an explanation to the configuration, add two dashes after the rule name (separated by some whitespace) and place your explanation after the dashes.
Highlighting configurationThe default highlight colors were selected for VS dark theme but they can be customized in The default colors except for parameter placeholder color are a mix of 50% default string color and 50% default SQL token color. This means that the highlighted text will have an orange tint, which is by design, to not overwhelm when combined with other C# syntax as it is still just a string literal. Possible further improvements
|