mscorlib(4.0.0.0) API with additions
CompilerParameters.cs
1 using Microsoft.Win32.SafeHandles;
7 
9 {
11  [Serializable]
12  [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
13  [PermissionSet(SecurityAction.InheritanceDemand, Name = "FullTrust")]
14  public class CompilerParameters
15  {
16  [OptionalField]
17  private string coreAssemblyFileName = string.Empty;
18 
19  private StringCollection assemblyNames = new StringCollection();
20 
21  [OptionalField]
22  private StringCollection embeddedResources = new StringCollection();
23 
24  [OptionalField]
25  private StringCollection linkedResources = new StringCollection();
26 
27  private string outputName;
28 
29  private string mainClass;
30 
31  private bool generateInMemory;
32 
33  private bool includeDebugInformation;
34 
35  private int warningLevel = -1;
36 
37  private string compilerOptions;
38 
39  private string win32Resource;
40 
41  private bool treatWarningsAsErrors;
42 
43  private bool generateExecutable;
44 
45  private TempFileCollection tempFiles;
46 
47  [NonSerialized]
48  private SafeUserTokenHandle userToken;
49 
50  private Evidence evidence;
51 
54  public string CoreAssemblyFileName
55  {
56  get
57  {
58  return coreAssemblyFileName;
59  }
60  set
61  {
62  coreAssemblyFileName = value;
63  }
64  }
65 
69  public bool GenerateExecutable
70  {
71  get
72  {
73  return generateExecutable;
74  }
75  set
76  {
77  generateExecutable = value;
78  }
79  }
80 
84  public bool GenerateInMemory
85  {
86  get
87  {
88  return generateInMemory;
89  }
90  set
91  {
92  generateInMemory = value;
93  }
94  }
95 
98  public StringCollection ReferencedAssemblies => assemblyNames;
99 
102  public string MainClass
103  {
104  get
105  {
106  return mainClass;
107  }
108  set
109  {
110  mainClass = value;
111  }
112  }
113 
116  public string OutputAssembly
117  {
118  get
119  {
120  return outputName;
121  }
122  set
123  {
124  outputName = value;
125  }
126  }
127 
131  {
132  get
133  {
134  if (tempFiles == null)
135  {
136  tempFiles = new TempFileCollection();
137  }
138  return tempFiles;
139  }
140  set
141  {
142  tempFiles = value;
143  }
144  }
145 
149  public bool IncludeDebugInformation
150  {
151  get
152  {
153  return includeDebugInformation;
154  }
155  set
156  {
157  includeDebugInformation = value;
158  }
159  }
160 
164  public bool TreatWarningsAsErrors
165  {
166  get
167  {
168  return treatWarningsAsErrors;
169  }
170  set
171  {
172  treatWarningsAsErrors = value;
173  }
174  }
175 
178  public int WarningLevel
179  {
180  get
181  {
182  return warningLevel;
183  }
184  set
185  {
186  warningLevel = value;
187  }
188  }
189 
192  public string CompilerOptions
193  {
194  get
195  {
196  return compilerOptions;
197  }
198  set
199  {
200  compilerOptions = value;
201  }
202  }
203 
206  public string Win32Resource
207  {
208  get
209  {
210  return win32Resource;
211  }
212  set
213  {
214  win32Resource = value;
215  }
216  }
217 
220  [ComVisible(false)]
222  {
223  get
224  {
225  return embeddedResources;
226  }
227  }
228 
231  [ComVisible(false)]
233  {
234  get
235  {
236  return linkedResources;
237  }
238  }
239 
242  public IntPtr UserToken
243  {
244  get
245  {
246  if (userToken != null)
247  {
248  return userToken.DangerousGetHandle();
249  }
250  return IntPtr.Zero;
251  }
252  set
253  {
254  if (userToken != null)
255  {
256  userToken.Close();
257  }
258  userToken = new SafeUserTokenHandle(value, ownsHandle: false);
259  }
260  }
261 
262  internal SafeUserTokenHandle SafeUserToken => userToken;
263 
266  [Obsolete("CAS policy is obsolete and will be removed in a future release of the .NET Framework. Please see http://go2.microsoft.com/fwlink/?LinkId=131738 for more information.")]
267  public Evidence Evidence
268  {
269  get
270  {
271  Evidence result = null;
272  if (evidence != null)
273  {
274  result = evidence.Clone();
275  }
276  return result;
277  }
279  set
280  {
281  if (value != null)
282  {
283  evidence = value.Clone();
284  }
285  else
286  {
287  evidence = null;
288  }
289  }
290  }
291 
294  : this(null, null)
295  {
296  }
297 
300  public CompilerParameters(string[] assemblyNames)
301  : this(assemblyNames, null, includeDebugInformation: false)
302  {
303  }
304 
308  public CompilerParameters(string[] assemblyNames, string outputName)
309  : this(assemblyNames, outputName, includeDebugInformation: false)
310  {
311  }
312 
318  public CompilerParameters(string[] assemblyNames, string outputName, bool includeDebugInformation)
319  {
320  if (assemblyNames != null)
321  {
322  ReferencedAssemblies.AddRange(assemblyNames);
323  }
324  this.outputName = outputName;
325  this.includeDebugInformation = includeDebugInformation;
326  }
327  }
328 }
Describes a set of security permissions applied to code. This class cannot be inherited.
TempFileCollection TempFiles
Gets or sets the collection that contains the temporary files.
Definition: __Canon.cs:3
bool IncludeDebugInformation
Gets or sets a value indicating whether to include debug information in the compiled executable.
StringCollection ReferencedAssemblies
Gets the assemblies referenced by the current project.
CompilerParameters()
Initializes a new instance of the T:System.CodeDom.Compiler.CompilerParameters class.
StringCollection EmbeddedResources
Gets the .NET Framework resource files to include when compiling the assembly output.
bool GenerateExecutable
Gets or sets a value indicating whether to generate an executable.
StringCollection LinkedResources
Gets the .NET Framework resource files that are referenced in the current source.
Evidence Clone()
Returns a duplicate copy of this evidence object.
Definition: Evidence.cs:1310
string Win32Resource
Gets or sets the file name of a Win32 resource file to link into the compiled assembly.
Represents the parameters used to invoke a compiler.
CompilerParameters(string[] assemblyNames)
Initializes a new instance of the T:System.CodeDom.Compiler.CompilerParameters class using the specif...
string CoreAssemblyFileName
Gets or sets the name of the core or standard assembly that contains basic types such as T:System....
Represents a collection of strings.
string CompilerOptions
Gets or sets optional command-line arguments to use when invoking the compiler.
SecurityAction
Specifies the security actions that can be performed using declarative security.
void AddRange(string[] value)
Copies the elements of a string array to the end of the T:System.Collections.Specialized....
string OutputAssembly
Gets or sets the name of the output assembly.
A platform-specific type that is used to represent a pointer or a handle.
Definition: IntPtr.cs:14
string MainClass
Gets or sets the name of the main class.
Ability to provide evidence, including the ability to alter the evidence provided by the common langu...
int WarningLevel
Gets or sets the warning level at which the compiler aborts compilation.
bool TreatWarningsAsErrors
Gets or sets a value indicating whether to treat warnings as errors.
bool GenerateInMemory
Gets or sets a value indicating whether to generate the output in memory.
Defines the set of information that constitutes input to security policy decisions....
Definition: Evidence.cs:17
CompilerParameters(string[] assemblyNames, string outputName)
Initializes a new instance of the T:System.CodeDom.Compiler.CompilerParameters class using the specif...
static readonly IntPtr Zero
A read-only field that represents a pointer or handle that has been initialized to zero.
Definition: IntPtr.cs:20
Specifies that the class can be serialized.
CompilerParameters(string[] assemblyNames, string outputName, bool includeDebugInformation)
Initializes a new instance of the T:System.CodeDom.Compiler.CompilerParameters class using the specif...
IntPtr UserToken
Gets or sets the user token to use when creating the compiler process.
Represents a collection of temporary files.