SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Andreas Weizel

NRefactory & NR6Pack Finally Roslyn-ized

In the last two months Mike Krüger has done some intensive refactoring of NRefactory 6 code and we also have restructured the project and the way how NRefactory and NR6Pack share their code:

Analyzers & Refactorings are now plain Roslyn

NRefactory 6 began as a thin wrapper API around some Roslyn base classes to emulate the API of NRefactory 5. The intention was to simplify porting of code actions and issues from the pre-Roslyn NRefactory 5. But since concepts of NR5 and Roslyn are not completely congruent, this led to some restrictions. An example: In Roslyn a code analyzer and a code fix may exist independently from each other. NR5 (and therefore NR6 wrapper) API didn't allow this separation. That way it wasn't possible to implement custom fixes for analyzers already shipped with Roslyn without reimplementing the analyzer.

The wrapper API has been removed, there are no NR6-specific base classes or attributes anymore. There is no difference to analyzers or refactorings implemented plainly with Roslyn. This is the reason why we have dropped the NRefactory.Templates project (and Visual Studio extension) published in January: The ".NET Compiler Platform SDK Templates" provided by Microsoft are now sufficient.

Changes in naming

In NRefactory and NR6Pack "Analyzers" and "Refactorings" were previously called "Issues" and "Actions", a relict from NR5. All classes were renamed to fit Roslyn terminology. All ...CodeFixProvider classes were moved to their own .cs files.

What's new and what's past?

Some new analyzers were ported, like ThreadStaticAtInstanceFieldAnalyzer, FieldCanBeMadeReadOnlyAnalyzer, PublicConstructorInAbstractClassAnalyzer and several more. On the other side some analyzers/refactorings were removed because they are similar to what Roslyn already provides. For some compiler errors Roslyn delivers only the analyzers, while NR6(Pack) also implements appropriate code fixes. Therefore only the CodeFixProviders were kept, while the analyzers have been dropped.

There are also some examples of refactorings which were combined into one, so their number might even have decreased without loosing features.

NRefactory "vs." NR6Pack

In previous releases NR6Pack project was more or less a reduced copy of NRefactory 6 project consisting of file links to analyzers and refactorings in ICSharpCode.NRefactory6.CSharp.Refactoring project. It was quite hard to keep both projects synchronized all the time. After recent restructuring all projects have clear responsibilities:

  • ICSharpCode.NRefactory6.Shared: Shared project containing utility classes used by NR6 and NR6Pack
  • NR6Pack: Now regularly contains all the analyzers and refactorings. No copies or links of these classes are needed anymore, the NR6Pack project will simply be used by MonoDevelop as well as by NR6Pack Visual Studio extension.
  • NR6Pack.Tests: This new project hosts all unit tests for analyzers and refactorings of NR6Pack.
  • ICSharpCode.NRefactory6.CSharp: Rest of NRefactory 6 remaining after excluding all utility APIs and analyzers/refactorings. This includes code completion and special refactoring features mainly needed by MonoDevelop.
  • ICSharpCode.NRefactory6.CSharp.Tests: Contains unit tests for features of ICSharpCode.NRefactory6.CSharp.

 

All this work should simplify maintenance and extending of NR/NR6Pack a lot. And there are still some unported analyzers and refactorings you could help us with!

 


UPDATE 2015-06-25:

We have finished the next evolutional step with NR6Pack and separated all refactorings and analyzers to a new project: "Refactoring Essentials" were born! Read the full post.

Comments

No Comments
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.