Escaping Commas in ReSharper Live Templates Comma-Delimited Macros
ReSharper is an irreplaceable tool in my coding arsenal. One of its myriad of amazingly useful tools is Live Templates, a much enhanced version of Visual Studio’s code snippets. When defining a live template you can specify a number of placeholders in the template, and choose from a variety of “macros” to determine how ReSharper fills that field in. We use this to automate putting the current year number and filename in the copyright header in new files, and to have ReSharper suggest appropriate types or variables names.
In a new template that I was writing, I wanted to be able to choose from a list of SQL Server types. Looking through the list of available macros, I was pleased to see that there was an option for a comma-delimited list of options. I started creating this list, and then came across decimal(18,2) as a type, and realized quickly that it was coming as two options in the list (decimal(18 and 2)), so I started looking for a way to escape that comma. After finding nothing in Google with a couple of searches, I tried a few guesses. It only took two guesses to find that you can use a backslash to escape the comma, ending up with decimal(18\,2).
Thanks, JetBrains, for ReSharper and its ability to do what I need it to do without even trying.