views:

10

answers:

1

Hi,

Is it possible to use reflection when we write a code-template?

I was just thinking if it is possible to write a piece of code-template that will return me a list of all private field in the class separated by && operator in Visual Stuudio?

Let's say, I will enter "getAllPrivates&&" (or press a shortcut key) in the VS editor and it will return me something like this:

private bool _privateFiel1 = false;
private bool _privateFiel2 = true;
private bool _privateFiel3 = false;
private bool _privateFiel4 = false;
private bool _privateFiel5 = true;

// Here I press the shortcut or call the code-template and get his:

_privateFiel1 && _privateFiel2  && _privateFiel3 && _privateFiel4 && _privateFiel5
A: 

Its not easy. The people at DevExpress I think basically implemented a compilation process to determine this. I hear the same about resharper. If you can look at using DXCore to do the heavy lifting for you. And Since you can get a free copy of CodeRush Xpress I think this will be all you need.

Preet Sangha