本文整理汇总了C#中Logger.?.Append方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.?.Append方法的具体用法?C# Logger.?.Append怎么用?C# Logger.?.Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger.?.Append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
private static int Compile(string[] args, Logger logger, Settings settings)
{
logger?.AppendHeader();
var responseFile = args[0];
var compilationOptions = File.ReadAllLines(responseFile.TrimStart('@'));
var unityEditorDataDir = GetUnityEditorDataDir();
var projectDir = Directory.GetCurrentDirectory();
var targetAssembly = compilationOptions.First(line => line.StartsWith("-out:")).Substring(10).Trim('\'');
var monoProfile = compilationOptions.First(line => line.StartsWith("-define:__UNITY_PROFILE__")).Substring(25);
if (monoProfile == "2_0") monoProfile = "2.0";
logger?.Append($"CSharpCompilerWrapper.exe version: {Assembly.GetExecutingAssembly().GetName().Version}");
logger?.Append($"Platform: {CurrentPlatform}");
logger?.Append($"Mono profile: {monoProfile}");
logger?.Append($"Target assembly: {targetAssembly}");
logger?.Append($"Project directory: {projectDir}");
logger?.Append($"Unity 'Data' or 'Frameworks' directory: {unityEditorDataDir}");
if (CurrentPlatform == Platform.Linux)
{
logger?.Append("");
logger?.Append("Platform is not supported");
return -1;
}
var compiler = CreateCompiler(settings.Compiler, logger, CurrentPlatform, monoProfile, projectDir, compilationOptions, unityEditorDataDir);
logger?.Append($"Compiler: {compiler.Name}");
logger?.Append("");
logger?.Append("- Compilation -----------------------------------------------");
logger?.Append("");
var stopwatch = Stopwatch.StartNew();
var exitCode = compiler.Compile(CurrentPlatform, monoProfile, unityEditorDataDir, responseFile);
stopwatch.Stop();
logger?.Append($"Elapsed time: {stopwatch.ElapsedMilliseconds / 1000f:F2} sec");
logger?.Append("");
compiler.PrintCompilerOutputAndErrors();
if (exitCode != 0 || compiler.NeedsPdb2MdbConversion == false)
{
return exitCode;
}
logger?.Append("");
logger?.Append("- PDB to MDB conversion --------------------------------------");
logger?.Append("");
stopwatch.Reset();
stopwatch.Start();
var libraryPath = Path.Combine("Temp", targetAssembly);
compiler.ConvertDebugSymbols(CurrentPlatform, libraryPath, unityEditorDataDir);
stopwatch.Stop();
logger?.Append($"Elapsed time: {stopwatch.ElapsedMilliseconds / 1000f:F2} sec");
logger?.Append("");
compiler.PrintPdb2MdbOutputAndErrors();
return 0;
}
示例2: Compile
private static int Compile(string[] args, Logger logger)
{
logger?.AppendHeader();
var compilationOptions = GetCompilationOptions(args);
var unityEditorDataDir = GetUnityEditorDataDir(compilationOptions);
var targetAssembly = compilationOptions.First(line => line.StartsWith("-out:")).Substring(10);
logger?.Append($"smcs.exe version: {Assembly.GetExecutingAssembly().GetName().Version}");
logger?.Append($"Target assembly: {targetAssembly}");
logger?.Append($"Project directory: {Directory.GetCurrentDirectory()}");
logger?.Append($"Unity directory: {unityEditorDataDir}");
CompilerVersion compilerVersion;
if (Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Roslyn")))
{
compilerVersion = CompilerVersion.Version6Microsoft;
}
else if (File.Exists("mcs.exe"))
{
compilerVersion = CompilerVersion.Version6Mono;
}
else if (compilationOptions.Any(line => line.Contains("AsyncBridge.Net35.dll")))
{
compilerVersion = CompilerVersion.Version5;
}
else
{
compilerVersion = CompilerVersion.Version3;
}
logger?.Append($"Compiler: {compilerVersion}");
logger?.Append("");
logger?.Append("- Compilation -----------------------------------------------");
logger?.Append("");
var stopwatch = Stopwatch.StartNew();
var process = CreateCompilerProcess(compilerVersion, unityEditorDataDir, args[0]);
logger?.Append($"Process: {process.StartInfo.FileName}");
logger?.Append($"Arguments: {process.StartInfo.Arguments}");
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
stopwatch.Stop();
logger?.Append($"Exit code: {process.ExitCode}");
logger?.Append($"Elapsed time: {stopwatch.ElapsedMilliseconds / 1000f:F2} sec");
if (compilerVersion == CompilerVersion.Version6Microsoft)
{
// Microsoft's compiler writes all warnings and errors to the standard output channel,
// so move them to the error channel skipping first 3 lines that are just part of the header.
while (OutputLines.Count > 3)
{
var line = OutputLines[3];
OutputLines.RemoveAt(3);
ErrorLines.Add(line);
}
}
logger?.Append("");
logger?.Append("- Compiler output:");
var lines = from line in OutputLines
let trimmedLine = line?.Trim()
where string.IsNullOrEmpty(trimmedLine) == false
select trimmedLine;
int lineIndex = 0;
foreach (var line in lines)
{
Console.Out.WriteLine(line);
logger?.Append($"{lineIndex++}: {line}");
}
logger?.Append("");
logger?.Append("- Compiler errors:");
lines = from line in ErrorLines
let trimmedLine = line?.Trim()
where string.IsNullOrEmpty(trimmedLine) == false
select trimmedLine;
lineIndex = 0;
foreach (var line in lines)
{
Console.Error.WriteLine(line);
logger?.Append($"{lineIndex++}: {line}");
}
if (process.ExitCode != 0 || compilerVersion != CompilerVersion.Version6Microsoft)
{
return process.ExitCode;
}
logger?.Append("");
//.........这里部分代码省略.........
示例3: FindSuitableCompiler
private static Compiler FindSuitableCompiler(Logger logger, Platform platform, string monoProfile, string projectDir, string[] compilationOptions, string unityEditorDataDir)
{
Compiler compiler = null;
// Looking for Incremental C# 6.0 compiler
var icscDirectory = Path.Combine(projectDir, LANGUAGE_SUPPORT_DIR);
if (Incremental60Compiler.IsAvailable(icscDirectory))
{
compiler = new Incremental60Compiler(logger, icscDirectory);
}
// Looking for Roslyn C# 6.0 compiler
var roslynDirectory = Path.Combine(Path.Combine(projectDir, LANGUAGE_SUPPORT_DIR), "Roslyn");
if (compiler == null && Microsoft60Compiler.IsAvailable(roslynDirectory))
{
compiler = new Microsoft60Compiler(logger, roslynDirectory);
if (platform != Platform.Windows)
{
compiler = null;
logger?.Append("Microsoft C# 6.0 compiler found, but it is not supported on the current platform. Looking for another compiler...");
}
}
if (compiler == null)
{
// Looking for Mono C# 6.0 compiler
var mcsDirectory = Path.Combine(projectDir, LANGUAGE_SUPPORT_DIR);
if (Mono60Compiler.IsAvailable(mcsDirectory))
{
compiler = new Mono60Compiler(logger, mcsDirectory);
}
}
if (compiler == null && compilationOptions.Any(line => line.Contains("AsyncBridge.Net35.dll")))
{
// Using Mono C# 5.0 compiler
var bleedingEdgeCompilerPath = Path.Combine(unityEditorDataDir, @"MonoBleedingEdge/lib/mono/4.5/mcs.exe");
compiler = new Mono50Compiler(logger, bleedingEdgeCompilerPath);
}
if (compiler == null)
{
// Using stock Mono C# 3.0 compiler
var stockCompilerPath = monoProfile == "2.0"
? Path.Combine(unityEditorDataDir, @"Mono/lib/mono/2.0/gmcs.exe")
: Path.Combine(unityEditorDataDir, @"Mono/lib/mono/" + monoProfile + "/smcs.exe");
compiler = new Mono30Compiler(logger, stockCompilerPath);
}
return compiler;
}