Reputation: 5361
I'm attempting to make a Resharper plugin to help do some specialized refactoring on a project I've got.
The gist of it is that I have a static function in a class and I want to create a new class and move the static function into it.
I thought it was going to be much more straightforward but I'm having difficulty finding examples or starting points in the SDK documentation.
Specifically, I can't figure out how to create a new file contains a new class. While I can't say for certain, I feel like I've run across a couple of examples of creating a new class (though I ignored them at the time because I was hung up on this new file thing).
Does anyone know the magic words to make the ReSharper SDK create this new file?
Upvotes: 1
Views: 142
Reputation: 23789
Creating a new file can be as simple as CSharpElementFactory.CreateFile
but you might also want to consider using a refactoring instead. What you can do is create your new class, put the method in there, add it to the current file and then execute MoveIntoMatchingFilesRefactoring
.
Upvotes: 1