forked from icsharpcode/ILSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first attempt at PdbGenerationTestRunner.
- Loading branch information
1 parent
f6aae1f
commit 25c757b
Showing
10 changed files
with
136 additions
and
73 deletions.
There are no files selected for viewing
55 changes: 0 additions & 55 deletions
55
ICSharpCode.Decompiler.Tests/DebugInfo/SequencePointTests.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection.PortableExecutable; | ||
using System.Runtime.CompilerServices; | ||
using System.Xml.Linq; | ||
using ICSharpCode.Decompiler.CSharp; | ||
using ICSharpCode.Decompiler.CSharp.OutputVisitor; | ||
using ICSharpCode.Decompiler.DebugInfo; | ||
using ICSharpCode.Decompiler.Metadata; | ||
using ICSharpCode.Decompiler.Tests.Helpers; | ||
using ICSharpCode.Decompiler.TypeSystem; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.DiaSymReader.Tools; | ||
using NUnit.Framework; | ||
|
||
namespace ICSharpCode.Decompiler.Tests | ||
{ | ||
[TestFixture] | ||
public class PdbGenerationTestRunner | ||
{ | ||
static readonly string TestCasePath = Tester.TestCasePath + "/PdbGen"; | ||
|
||
[Test, Ignore("Needs adjustments in generator")] | ||
public void HelloWorld() | ||
{ | ||
TestGeneratePdb(); | ||
} | ||
|
||
private void TestGeneratePdb([CallerMemberName] string testName = null) | ||
{ | ||
const PdbToXmlOptions options = PdbToXmlOptions.IncludeEmbeddedSources | PdbToXmlOptions.ThrowOnError | PdbToXmlOptions.IncludeTokens | PdbToXmlOptions.ResolveTokens | PdbToXmlOptions.IncludeMethodSpans; | ||
|
||
string xmlFile = Path.Combine(TestCasePath, testName + ".xml"); | ||
string xmlContent = File.ReadAllText(xmlFile); | ||
XDocument document = XDocument.Parse(xmlContent); | ||
var files = document.Descendants("file").ToDictionary(f => f.Attribute("name").Value, f => f.Value); | ||
Tester.CompileCSharpWithPdb(Path.Combine(TestCasePath, testName + ".expected"), files, options); | ||
|
||
string peFileName = Path.Combine(TestCasePath, testName + ".expected.dll"); | ||
string pdbFileName = Path.Combine(TestCasePath, testName + ".expected.pdb"); | ||
var moduleDefinition = new PEFile(peFileName); | ||
var resolver = new UniversalAssemblyResolver(peFileName, false, moduleDefinition.Reader.DetectTargetFrameworkId(), PEStreamOptions.PrefetchEntireImage); | ||
var decompiler = new CSharpDecompiler(moduleDefinition, resolver, new DecompilerSettings()); | ||
using (FileStream pdbStream = File.Open(Path.Combine(TestCasePath, testName + ".pdb"), FileMode.OpenOrCreate, FileAccess.ReadWrite)) { | ||
PortablePdbWriter.WritePdb(moduleDefinition, decompiler, new DecompilerSettings(), pdbStream); | ||
pdbStream.Position = 0; | ||
string resultFile = PdbToXmlConverter.ToXml(pdbStream, moduleDefinition.Reader.GetEntireImage().GetContent().ToArray(), options); | ||
Assert.AreEqual(xmlContent, resultFile); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/*.dll | ||
/*.pdb |
33 changes: 33 additions & 0 deletions
33
ICSharpCode.Decompiler.Tests/TestCases/PdbGen/HelloWorld.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-16"?> | ||
<symbols> | ||
<files> | ||
<file id="1" name="HelloWorld.cs" language="C#" checksumAlgorithm="SHA1" checksum="80-99-0D-B3-EA-B0-A3-72-39-A0-C5-FB-17-13-1B-CC-BF-3D-4C-AA" embeddedSourceLength="200"><![CDATA[using System; | ||
namespace ICSharpCode.Decompiler.Tests.TestCases.PdbGen | ||
{ | ||
public class HelloWorld | ||
{ | ||
public static void Hello() | ||
{ | ||
Console.WriteLine("Hello World!"); | ||
} | ||
} | ||
} | ||
]]></file> | ||
</files> | ||
<methods> | ||
<method containingType="ICSharpCode.Decompiler.Tests.TestCases.PdbGen.HelloWorld" name="Hello" token="0x6000001"> | ||
<sequencePoints> | ||
<entry offset="0x0" startLine="8" startColumn="3" endLine="8" endColumn="4" document="1" /> | ||
<entry offset="0x1" startLine="9" startColumn="4" endLine="9" endColumn="38" document="1" /> | ||
<entry offset="0xc" startLine="10" startColumn="3" endLine="10" endColumn="4" document="1" /> | ||
</sequencePoints> | ||
<scope startOffset="0x0" endOffset="0xd" /> | ||
</method> | ||
</methods> | ||
<method-spans> | ||
<method declaringType="ICSharpCode.Decompiler.Tests.TestCases.PdbGen.HelloWorld" methodName="Hello" token="0x6000001"> | ||
<document startLine="8" endLine="10" /> | ||
</method> | ||
</method-spans> | ||
</symbols> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters