Terraria.ModLoader.ErrorLogger.LogCompileErrors C# (CSharp) Method

LogCompileErrors() static private method

static private LogCompileErrors ( CompilerErrorCollection errors ) : void
errors System.CodeDom.Compiler.CompilerErrorCollection
return void
		internal static void LogCompileErrors(CompilerErrorCollection errors)
		{
			string errorHeader = "An error ocurred while compiling a mod." + Environment.NewLine + Environment.NewLine;
			Console.WriteLine(errorHeader);
			Directory.CreateDirectory(LogPath);
			CompilerError displayError = null;
			using (var writer = File.CreateText(CompileErrorPath))
			{
				foreach (CompilerError error in errors)
				{
					writer.WriteLine(error + Environment.NewLine);
					Console.WriteLine(error);
					if (!error.IsWarning && displayError == null)
						displayError = error;
				}
			}
			Interface.errorMessage.SetMessage(errorHeader + displayError);
			Interface.errorMessage.SetGotoMenu(Interface.modSourcesID);
			Interface.errorMessage.SetFile(CompileErrorPath);
		}

Usage Example

Exemplo n.º 1
0
        private static bool CompileMod(string modDir, BuildProperties properties)
        {
            CompilerParameters compileOptions = new CompilerParameters();

            compileOptions.GenerateExecutable = false;
            compileOptions.GenerateInMemory   = false;
            compileOptions.OutputAssembly     = ModPath + Path.DirectorySeparatorChar + Path.GetFileName(modDir) + ".tmod";
            foreach (string reference in buildReferences)
            {
                compileOptions.ReferencedAssemblies.Add(reference);
            }
            Directory.CreateDirectory(DllPath);
            foreach (string reference in properties.dllReferences)
            {
                compileOptions.ReferencedAssemblies.Add(DllPath + Path.DirectorySeparatorChar + reference + ".dll");
            }
            foreach (string reference in properties.modReferences)
            {
                compileOptions.ReferencedAssemblies.Add(ModSourcePath + Path.DirectorySeparatorChar + reference + ".dll");
            }
            CodeDomProvider         codeProvider = new CSharpCodeProvider();
            CompilerResults         results      = codeProvider.CompileAssemblyFromFile(compileOptions, Directory.GetFiles(modDir, "*.cs", SearchOption.AllDirectories));
            CompilerErrorCollection errors       = results.Errors;

            foreach (string reference in properties.modReferences)
            {
                File.Delete(ModSourcePath + Path.DirectorySeparatorChar + reference + ".dll");
            }
            if (errors.HasErrors)
            {
                ErrorLogger.LogCompileErrors(errors);
                return(false);
            }
            return(true);
        }
All Usage Examples Of Terraria.ModLoader.ErrorLogger::LogCompileErrors