Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting Literal parameters of a C# code snippet

Is there any way that I can change how a Literal of a code snippet renders when it is used in the code that the snippet generates?

Specifically I'd like to know if I can have a literal called say, $PropertyName$ and then get the snippet engine to render "_$PropertyName$ where the first character is made lowercase.

I can't afford R#. Please help :)

like image 558
Michael Lang Avatar asked Oct 02 '08 21:10

Michael Lang


People also ask

What is a format string in C?

The Format specifier is a string used in the formatted input and output functions. The format string determines the format of the input and output. The format string always starts with a '%' character. The commonly used format specifiers in printf() function are: Format specifier.

What is a formatted string literal?

Formatted String Literals. Formatted string literals (also called f-strings for short) let you include the value of Python expressions inside a string by prefixing the string with f or F and writing expressions as {expression} .

What is return by format () method?

format() method returns the formatted string by a given locale, format, and argument. If the locale is not specified in the String. format() method, it uses the default locale by calling the Locale.

What is $@ in C#?

It marks the string as a verbatim string literal. In C#, a verbatim string is created using a special symbol @. @ is known as a verbatim identifier. If a string contains @ as a prefix followed by double quotes, then compiler identifies that string as a verbatim string and compile that string.


1 Answers

Unfortunately there seems to be no way. Snippets offer amazingly limited support for transformation functions as you can see.

You have to stick with the VS standard solution, which is to write two literals: one for the property name, and the other for the member variable name.

like image 135
Caerbanog Avatar answered Oct 05 '22 01:10

Caerbanog