2 using System
.Diagnostics
;
3 using System
.Collections
.Generic
;
5 using System
.Reflection
;
7 using CA
= MonoDevelop
.CodeAnalysis
;
9 namespace MonoDevelop
.CodeAnalysis
.Smokey
{
11 public class SmokeyRunner
: IRunner
13 private static readonly Assembly smokey
;
15 static SmokeyRunner ()
17 string assemblyDirectory
= Path
.GetDirectoryName (Assembly
.GetExecutingAssembly ().Location
);
18 smokey
= Assembly
.LoadFile (Path
.Combine (assemblyDirectory
, "smokey.exe"));
25 public IEnumerable
<CA
.IViolation
> Run (string inspectedFile
, IEnumerable
<CA
.IRule
> ruleSet
)
27 // FIXME: add support for ruleSet parameter
28 // TODO: use MonoDevelop process APIs instead of System.Diagnostics
29 string arguments
= "-xml";
31 ProcessStartInfo startInfo
= new ProcessStartInfo ("mono");
32 // runtime needs to be defined explicitly (or somewhy 1.1 can be loaded)
33 startInfo
.Arguments
= string.Format ("--runtime=v2.0.50727 {0} {1} {2}",
34 smokey
.CodeBase
, arguments
, inspectedFile
);
35 startInfo
.RedirectStandardOutput
= true;
36 startInfo
.UseShellExecute
= false;
38 Process smokeyProcess
= null;
40 smokeyProcess
= Process
.Start (startInfo
);
41 return SmokeyParser
.ParseOutput (smokeyProcess
.StandardOutput
, ruleSet
);
42 } catch (Exception ex
) {
43 throw new InvalidOperationException (AddinCatalog
.GetString ("Could not run Smokey or parse its output."), ex
);
45 if (smokey
!= null) smokeyProcess
.Dispose ();
49 public static Assembly Smokey
{
50 get { return smokey; }
54 get { return "SmokeyRunner"; }
58 get { return "Smokey"; }