Resharper Build configurations

17 visualizzazioni
Passa al primo messaggio da leggere

Demetrios Seferlis

da leggere,
23 ago 2016, 09:29:1723/08/16
a resharper-plugins
Hello everyone.

I'm trying to make a reshaprer plugin to add one (or more) configurations, besides executable, static method, project, at resharper's build window.
Any guidelines how to archive this? Or how to access build's context and configure? Or what are the assemblies responsible for this so i can examine?

Thank in advance!

Matt Ellis

da leggere,
24 ago 2016, 05:04:0324/08/16
a resharper-plugins
Hi Demetrios. You can extend the available run configuration types by implementing IRunConfig and IRunConfigProvider.

The IRunConfigProvider class needs to be marked as [ShellComponent], and can derive from the RunConfigProviderBase abstract base class. You get to specify a name, e.g. "Executable", a type identifier, e.g. "exe" and an icon ID. There's also the CreateNew method, which will create a new instance of your IRunConfig class, which will be mostly unconfigured, at this point.

The IRunConfig interface doesn't need to marked as a component, and should also derive from RunConfigBase - take a look at RunConfigExe in dotPeek to see an example of how to implement. You should override Execute in order to actually run whatever it is you need to run. You can use the RunConfigContext class passed in to actually execute a process from a ProcessStartInfo, or an IProject - this will execute it either by running the process, debugging it, or something else, such as code coverage or profiling.

For an .exe, this is as simple as:

public override void Execute(RunConfigContext context)

{

  context.ExecutionProvider.Execute(GetStartInfo(context), context, this);

}


But for a more complicated example, look at RunConfigMethod.Execute, which uses its own standalone launcher executable, and passes in command line parameters to load the correct assembly and execute the given static method.

Settings are implemented with ReadSpecific/SaveSpecific, and you can provide an editor view model with CreateEditor. You'll need a settings class, something like:

[SettingsKey(typeof (ConfigSettings), ".exe config")]

public class ExeSettings

{

  [SettingsEntry(null, "Path to .exe")] public string Executable;

  [SettingsEntry(null, "Working directory")] public string WorkingDirectory;

  [SettingsEntry(null, "Command line arguments")] public string Arguments;

}


The view for the editor is provided by a WPF control that is displayed in a dialog that ReSharper controls. The view needs to be decorated with the [View] attribute and must implement IView<T> where T is the concrete class returned from CreateEditor. This is how ReSharper will locate the view for the view model returned by CreateEditor. Again, take a look at RunConfigMethodView in dotPeek for some more idea of what's going on (and if you look in the resources, you'll be able to see the XAML itself).

Hope this helps.

Regards
Matt
Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi