I wanted to make templates with private variable a bit easier to make so included a macro to do that, then made two extra ones for other common stuff that I need.
ReSharper Gallery Link: https://resharper-plugins.jetbrains.com/packages/Vukomanovic.Resharper.Macros
- Value of another variable with prefix
_added and first character made lower case; - Value of another variable transformed with a prefix added a suffix added; and
- Value of another variable with a prefix removed a suffix removed and remaining text transformed.
- Value of another variable with multiple functions applied.
lfor the first character being made lowercase;ufor the first character being made uppercase;Lfor all the characters being made lowercase (in the original variable, not the prefix or suffix);Ufor all the characters being made uppercase (in the original variable, not the prefix or suffix); and- Anything else for no transform.
This macro allows chaining different functions together for more flexibilty
The second parameter needs to be separated by ;'s and the functions should be followed by :'s
The functions are:
ap- Add prefixas- Add suffixrp- Remove prefixrs- Remove suffixt- Perform case transform (see above for transforms)d- Replace an empty string with the defined defaulttxorxwherexis any of the transforms by themselves with or without a:
Example: if you had _lockSuf as your variable input you could run with the function parameter as rp:_;rs:Suf;u;d:Lock;ap:got;as:YAY which would give you the output gotLockYAY
Note that any function which you define which wouldn't do anything is skipped so that it is quicker.
Example: if you again had _lockSuf as your variable input and had ap:;as:;rp;rs:;t;d: as the function parameter. Then the macro compiles this down to just returning the original value.
I have include a file instanceExample.DotSettings which creates a thread safe Instance property in a class and also a Lock object for that Instance. The good thing about having the entire variable encapsulated in the resharper variable is that if you change it, it can have a nice flow on effect through the rest of the tempalte as well.