1

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?

Anthony Compton
  • 5,271
  • 3
  • 29
  • 38
  • I've been trying to figure out creating new class also. I found this on github. Maybe it'll help: https://github.com/kropp/ReSharper-TestToolsPlugin/blob/master/TestToolsPlugin/Actions/CreateTestsAction.cs – Reactgular Jun 21 '14 at 15:21

1 Answers1

1

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.

Dmitri Nesteruk
  • 23,067
  • 22
  • 97
  • 166