When creating a Resharper template, can you get a macro parameter to select from a list of enum values?

StackOverflow https://stackoverflow.com/questions/23550330

  •  18-07-2023
  •  | 
  •  

Вопрос

I am creating a ReSharper template and need to add a macro that sets a value which can only be selected from an enum. Is it possible to do this in ReSharper? I have a command named $AUTHOR$ and I need it to resolve to EnumAuthors.?? Where ?? is where I pick teh enum value I want.

Thanks!

Это было полезно?

Решение

You can use the "Execute smart completion" or "Execute basic completion" macros to provide code completion for the values of an enum. For example:

public void Foo()
{
  var author = EnumAuthors.$VALUE$;
}

when you come to expand $VALUE$, code completion will display just the values of EnumAuthors.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top