本文整理汇总了C#中System.CodeDom.Compiler.CompilerResults类的典型用法代码示例。如果您正苦于以下问题:C# CompilerResults类的具体用法?C# CompilerResults怎么用?C# CompilerResults使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompilerResults类属于System.CodeDom.Compiler命名空间,在下文中一共展示了CompilerResults类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Execute
/// <exception cref="TargetInvocationException">When the supplied assembly's main method throws</exception>
public void Execute(CompilerResults results, IEnumerable<string> additionalReferences)
{
var entryPoint = results.CompiledAssembly.EntryPoint;
using(serviceMessages.ProgressBlock("Executing script"))
ExecutePrivate(entryPoint, additionalReferences);
}
开发者ID:Tdue21,项目名称:teamcitycsharprunner,代码行数:8,代码来源:Executor.cs
示例2: CompileAssemblyFromDomBatch
public CompilerResults CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit[] compilationUnits)
{
Setup(options, ContainsLocalFunctions(compilationUnits));
foreach(var Unit in compilationUnits)
{
foreach (CodeAttributeDeclaration attribute in Unit.AssemblyCustomAttributes)
EmitAttribute(ABuilder, attribute);
EmitNamespace(ABuilder, Unit.Namespaces[0]);
}
ABuilder.SetEntryPoint(EntryPoint, PEFileKinds.WindowApplication);
Save();
var results = new CompilerResults(new TempFileCollection());
string output = options.OutputAssembly;
if (options.GenerateInMemory)
{
results.TempFiles.AddFile(output, false);
byte[] raw = File.ReadAllBytes(output);
results.CompiledAssembly = Assembly.Load(raw);
File.Delete(output);
}
else
results.PathToAssembly = Path.GetFullPath(output);
return results;
}
开发者ID:BillTheBest,项目名称:IronAHK,代码行数:30,代码来源:Compiler.cs
示例3: Compile
public List<CheckingResult> Compile(string program, out CompilerResults compilerResults)
{
compilerResults = null;
using (var provider = new CSharpCodeProvider())
{
compilerResults = provider.CompileAssemblyFromSource(new CompilerParameters(new string[]
{
"System.dll"
})
{
GenerateExecutable = true
},
new string[]
{
program
});
}
var result = new List<CheckingResult>();
if (compilerResults.Errors.HasErrors)
{
for (int i = 0; i < compilerResults.Errors.Count; i++)
result.Add(new CheckingResult
{
FirstErrorLine = compilerResults.Errors[i].Line,
FirstErrorColumn = compilerResults.Errors[i].Column,
Output = null,
Description = compilerResults.Errors[i].ErrorText
});
}
return result;
}
开发者ID:KvanTTT,项目名称:Freaky-Sources,代码行数:31,代码来源:CSharpChecker.cs
示例4: Load
void Load (CompilerResults results, string fullName)
{
var assembly = results.CompiledAssembly;
Type transformType = assembly.GetType (fullName);
//MS Templating Engine does not look on the type itself,
//it checks only that required methods are exists in the compiled type
textTransformation = Activator.CreateInstance (transformType);
//set the host property if it exists
Type hostType = null;
var gen = host as TemplateGenerator;
if (gen != null) {
hostType = gen.SpecificHostType;
}
var hostProp = transformType.GetProperty ("Host", hostType ?? typeof(ITextTemplatingEngineHost));
if (hostProp != null && hostProp.CanWrite)
hostProp.SetValue (textTransformation, host, null);
var sessionHost = host as ITextTemplatingSessionHost;
if (sessionHost != null) {
//FIXME: should we create a session if it's null?
var sessionProp = transformType.GetProperty ("Session", typeof (IDictionary<string, object>));
sessionProp.SetValue (textTransformation, sessionHost.Session, null);
}
}
开发者ID:riverans,项目名称:monodevelop,代码行数:25,代码来源:CompiledTemplate.cs
示例5: CompileScript
/// <summary>
/// Compile Script -> Return Assembly
/// </summary>
public Assembly CompileScript(IRefObject ScriptObject, out CompilerResults Result)
{
String ClassName, PrefixName;
switch (ScriptObject.Type)
{
case IRefObject.ScriptType.WEAPON:
ClassName = "ScriptWeapon";
PrefixName = "WeaponPrefix";
break;
default:
ClassName = "ScriptLevelNpc";
PrefixName = "LevelNpcPrefix";
break;
}
// Setup our options
CompilerParameters options = new CompilerParameters();
options.GenerateExecutable = false;
options.GenerateInMemory = true;
options.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
options.ReferencedAssemblies.Add("System.dll");
options.ReferencedAssemblies.Add("System.Core.dll");
options.ReferencedAssemblies.Add("Microsoft.CSharp.dll");
// Compile our code
CSharpCodeProvider csProvider = new Microsoft.CSharp.CSharpCodeProvider();
Result = csProvider.CompileAssemblyFromSource(options, "using CS_NPCServer; public class " + PrefixName + NextId[(int)ScriptObject.Type] + " : " + ClassName + " { public " + PrefixName + NextId[(int)ScriptObject.Type] + "(NPCServer Server, IRefObject Ref) : base(Server, Ref) { } " + ParseJoins(ScriptObject.Script) + " } ");
NextId[(int)ScriptObject.Type]++;
return (Result.Errors.HasErrors ? null : Result.CompiledAssembly);
}
开发者ID:dufresnep,项目名称:gs2emu-googlecode,代码行数:34,代码来源:GameCompiler.cs
示例6: CompilerErrorException
public CompilerErrorException(CompilerResults results)
{
foreach (CompilerError error in results.Errors)
{
this.CompilerMessage += error + "\n";
}
}
开发者ID:esmaxwill,项目名称:ScriptHost,代码行数:7,代码来源:CompilerErrorException.cs
示例7: GetGeneratedType
public override Type GetGeneratedType(CompilerResults results)
{
Type type;
try
{
using (Stream stream = base.OpenStream())
{
XamlXmlReader reader2 = new XamlXmlReader(XmlReader.Create(stream));
while (reader2.Read())
{
if (reader2.NodeType == XamlNodeType.StartObject)
{
if (reader2.Type.IsUnknown)
{
StringBuilder sb = new StringBuilder();
this.AppendTypeName(reader2.Type, sb);
throw FxTrace.Exception.AsError(new TypeLoadException(System.Xaml.Hosting.SR.CouldNotResolveType(sb)));
}
return reader2.Type.UnderlyingType;
}
}
throw FxTrace.Exception.AsError(new HttpCompileException(System.Xaml.Hosting.SR.UnexpectedEof));
}
}
catch (XamlParseException exception)
{
throw FxTrace.Exception.AsError(new HttpCompileException(exception.Message, exception));
}
return type;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:XamlBuildProvider.cs
示例8: handleErrors
private void handleErrors(CompilerResults compilerResults)
{
if (compilerResults.Errors.Count > 0)
{
StringBuilder sb = new StringBuilder("Error compiling the composition script:\n");
foreach (CompilerError compilerError in compilerResults.Errors)
{
if (!compilerError.IsWarning)
{
sb.Append("\nError number:\t")
.Append(compilerError.ErrorNumber)
.Append("\nMessage:\t ")
.Append(compilerError.ErrorText)
.Append("\nLine number:\t")
.Append(compilerError.Line);
}
}
if (!sb.Length.Equals(0))
{
throw new PicoCompositionException(sb.ToString());
}
}
}
开发者ID:smmckay,项目名称:picocontainer,代码行数:25,代码来源:FrameworkCompiler.cs
示例9: GetGeneratedType
internal Type GetGeneratedType(CompilerResults results, bool useDelayLoadTypeIfEnabled)
{
string str;
if (!this.Parser.RequiresCompilation)
{
return null;
}
if (this._instantiatableFullTypeName == null)
{
if (this.Parser.CodeFileVirtualPath == null)
{
return this.Parser.BaseType;
}
str = this._intermediateFullTypeName;
}
else
{
str = this._instantiatableFullTypeName;
}
if (useDelayLoadTypeIfEnabled && DelayLoadType.Enabled)
{
return new DelayLoadType(Util.GetAssemblyNameFromFileName(Path.GetFileName(results.PathToAssembly)), str);
}
return results.CompiledAssembly.GetType(str);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:BaseTemplateBuildProvider.cs
示例10: CacheCompileErrors
private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results)
{
System.Web.Compilation.BuildProvider provider = null;
foreach (CompilerError error in results.Errors)
{
if (!error.IsWarning)
{
System.Web.Compilation.BuildProvider buildProviderFromLinePragma = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName);
if (((buildProviderFromLinePragma != null) && (buildProviderFromLinePragma is BaseTemplateBuildProvider)) && (buildProviderFromLinePragma != provider))
{
provider = buildProviderFromLinePragma;
CompilerResults results2 = new CompilerResults(null);
foreach (string str in results.Output)
{
results2.Output.Add(str);
}
results2.PathToAssembly = results.PathToAssembly;
results2.NativeCompilerReturnValue = results.NativeCompilerReturnValue;
results2.Errors.Add(error);
HttpCompileException compileException = new HttpCompileException(results2, assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProviderFromLinePragma));
BuildResult result = new BuildResultCompileError(buildProviderFromLinePragma.VirtualPathObject, compileException);
buildProviderFromLinePragma.SetBuildResultDependencies(result);
BuildManager.CacheVPathBuildResult(buildProviderFromLinePragma.VirtualPathObject, result, this._utcStart);
}
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:WebDirectoryBatchCompiler.cs
示例11: ProcessResults
private static void ProcessResults(CompilerResults results)
{
if (results.Errors.Count != 0)
throw new CompilingErrorsException(results.Errors.OfType<CompilerError>().ToArray());
if (results.CompiledAssembly == null)
throw new CompilingException(CouldNotLocateAssemblyErrorMessage);
}
开发者ID:Eskat0n,项目名称:NArms,代码行数:7,代码来源:CompilingServiceBase.cs
示例12: Check
private static _Assembly Check(CompilerResults results) {
if (results.Errors.Count > 0) {
throw new CompilerException(results);
}
return results.CompiledAssembly;
}
开发者ID:roomaroo,项目名称:coapp.powershell,代码行数:7,代码来源:CompilerImpl.cs
示例13: BuildManagerCacheItem
public BuildManagerCacheItem (Assembly assembly, BuildProvider bp, CompilerResults results)
{
this.BuiltAssembly = assembly;
this.CompiledCustomString = bp.GetCustomString (results);
this.VirtualPath = bp.VirtualPath;
this.Type = bp.GetGeneratedType (results);
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:BuildManagerCacheItem.cs
示例14: GetGeneratedType
public override Type GetGeneratedType(CompilerResults results)
{
if (this.xamlBuildProviderExtension != null)
{
Type result = this.xamlBuildProviderExtension.GetGeneratedType(results);
if (result != null)
{
return result;
}
}
try
{
XamlType rootXamlType = GetRootXamlType();
if (rootXamlType.IsUnknown)
{
StringBuilder typeName = new StringBuilder();
AppendTypeName(rootXamlType, typeName);
throw FxTrace.Exception.AsError(new TypeLoadException(SR.CouldNotResolveType(typeName)));
}
return rootXamlType.UnderlyingType;
}
catch (XamlParseException ex)
{
throw FxTrace.Exception.AsError(new HttpCompileException(ex.Message, ex));
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:27,代码来源:XamlBuildProvider.cs
示例15: CompileAssemblyFromSource
// Build an assembly from a list of source strings.
public override CompilerResults CompileAssemblyFromSource(CompilerParameters options, params string[] sources)
{
var root = new Root();
foreach(string code in sources)
parser.Parse(root, code);
if(root.CompilerErrors.Count > 0)
{
var results = new CompilerResults(null);
foreach(var e in root.CompilerErrors)
results.Errors.Add(e);
return results;
}
validator.Validate(options, root);
if (root.CompilerErrors.Count > 0)
{
var results = new CompilerResults(null);
foreach (var e in root.CompilerErrors)
results.Errors.Add(e);
return results;
}
var codeDomEmitter = new CodeDomEmitter();
return codeDomEmitter.Emit(options, root);
}
开发者ID:maleficus1234,项目名称:Pie,代码行数:29,代码来源:PieCodeProvider.cs
示例16: GetOutput
static string GetOutput(CompilerResults results)
{
var message = new StringBuilder();
foreach(var s in results.Output)
message.AppendLine(s);
return message.ToString();
}
开发者ID:simoneb,项目名称:Pencil,代码行数:7,代码来源:CompilationFailedException.cs
示例17: AddCompilerErrorsFromCompilerResults
internal void AddCompilerErrorsFromCompilerResults(CompilerResults results)
{
foreach (CompilerError error in results.Errors)
base.Errors.Add(new WorkflowCompilerError(error));
foreach (string msg in results.Output)
base.Output.Add(msg);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:XomlCompilerResults.cs
示例18: service_info_methods
public static void service_info_methods()
{
uri = new Uri("http://localhost:60377/Service1.asmx?wsdl");
WebRequest webRequest = WebRequest.Create(uri);
System.IO.Stream requestStream = webRequest.GetResponse().GetResponseStream();
// Get a WSDL file describing a service
ServiceDescription sd = ServiceDescription.Read(requestStream);
string sdName = sd.Services[0].Name;
// Initialize a service description servImport
ServiceDescriptionImporter servImport = new ServiceDescriptionImporter();
servImport.AddServiceDescription(sd, String.Empty, String.Empty);
servImport.ProtocolName = "Soap";
servImport.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties;
CodeNamespace nameSpace = new CodeNamespace();
CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
codeCompileUnit.Namespaces.Add(nameSpace);
// Set Warnings
ServiceDescriptionImportWarnings warnings = servImport.Import(nameSpace, codeCompileUnit);
if (warnings == 0)
{
StringWriter stringWriter = new StringWriter(System.Globalization.CultureInfo.CurrentCulture);
Microsoft.CSharp.CSharpCodeProvider prov = new Microsoft.CSharp.CSharpCodeProvider();
prov.GenerateCodeFromNamespace(nameSpace, stringWriter, new CodeGeneratorOptions());
string[] assemblyReferences = new string[2] { "System.Web.Services.dll", "System.Xml.dll" };
CompilerParameters param = new CompilerParameters(assemblyReferences);
param.GenerateExecutable = false;
param.GenerateInMemory = true;
param.TreatWarningsAsErrors = false;
param.WarningLevel = 4;
CompilerResults results = new CompilerResults(new TempFileCollection());
results = prov.CompileAssemblyFromDom(param, codeCompileUnit);
Assembly assembly = results.CompiledAssembly;
service = assembly.GetType(sdName);
methodInfo = service.GetMethods();
int c = 0;
foreach (MethodInfo t in methodInfo)
{
if (t.Name == "Discover")
break;
c++;
}
listurl = new string[c]; c = 0;
foreach (MethodInfo t in methodInfo)
{
if (t.Name == "Discover")
break;
listurl[c++] = t.Name;
}
}
}
开发者ID:MinaYounan-CS,项目名称:WoT-Testbed-Environment,代码行数:59,代码来源:Service+Info.cs
示例19: GetGeneratedType
public override Type GetGeneratedType(CompilerResults results)
{
if (this._parser.HasInlineCode)
{
return this._parser.GetTypeToCache(results.CompiledAssembly);
}
return this._parser.GetTypeToCache(null);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:SimpleHandlerBuildProvider.cs
示例20: AssertNoErrors
static void AssertNoErrors(CompilerResults results)
{
if (results.Errors.Count == 0)
return;
CompilerError firstError = results.Errors[0];
throw new ArgumentException(String.Format("{2} at ({0},{1})", firstError.Line, firstError.Column, firstError.ErrorText));
}
开发者ID:tigerhu67,项目名称:monobuildtools,代码行数:8,代码来源:CSharpCompiler.cs
注:本文中的System.CodeDom.Compiler.CompilerResults类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论