Yesterday in 3 hours I wrote a program that find assembly usages in my code. It is nice to have knowledge about classes I need to refactor to replace library to another. How this program works:
- Read all assembly types to check they are used in my code.
- Iterate all project .cs files.
- For every source file use CSharpSyntaxWalker to traverse to all nodes in AST
- For every node ask SemanitcModel to GetDecalredSymbol.
- Filter all informative symbols like a IPropertySymbol, IlocalSymbol to read type from it and resolve it from assembly I need to replace.
Thank you for Roslyn it works as expected and it is easy to extend to find indirect dependencies in code to know all places for refactor.
No comments:
Post a Comment