48 options.TempFiles.SafeDelete();
58 CompilerResults ICodeCompiler.CompileAssemblyFromFile(CompilerParameters options,
string fileName)
62 throw new ArgumentNullException(
"options");
70 options.TempFiles.SafeDelete();
80 CompilerResults ICodeCompiler.CompileAssemblyFromSource(CompilerParameters options,
string source)
84 throw new ArgumentNullException(
"options");
92 options.TempFiles.SafeDelete();
102 CompilerResults ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options,
string[] sources)
106 throw new ArgumentNullException(
"options");
114 options.TempFiles.SafeDelete();
122 CompilerResults ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options,
string[] fileNames)
126 throw new ArgumentNullException(
"options");
128 if (fileNames ==
null)
130 throw new ArgumentNullException(
"fileNames");
134 foreach (
string path
in fileNames)
144 options.TempFiles.SafeDelete();
152 CompilerResults ICodeCompiler.CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit[] ea)
156 throw new ArgumentNullException(
"options");
164 options.TempFiles.SafeDelete();
168 internal void Compile(CompilerParameters options,
string compilerDirectory,
string compilerExe,
string arguments, ref
string outputFile, ref
int nativeReturnValue,
string trueArgs)
170 string errorName =
null;
171 outputFile = options.TempFiles.AddExtension(
"out");
172 string text =
Path.
Combine(compilerDirectory, compilerExe);
175 string trueCmdLine =
null;
176 if (trueArgs !=
null)
178 trueCmdLine =
"\"" + text +
"\" " + trueArgs;
180 nativeReturnValue = Executor.ExecWaitWithCapture(options.SafeUserToken,
"\"" + text +
"\" " + arguments, Environment.CurrentDirectory, options.TempFiles, ref outputFile, ref errorName, trueCmdLine);
183 throw new InvalidOperationException(SR.GetString(
"CompilerNotFound", text));
218 if (fileName ==
null)
269 string[] array =
new string[ea.Length];
276 for (
int i = 0; i < ea.Length; i++)
280 ResolveReferencedAssemblies(options, ea[i]);
281 array[i] = options.TempFiles.AddExtension(i +
FileExtension);
288 streamWriter.
Flush();
301 Executor.ReImpersonate(impersonation);
319 string current = enumerator.
Current;
320 if (!options.ReferencedAssemblies.Contains(current))
322 options.ReferencedAssemblies.Add(current);
328 (enumerator as IDisposable)?.Dispose();
346 if (fileNames ==
null)
351 string outputFile =
null;
352 int nativeReturnValue = 0;
355 securityPermission.
Assert();
358 compilerResults.
Evidence = options.Evidence;
365 if (options.OutputAssembly ==
null || options.OutputAssembly.Length == 0)
367 string fileExtension = options.GenerateExecutable ?
"exe" :
"dll";
368 options.OutputAssembly = compilerResults.
TempFiles.
AddExtension(fileExtension, !options.GenerateInMemory);
375 string trueArgs =
null;
376 if (responseFileCmdArgs !=
null)
379 text = responseFileCmdArgs;
381 Compile(options,
Executor.GetRuntimeInstallDirectory(),
CompilerName, text, ref outputFile, ref nativeReturnValue, trueArgs);
383 if (nativeReturnValue != 0 || options.WarningLevel > 0)
388 if (fileStream.
Length > 0)
401 while (text2 !=
null);
408 if (nativeReturnValue != 0 && flag)
418 int num = (int)fileStream2.
Length;
419 byte[] array =
new byte[num];
420 fileStream2.
Read(array, 0, num);
422 securityPermission2.
Assert();
426 return compilerResults;
439 return compilerResults;
458 string text = options.TempFiles.AddExtension(
"cmdline");
464 streamWriter.
Write(cmdArgs);
465 streamWriter.
Flush();
472 return "@\"" + text +
"\"";
493 string[] array =
new string[sources.Length];
500 for (
int i = 0; i < sources.Length; i++)
502 string text = options.TempFiles.AddExtension(i +
FileExtension);
508 streamWriter.
Write(sources[i]);
509 streamWriter.
Flush();
522 Executor.ReImpersonate(impersonation);
537 if (sa ==
null || sa.Length == 0)
543 return "\"" + sa[0] +
"\"";
546 for (
int i = 0; i < sa.Length - 1; i++)
548 stringBuilder.
Append(
"\"");
549 stringBuilder.
Append(sa[i]);
550 stringBuilder.
Append(
"\"");
551 stringBuilder.
Append(separator);
553 stringBuilder.
Append(
"\"");
554 stringBuilder.
Append(sa[sa.Length - 1]);
555 stringBuilder.
Append(
"\"");
Represents a character encoding.To browse the .NET Framework source code for this type,...
static string JoinStringArray(string[] sa, string separator)
Joins the specified string arrays.
int Add(string value)
Adds a string to the end of the T:System.Collections.Specialized.StringCollection.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
string Current
Gets the current element in the collection.
Describes a set of security permissions applied to code. This class cannot be inherited.
Provides command execution functions for invoking compilers. This class cannot be inherited.
TempFileCollection TempFiles
Gets or sets the temporary file collection to use.
static bool Exists(string path)
Determines whether the specified file exists.
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
static string Combine(string path1, string path2)
Combines two strings into a path.
Represents the results of compilation that are returned from a compiler.
static Assembly Load(string assemblyString)
Loads an assembly given the long form of its name.
abstract string CompilerName
Gets the name of the compiler executable.
FileMode
Specifies how the operating system should open a file.
Assembly CompiledAssembly
Gets or sets the compiled assembly.
virtual CompilerResults FromDomBatch(CompilerParameters options, CodeCompileUnit[] ea)
Compiles the specified compile units using the specified options, and returns the results from the co...
Provides an example implementation of the T:System.CodeDom.Compiler.ICodeGenerator interface....
bool HasErrors
Gets a value that indicates whether the collection contains errors.
Supports a simple iteration over a T:System.Collections.Specialized.StringCollection.
Implements a T:System.IO.TextReader that reads characters from a byte stream in a particular encoding...
abstract string FileExtension
Gets the file name extension to use for source files.
static FileStream OpenRead(string path)
Opens an existing file for reading.
StringCollection Output
Gets the compiler output messages.
override string ReadLine()
Reads a line of characters from the current stream and returns the data as a string.
override int Read([In] [Out] byte[] array, int offset, int count)
Reads a block of bytes from the stream and writes the data in a given buffer.
Represents the parameters used to invoke a compiler.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Implements a T:System.IO.TextWriter for writing characters to a stream in a particular encoding....
virtual void Close()
Closes the current stream and releases any resources (such as sockets and file handles) associated wi...
Defines an interface for invoking compilation of source code or a CodeDOM tree using a specific compi...
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
Defines an interface for generating code.
Evidence Evidence
Indicates the evidence object that represents the security policy permissions of the compiled assembl...
Represents a collection that can contain many different types of permissions.
StringEnumerator GetEnumerator()
Returns a T:System.Collections.Specialized.StringEnumerator that iterates through the T:System....
abstract string CmdArgsFromParameters(CompilerParameters options)
Gets the command arguments to be passed to the compiler from the specified T:System....
virtual CompilerResults FromFile(CompilerParameters options, string fileName)
Compiles the specified file using the specified options, and returns the results from the compilation...
StringCollection ReferencedAssemblies
Gets the referenced assemblies.
Provides a T:System.IO.Stream for a file, supporting both synchronous and asynchronous read and write...
Represents a writer that can write a sequential series of characters. This class is abstract.
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
Defines the underlying structure of all code access permissions.
virtual CompilerResults FromFileBatch(CompilerParameters options, string[] fileNames)
Compiles the specified files using the specified options, and returns the results from the compilatio...
bool MoveNext()
Advances the enumerator to the next element of the collection.
virtual CompilerResults FromDom(CompilerParameters options, CodeCompileUnit e)
Compiles the specified compile unit using the specified options, and returns the results from the com...
virtual void Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
CompilerResults CompileAssemblyFromDom(CompilerParameters options, CodeCompileUnit compilationUnit)
Compiles an assembly from the N:System.CodeDom tree contained in the specified T:System....
virtual CompilerResults FromSource(CompilerParameters options, string source)
Compiles the specified source code string using the specified options, and returns the results from t...
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
static void RevertAssert()
Causes any previous M:System.Security.CodeAccessPermission.Assert for the current frame to be removed...
virtual string GetResponseFileCmdArgs(CompilerParameters options, string cmdArgs)
Gets the command arguments to use when invoking the compiler to generate a response file.
Provides a container for a CodeDOM program graph.
abstract void ProcessCompilerOutputLine(CompilerResults results, string line)
Processes the specified line from the specified T:System.CodeDom.Compiler.CompilerResults.
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
override void Write(char value)
Writes a character to the stream.
override long Length
Gets the length in bytes of the stream.
int Count
Gets the number of strings contained in the T:System.Collections.Specialized.StringCollection.
Provides an example implementation of the T:System.CodeDom.Compiler.ICodeCompiler interface.
CompilerErrorCollection Errors
Gets the collection of compiler errors and warnings.
string PathToAssembly
Gets or sets the path of the compiled assembly.
virtual CompilerResults FromSourceBatch(CompilerParameters options, string[] sources)
Compiles the specified source code strings using the specified options, and returns the results from ...
FileAccess
Defines constants for read, write, or read/write access to a file.
int NativeCompilerReturnValue
Gets or sets the compiler's return value.
static Encoding UTF8
Gets an encoding for the UTF-8 format.
Provides static methods for the creation, copying, deletion, moving, and opening of a single file,...
static void Delete(string path)
Deletes the specified file.
void Assert()
Declares that the calling code can access the resource protected by a permission demand through the c...
SecurityPermissionFlag
Specifies access flags for the security permission object.
override void Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
Performs operations on T:System.String instances that contain file or directory path information....
string AddExtension(string fileExtension)
Adds a file name with the specified file name extension to the collection.
Represents the Windows user prior to an impersonation operation.
FileShare
Contains constants for controlling the kind of access other T:System.IO.FileStream objects can have t...
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....