/// <returns>The file name of the compiled assembly.</returns> private Assembly _Compile(string[] files, IEnumerable <string> assemblyReferences, IScriptModuleInstance language) { // Assembly references come in two flavors: // 1. Framework assemblies -- need only the file name. // 2. Other assemblies -- need the qualified file name. _errors.Clear(); HashSet <string> uniqueAssemblyReferences = new HashSet <string>(assemblyReferences); // Remove .NET framework and GAC assemblies. uniqueAssemblyReferences.RemoveWhere(x => x.StartsWith(Environment.GetFolderPath(Environment.SpecialFolder.Windows), StringComparison.OrdinalIgnoreCase)); ICompilerParameters compilerParameters = new ScriptCompilerParameters { GenerateInMemory = true, //IncludeDebugInformation = true }; compilerParameters.ReferencedAssemblies.AddRange(uniqueAssemblyReferences.ToArray()); ICompilerResults results = language.CodeProvider.CompileAssemblyFromFile(compilerParameters, files); // Get any errors. foreach (ICompilerError error in results.Errors) { _errors.Add(string.Format("{0} [{1}]: {2}", Path.GetFileName(error.FileName), error.Line, error.ErrorText)); } return(results.HasErrors ? null : results.CompiledAssembly); }
/// <returns>The file name of the compiled assembly.</returns> private Assembly _Compile(string[] files, HashSet <string> uniqueAssemblyReferences, ScriptSequence sequence) { IScriptModuleInstance language = sequence.Language; // Assembly references come in two flavors: // 1. Framework assemblies -- need only the file name. // 2. Other assemblies -- need the qualified file name. _errors.Clear(); ICompilerParameters compilerParameters = new ScriptCompilerParameters { GenerateInMemory = true, //IncludeDebugInformation = true }; compilerParameters.ReferencedAssemblies.AddRange(uniqueAssemblyReferences.ToArray()); ICompilerResults results = language.CodeProvider.CompileAssemblyFromFile(compilerParameters, files); // Get any errors. foreach (ICompilerError error in results.Errors) { _errors.Add(string.Format("{0} [{1}]: {2}", Path.GetFileName(error.FileName), error.Line, error.ErrorText)); } return(results.HasErrors ? null : results.CompiledAssembly); }
/// <summary> /// Emits a summary of the results. /// </summary> /// <param name="compilerResults">The compiler results.</param> public void EmitSummary(ICompilerResults compilerResults) { Guard.ArgumentNotNull(() => compilerResults, compilerResults); log.Info("----------------------------"); var warningCount = compilerResults.Warnings == null ? 0 : compilerResults.Warnings.Count; var errorCount = compilerResults.Errors == null ? 0 : compilerResults.Errors.Count; if (warningCount > 0 || errorCount > 0) { log.Info("Found " + errorCount + " Errors, " + warningCount + " Warnings"); } else { log.Info("No Errors or Warnings Found!"); } if (errorCount <= 0) { log.Info("----------------------------"); log.Info("Code Emitted:"); log.Info(compilerResults.CompiledCode); } }
public void EmitWarnings(ICompilerResults compilerResults) { var warningCount = compilerResults.Warnings == null ? 0 : compilerResults.Warnings.Count; if (warningCount > 0) { foreach (var compilerWarning in compilerResults.Warnings) { errorListHelper.Write( TaskCategory.Misc, TaskErrorCategory.Warning, "Some Context", compilerWarning.Warning, "sample.js", compilerWarning.Lineno, compilerWarning.Charno); } } }
public void EmitErrors(ICompilerResults compilerResults) { var errorCount = compilerResults.Errors == null ? 0 : compilerResults.Errors.Count; if (errorCount > 0) { foreach (var compilerError in compilerResults.Errors) { errorListHelper.Write( TaskCategory.Misc, TaskErrorCategory.Error, "Some Context", compilerError.Error, "sample.js", compilerError.Lineno, compilerError.Charno); } } }
public void EmitErrors(ICompilerResults compilerResults) { var errorCount = compilerResults.Errors == null ? 0 : compilerResults.Errors.Count; if (errorCount > 0) { foreach (var compilerError in compilerResults.Errors) { errorListHelper.Write( TaskCategory.Misc, TaskErrorCategory.Error, "Some Context", compilerError.Error, "sample.js", compilerError.Lineno, compilerError.Charno); } } }
public void EmitWarnings(ICompilerResults compilerResults) { var warningCount = compilerResults.Warnings == null ? 0 : compilerResults.Warnings.Count; if (warningCount > 0) { foreach (var compilerWarning in compilerResults.Warnings) { errorListHelper.Write( TaskCategory.Misc, TaskErrorCategory.Warning, "Some Context", compilerWarning.Warning, "sample.js", compilerWarning.Lineno, compilerWarning.Charno); } } }
/// <summary> /// Emits errors. /// </summary> /// <param name="compilerResults">The compiler results.</param> public void EmitErrors(ICompilerResults compilerResults) { Guard.ArgumentNotNull(() => compilerResults, compilerResults); var errorCount = compilerResults.Errors == null ? 0 : compilerResults.Errors.Count; if (errorCount <= 0) { return; } // ReSharper disable once PossibleNullReferenceException foreach (var compilerError in compilerResults.Errors) { log.Info( string.Format( "{0}({1}): ERROR ({2}) - {3}", compilerResults.OutputFilePath, compilerError.Lineno, compilerError.Type, compilerError.Error)); log.Info(compilerError.Line.TrimStart()); } }
/// <summary> /// Emits errors. /// </summary> /// <param name="compilerResults">The compiler results.</param> public void EmitErrors(ICompilerResults compilerResults) { Guard.ArgumentNotNull(() => compilerResults, compilerResults); var errorCount = compilerResults.Errors == null ? 0 : compilerResults.Errors.Count; if (errorCount <= 0) { return; } // ReSharper disable once PossibleNullReferenceException foreach (var compilerError in compilerResults.Errors) { log.Info( string.Format( "{0}({1}): ERROR ({2}) - {3}", compilerResults.OutputFilePath, compilerError.Lineno, compilerError.Type, compilerError.Error)); log.Info(compilerError.Line.TrimStart()); } }
/// <summary> /// Emits warnings. /// </summary> /// <param name="compilerResults">The compiler results.</param> public void EmitWarnings(ICompilerResults compilerResults) { Guard.ArgumentNotNull(() => compilerResults, compilerResults); var warningCount = compilerResults.Warnings == null ? 0 : compilerResults.Warnings.Count; if (warningCount <= 0) { return; } // ReSharper disable once PossibleNullReferenceException foreach (var compilerWarning in compilerResults.Warnings) { log.Info( string.Format( "{0}({1}): WARNING ({2}) - {3}", compilerResults.OutputFilePath, compilerWarning.Lineno, compilerWarning.Type, compilerWarning.Warning)); log.Info(compilerWarning.Line.TrimStart()); } }
/// <summary> /// Emits a summary of the results. /// </summary> /// <param name="compilerResults">The compiler results.</param> public void EmitSummary(ICompilerResults compilerResults) { Guard.ArgumentNotNull(() => compilerResults, compilerResults); log.Info("----------------------------"); var warningCount = compilerResults.Warnings == null ? 0 : compilerResults.Warnings.Count; var errorCount = compilerResults.Errors == null ? 0 : compilerResults.Errors.Count; if (warningCount > 0 || errorCount > 0) { log.Info("Found " + errorCount + " Errors, " + warningCount + " Warnings"); } else { log.Info("No Errors or Warnings Found!"); } if (errorCount <= 0) { log.Info("----------------------------"); log.Info("Code Emitted:"); log.Info(compilerResults.CompiledCode); } }
/// <summary> /// Emits warnings. /// </summary> /// <param name="compilerResults">The compiler results.</param> public void EmitWarnings(ICompilerResults compilerResults) { Guard.ArgumentNotNull(() => compilerResults, compilerResults); var warningCount = compilerResults.Warnings == null ? 0 : compilerResults.Warnings.Count; if (warningCount <= 0) { return; } // ReSharper disable once PossibleNullReferenceException foreach (var compilerWarning in compilerResults.Warnings) { log.Info( string.Format( "{0}({1}): WARNING ({2}) - {3}", compilerResults.OutputFilePath, compilerWarning.Lineno, compilerWarning.Type, compilerWarning.Warning)); log.Info(compilerWarning.Line.TrimStart()); } }
public void EmitSummary(ICompilerResults compilerResults) { // do nothing }
public void EmitSummary(ICompilerResults compilerResults) { // do nothing }