Visual Studio code snippet: how to add logic to it?

I created a small piece of code to create a property for WPF data strings:

private string property; public string Property { get { return this.property; } set { this.property = value; this.OnPropertyChanged(() => Property); } } 

It is very difficult to create a field name in Case Camel and rewrite the property in Pascal Case. Is there a way to just write a field and let the fragment write the property using the name of the field with the first character in uppercase?

+6
source share
1 answer

Unfortunately, this type of logic is not available in the functionality of Visual Studio. Naming both names is the best you can do.

Here are just the "functions" available to you when creating a piece of code. MSDN Code Snippet Functions

Products such as Resharper provide superior code functionality (called "Resharper Templates") with the ability to change the wrapper of other notes within a snippet, among many other useful features. Resharper Template Information

For example, you will be interested in this macro:

"The value of another variable with the first character in lowercase

+8
source

Source: https://habr.com/ru/post/921415/


All Articles