in Nodejs/Product/LogConverter/LogParsing/LogConverter.cs [640:731]
private string CreatePdbFile(out Guid pdbSig, out uint pdbAge)
{
StringBuilder pdbCode = new StringBuilder();
pdbCode.Append("class JavaScriptFunctions {");
int id = 0;
string dllDirectory;
for (;;)
{
dllDirectory = Path.Combine(Path.GetTempPath(), "JavaScriptFunctions_" + id);
id++;
if (!Directory.Exists(dllDirectory))
{
try
{
Directory.CreateDirectory(dllDirectory);
break;
}
catch
{
}
}
}
string dllPath = Path.Combine(dllDirectory, "JavaScriptFunctions.dll");
uint methodToken = 0x06000001;
using (var reader = new StreamReader(_filename))
{
string line;
while ((line = reader.ReadLine()) != null)
{
var records = SplitRecord(line);
if (records.Length == 0)
{
continue;
}
switch (records[0])
{
case "code-creation":
int shift = (_nodeVersion >= v012 ? 1 : 0);
var funcInfo = ExtractNamespaceAndMethodName(records[shift + 4]);
if (funcInfo.LineNumber != null && !string.IsNullOrWhiteSpace(funcInfo.Filename))
{
pdbCode.Append(string.Format(CultureInfo.InvariantCulture, @"
#line {0} ""{1}""
public static void X{2:X}() {{
}}
", funcInfo.LineNumber, funcInfo.Filename, methodToken));
}
else
{
// we need to keep outputting methods just to keep tokens lined up.
pdbCode.Append(string.Format(CultureInfo.InvariantCulture, @"
public static void X{0:X}() {{
}}
", methodToken));
}
methodToken++;
break;
}
}
}
pdbCode.Append("}");
var compiler = CodeDomProvider.GetCompilerInfo("csharp");
var parameters = compiler.CreateDefaultCompilerParameters();
parameters.IncludeDebugInformation = true;
parameters.OutputAssembly = dllPath;
parameters.GenerateExecutable = false;
var res = compiler.CreateProvider().CompileAssemblyFromSource(parameters, pdbCode.ToString());
if (res.Errors.Count > 0)
{
#if DEBUG
var tempPath = Path.GetTempFileName();
File.WriteAllText(tempPath, pdbCode.ToString());
#endif
StringBuilder errors = new StringBuilder("Error while generating symbols:");
foreach (var error in res.Errors)
{
errors.AppendFormat(" {0}", error);
errors.AppendLine();
}
#if DEBUG
Console.WriteLine(errors.ToString());
MessageBox.Show("Code saved to: " + tempPath + Environment.NewLine + errors.ToString());
#endif
}
ReadPdbSigAndAge(dllPath, out pdbSig, out pdbAge);
return dllPath;
}