Add a more functional (i.e. fewer-stubs) implementation of System.Data.Linq.
[mono.git] / mcs / nunit24 / NUnitFixtures / fixtures / TestCompiler.cs
1 // ****************************************************************\r
2 // Copyright 2007, Charlie Poole\r
3 // This is free software licensed under the NUnit license. You may\r
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4\r
5 // ****************************************************************\r
6 \r
7 using System;\r
8 using System.CodeDom.Compiler;\r
9 \r
10 namespace NUnit.Fixtures\r
11 {\r
12         /// <summary>\r
13         /// Summary description for CSharpCompiler.\r
14         /// </summary>\r
15         public class TestCompiler\r
16         {\r
17                 ICodeCompiler compiler;\r
18                 CompilerParameters options;\r
19 \r
20                 public TestCompiler() : this( null, null ) { }\r
21 \r
22                 public TestCompiler( string[] assemblyNames ) : this( assemblyNames, null ) { }\r
23 \r
24                 public TestCompiler( string[] assemblyNames, string outputName )\r
25                 {\r
26                         Microsoft.CSharp.CSharpCodeProvider provider = new Microsoft.CSharp.CSharpCodeProvider();\r
27                         this.compiler = provider.CreateCompiler();\r
28                         this.options = new CompilerParameters();\r
29 \r
30                         if ( assemblyNames != null && assemblyNames.Length > 0 )\r
31                                 options.ReferencedAssemblies.AddRange( assemblyNames );\r
32                         if ( outputName != null )\r
33                                 options.OutputAssembly = outputName;\r
34 \r
35                         options.IncludeDebugInformation = false;\r
36                         options.TempFiles = new TempFileCollection( ".", false );\r
37                         options.GenerateInMemory = false;\r
38                 }\r
39 \r
40                 public CompilerParameters Options\r
41                 {\r
42                         get { return options; }\r
43                 }\r
44 \r
45                 public CompilerResults CompileCode( string code )\r
46                 {\r
47                         return compiler.CompileAssemblyFromSource( options, code );\r
48                 }\r
49         }\r
50 }\r