Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Using NRefactory to move types

$
0
0

I have a need to go through all the types in a set of files and 'sort' them using various criteria (eg looking at certain attributes applied to the types) and then based on these criteria, move the types into the appropriate .NET namespace. eg:

namespace InputFileA

{

Type A

Type B

Type C

}

namepsace InputFileB

{

Type D

Type E

}

 

May be turned into:

 

namespace OutputA

{

Type D

Type E

}

 

namespace OutputB

{

Type A

Type C

}

 

namespace OutputC

{

Type B

}

Each output namespace should be in its own file, although this is not necessary.  Each output namespace may or may not exist at the point of moving a type into it.  Appropriate using statements, etc should be generated.  Most of the refactoring examples i have seen with NRefactory deal with replacing or modifying content in the same file, therefore i dont think the DocumentScript class will be useful here as i want to create new files.  I am currently looking at modifying the AST and calling GetText() on that.

If possible, i would love a working example as whilst i understand the high-level concepts here i have as yet been unable to get a working sample.

Thanks for your help


Viewing all articles
Browse latest Browse all 1764

Trending Articles