Reputation: 37050
I have legacy systems that I want to migrate to a new data model. It boils down to many type name changing. In order to not break existing code, I plan to use compiler switches:
#if NEW
var variable = new MyNewType();
#else
MyOldType variable = new MyOldType();
#endif
I created a Resharper replace pattern:
#if NEW
var $variable$ = new $type$();
#else
$type$ $variable$ = new $type$();
#endif
type
is defined as a type placeholder and variable
is an identifier placeholder. However, I get a syntax error while parsing that expression:
unexpected placeholder "variable"
Is introducing compiler switches with Resharper not possible, or where did I go wrong?
Upvotes: 0
Views: 38
Reputation: 16
As far as I know, R# doesn't support this case. I believe it's because R# relies on the Abstract Syntax Tree (AST) of the current code. And in your case AST depends on which statements would actually be compiled based on whether NEW
is defined or not.
Upvotes: 0