c# - Resharper source template adding empty statement -


to ease testing, put resharper source template to create substitute class nsubstitute.

[sourcetemplate] public static void substitute<t>(this t o,     [macro(expression = "guessexpectedtype()", editable = -1)] string type)     t : class {     //$ o = substitute.for<$type$>(); } 

assuming field, private ilogger logger; has been defined, lets me type logger.sub (resharper suggests full method name there) generate logger = substitute.for<ilogger>();.

i still have 2 issues haven't been able figure out.

1) puts empty statement before replaced code, i.e.

; logger = substitute.for<ilogger>(); 

this appears happen whenever there statements below replaced line. resharper suggest empty statement can removed. why being adding begin with, , how can prevent it?

2) correctly guesses substitute type if nsubstitute has been imported class (using nsubstitute;). without it, logger = substitute.for<object>(); , suggestion import nsubstitute. there better macro expression resolve field type? alternatively, there way import namespace if hasn't been imported already?

  1. this sounds bug - please can file issue
  2. try including namespace in commented code. resharper shorten references , automatically add namespace list of using statements @ top of file:

    //$ o = nsubstitute.substitute.for<$type$>();


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -