16 [PermissionSet(
SecurityAction.InheritanceDemand, Name =
"FullTrust")]
19 private static CodeDomCompilationConfiguration Config
24 if (codeDomCompilationConfiguration ==
null)
26 return CodeDomCompilationConfiguration.Default;
28 return codeDomCompilationConfiguration;
73 CompilerInfo compilerInfoForExtensionNoThrow = GetCompilerInfoForExtensionNoThrow(extension);
74 if (compilerInfoForExtensionNoThrow ==
null)
76 throw new ConfigurationErrorsException(SR.GetString(
"CodeDomProvider_NotDefined"));
78 return compilerInfoForExtensionNoThrow._compilerLanguages[0];
90 return GetCompilerInfoForLanguageNoThrow(language) !=
null;
102 return GetCompilerInfoForExtensionNoThrow(extension) !=
null;
114 CompilerInfo compilerInfoForLanguageNoThrow = GetCompilerInfoForLanguageNoThrow(language);
115 if (compilerInfoForLanguageNoThrow ==
null)
117 throw new ConfigurationErrorsException(SR.GetString(
"CodeDomProvider_NotDefined"));
119 return compilerInfoForLanguageNoThrow;
122 private static CompilerInfo GetCompilerInfoForLanguageNoThrow(
string language)
124 if (language ==
null)
128 return (CompilerInfo)Config._compilerLanguages[language.Trim()];
131 private static CompilerInfo GetCompilerInfoForExtensionNoThrow(
string extension)
133 if (extension ==
null)
137 return (CompilerInfo)Config._compilerExtensions[extension.Trim()];
146 ArrayList allCompilerInfo = Config._allCompilerInfo;
152 [Obsolete(
"Callers should not use the ICodeGenerator interface and should instead use the methods directly on the CodeDomProvider class. Those inheriting from CodeDomProvider must still implement this interface, and should exclude this warning or also obsolete this method.")]
173 [Obsolete(
"Callers should not use the ICodeCompiler interface and should instead use the methods directly on the CodeDomProvider class. Those inheriting from CodeDomProvider must still implement this interface, and should exclude this warning or also obsolete this method.")]
178 [Obsolete(
"Callers should not use the ICodeParser interface and should instead use the methods directly on the CodeDomProvider class. Those inheriting from CodeDomProvider must still implement this interface, and should exclude this warning or also obsolete this method.")]
266 return CreateGeneratorHelper().
Supports(generatorSupport);
335 return CreateParserHelper().
Parse(codeStream);
341 if (codeCompiler ==
null)
348 private ICodeGenerator CreateGeneratorHelper()
351 if (codeGenerator ==
null)
355 return codeGenerator;
358 private ICodeParser CreateParserHelper()
361 if (codeParser ==
null)
363 throw new NotImplementedException(SR.GetString(
"NotSupported_CodeDomAPI"));
368 internal static bool TryGetProbableCoreAssemblyFilePath(CompilerParameters parameters, out
string coreAssemblyFilePath)
371 char[] separator =
new char[1]
375 string value =
Path.
Combine(
"Reference Assemblies",
"Microsoft",
"Framework");
376 StringEnumerator enumerator = parameters.ReferencedAssemblies.GetEnumerator();
381 string current = enumerator.
Current;
384 coreAssemblyFilePath =
string.Empty;
390 for (
int i = 0; i < array.Length - 5; i++)
392 if (
string.Equals(array[i],
"Reference Assemblies",
StringComparison.OrdinalIgnoreCase) && array[i + 4].StartsWith(
"v",
StringComparison.OrdinalIgnoreCase))
398 coreAssemblyFilePath =
string.Empty;
413 (enumerator as IDisposable)?.
Dispose();
417 coreAssemblyFilePath =
Path.
Combine(text,
"mscorlib.dll");
420 coreAssemblyFilePath =
string.Empty;
LanguageOptions
Defines identifiers that indicate special features of a language.
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.
virtual ICodeGenerator CreateGenerator(string fileName)
When overridden in a derived class, creates a new code generator using the specified file name for ou...
virtual bool IsValidIdentifier(string value)
Returns a value that indicates whether the specified value is a valid identifier for the current lang...
string CreateEscapedIdentifier(string value)
Creates an escaped identifier for the specified value.
static string Combine(string path1, string path2)
Combines two strings into a path.
virtual ICodeGenerator CreateGenerator(TextWriter output)
When overridden in a derived class, creates a new code generator using the specified T:System....
Represents the results of compilation that are returned from a compiler.
bool IsValidIdentifier(string value)
Gets a value that indicates whether the specified value is a valid identifier for the current languag...
CompilerResults CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit[] compilationUnits)
Compiles an assembly based on the N:System.CodeDom trees contained in the specified array of T:System...
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
virtual TypeConverter GetConverter(Type type)
Gets a T:System.ComponentModel.TypeConverter for the specified data type.
static CodeDomProvider CreateProvider(string language)
Gets a T:System.CodeDom.Compiler.CodeDomProvider instance for the specified language.
static TypeConverter GetConverter(object component)
Returns a type converter for the type of the specified component.
virtual void GenerateCodeFromStatement(CodeStatement statement, TextWriter writer, CodeGeneratorOptions options)
Generates code for the specified Code Document Object Model (CodeDOM) statement and sends it to the s...
Represents a type declaration for a class, structure, interface, or enumeration.
void GenerateCodeFromStatement(CodeStatement e, TextWriter w, CodeGeneratorOptions o)
Generates code for the specified Code Document Object Model (CodeDOM) statement and outputs it to the...
Supports a simple iteration over a T:System.Collections.Specialized.StringCollection.
Defines an interface for parsing code into a T:System.CodeDom.CodeCompileUnit.
abstract ICodeCompiler CreateCompiler()
When overridden in a derived class, creates a new code compiler.
virtual void GenerateCodeFromCompileUnit(CodeCompileUnit compileUnit, TextWriter writer, CodeGeneratorOptions options)
Generates code for the specified Code Document Object Model (CodeDOM) compilation unit and sends it t...
CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames)
Compiles an assembly from the source code contained within the specified files, using the specified c...
void GenerateCodeFromNamespace(CodeNamespace e, TextWriter w, CodeGeneratorOptions o)
Generates code for the specified Code Document Object Model (CodeDOM) namespace and outputs it to the...
static string GetFileName(string path)
Returns the file name and extension of the specified path string.
static readonly char DirectorySeparatorChar
Provides a platform-specific character used to separate directory levels in a path string that reflec...
Represents the parameters used to invoke a compiler.
static string GetLanguageFromExtension(string extension)
Returns a language name associated with the specified file name extension, as configured in the T:Sys...
virtual string FileExtension
Gets the default file name extension to use for source code files in the current language.
static bool IsDefinedExtension(string extension)
Tests whether a file name extension has an associated T:System.CodeDom.Compiler.CodeDomProvider imple...
CompilerResults CompileAssemblyFromSourceBatch(CompilerParameters options, string[] sources)
Compiles an assembly from the specified array of strings containing source code, using the specified ...
virtual CompilerResults CompileAssemblyFromSource(CompilerParameters options, params string[] sources)
Compiles an assembly from the specified array of strings containing source code, using the specified ...
SecurityAction
Specifies the security actions that can be performed using declarative security.
Defines an interface for invoking compilation of source code or a CodeDOM tree using a specific compi...
Defines an interface for generating code.
virtual bool Supports(GeneratorSupport generatorSupport)
Returns a value indicating whether the specified code generation support is provided.
string CreateValidIdentifier(string value)
Creates a valid identifier for the specified value.
void Dispose()
Releases all resources used by the T:System.ComponentModel.Component.
virtual void GenerateCodeFromType(CodeTypeDeclaration codeType, TextWriter writer, CodeGeneratorOptions options)
Generates code for the specified Code Document Object Model (CodeDOM) type declaration and sends it t...
virtual string CreateValidIdentifier(string value)
Creates a valid identifier for the specified value.
void GenerateCodeFromType(CodeTypeDeclaration e, TextWriter w, CodeGeneratorOptions o)
Generates code for the specified Code Document Object Model (CodeDOM) type declaration and outputs it...
static CompilerInfo GetCompilerInfo(string language)
Returns the language provider and compiler configuration settings for the specified language.
static CompilerInfo [] GetAllCompilerInfo()
Returns the language provider and compiler configuration settings for this computer.
Provides a base class for a member of a type. Type members include fields, methods,...
StringSplitOptions
Specifies whether applicable Overload:System.String.Split method overloads include or omit empty subs...
CodeCompileUnit Parse(TextReader codeStream)
When implemented in a derived class, compiles the specified text stream into a T:System....
Represents a writer that can write a sequential series of characters. This class is abstract.
Represents a set of options used by a code generator.
Provides the base implementation for the T:System.ComponentModel.IComponent interface and enables obj...
Represents type declarations: class types, interface types, array types, value types,...
Provides information about the characteristics for a component, such as its attributes,...
bool MoveNext()
Advances the enumerator to the next element of the collection.
virtual CompilerResults CompileAssemblyFromDom(CompilerParameters options, params CodeCompileUnit[] compilationUnits)
Compiles an assembly based on the N:System.CodeDom trees contained in the specified array of T:System...
CodeDomProvider CreateProvider()
Returns a T:System.CodeDom.Compiler.CodeDomProvider instance for the current language provider settin...
void GenerateCodeFromExpression(CodeExpression e, TextWriter w, CodeGeneratorOptions o)
Generates code for the specified Code Document Object Model (CodeDOM) expression and outputs it to th...
static CodeDomProvider CreateProvider(string language, IDictionary< string, string > providerOptions)
Gets a T:System.CodeDom.Compiler.CodeDomProvider instance for the specified language and provider opt...
Provides a container for a CodeDOM program graph.
GeneratorSupport
Defines identifiers used to determine whether a code generator supports certain types of code element...
static bool IsDefinedLanguage(string language)
Tests whether a language has a T:System.CodeDom.Compiler.CodeDomProvider implementation configured on...
abstract ICodeGenerator CreateGenerator()
When overridden in a derived class, creates a new code generator.
virtual string CreateEscapedIdentifier(string value)
Creates an escaped identifier for the specified value.
virtual ICodeParser CreateParser()
When overridden in a derived class, creates a new code parser.
virtual CompilerResults CompileAssemblyFromFile(CompilerParameters options, params string[] fileNames)
Compiles an assembly from the source code contained in the specified files, using the specified compi...
Represents a namespace declaration.
virtual void GenerateCodeFromNamespace(CodeNamespace codeNamespace, TextWriter writer, CodeGeneratorOptions options)
Generates code for the specified Code Document Object Model (CodeDOM) namespace and sends it to the s...
Represents a code expression. This is a base class for other code expression objects that is never in...
Represents a reader that can read a sequential series of characters.
virtual CodeCompileUnit Parse(TextReader codeStream)
Compiles the code read from the specified text stream into a T:System.CodeDom.CodeCompileUnit.
Provides a base class for T:System.CodeDom.Compiler.CodeDomProvider implementations....
virtual void GenerateCodeFromMember(CodeTypeMember member, TextWriter writer, CodeGeneratorOptions options)
Generates code for the specified Code Document Object Model (CodeDOM) member declaration and sends it...
Represents the configuration settings of a language provider. This class cannot be inherited.
Represents the abstract base class from which all code statements derive.
string GetTypeOutput(CodeTypeReference type)
Gets the type indicated by the specified T:System.CodeDom.CodeTypeReference.
static string GetDirectoryName(string path)
Returns the directory information for the specified path string.
bool Supports(GeneratorSupport supports)
Gets a value indicating whether the generator provides support for the language features represented ...
void GenerateCodeFromCompileUnit(CodeCompileUnit e, TextWriter w, CodeGeneratorOptions o)
Generates code for the specified Code Document Object Model (CodeDOM) compilation unit and outputs it...
virtual string GetTypeOutput(CodeTypeReference type)
Gets the type indicated by the specified T:System.CodeDom.CodeTypeReference.
Represents a reference to a type.
The exception that is thrown when a requested method or operation is not implemented.
Provides a unified way of converting types of values to other types, as well as for accessing standar...
Performs operations on T:System.String instances that contain file or directory path information....
virtual void GenerateCodeFromExpression(CodeExpression expression, TextWriter writer, CodeGeneratorOptions options)
Generates code for the specified Code Document Object Model (CodeDOM) expression and sends it to the ...
virtual object [] ToArray()
Copies the elements of the T:System.Collections.ArrayList to a new T:System.Object array.
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...