You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
@@ -1,4 +1,4 @@
|
||||
|
||||
#if !READ_ONLY
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Mono.Cecil.Tests {
|
||||
.line 7,7:8,18 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs'
|
||||
IL_0001: ldc.i4.0
|
||||
IL_0002: stloc.0
|
||||
.line 16707566,16707566:0,0 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs'
|
||||
.line hidden 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs'
|
||||
IL_0003: br.s IL_0012
|
||||
.line 8,8:4,21 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs'
|
||||
IL_0005: ldarg.0
|
||||
@@ -46,7 +46,7 @@ namespace Mono.Cecil.Tests {
|
||||
IL_0015: conv.i4
|
||||
IL_0016: clt
|
||||
IL_0018: stloc.2
|
||||
.line 16707566,16707566:0,0 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs'
|
||||
.line hidden 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs'
|
||||
IL_0019: ldloc.2
|
||||
IL_001a: brtrue.s IL_0005
|
||||
.line 10,10:3,12 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs'
|
||||
@@ -86,7 +86,6 @@ namespace Mono.Cecil.Tests {
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Document ()
|
||||
{
|
||||
@@ -154,6 +153,247 @@ namespace Mono.Cecil.Tests {
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LocalVariables ()
|
||||
{
|
||||
TestModule ("ComplexPdb.dll", module => {
|
||||
var type = module.GetType ("ComplexPdb.Program");
|
||||
var method = type.GetMethod ("Bar");
|
||||
var debug_info = method.DebugInformation;
|
||||
|
||||
Assert.IsNotNull (debug_info.Scope);
|
||||
Assert.IsTrue (debug_info.Scope.HasScopes);
|
||||
Assert.AreEqual (2, debug_info.Scope.Scopes.Count);
|
||||
|
||||
var scope = debug_info.Scope.Scopes [0];
|
||||
|
||||
Assert.IsNotNull (scope);
|
||||
Assert.IsTrue (scope.HasVariables);
|
||||
Assert.AreEqual (1, scope.Variables.Count);
|
||||
|
||||
var variable = scope.Variables [0];
|
||||
|
||||
Assert.AreEqual ("s", variable.Name);
|
||||
Assert.IsFalse (variable.IsDebuggerHidden);
|
||||
Assert.AreEqual (2, variable.Index);
|
||||
|
||||
scope = debug_info.Scope.Scopes [1];
|
||||
|
||||
Assert.IsNotNull (scope);
|
||||
Assert.IsTrue (scope.HasVariables);
|
||||
Assert.AreEqual (1, scope.Variables.Count);
|
||||
|
||||
variable = scope.Variables [0];
|
||||
|
||||
Assert.AreEqual ("s", variable.Name);
|
||||
Assert.IsFalse (variable.IsDebuggerHidden);
|
||||
Assert.AreEqual (3, variable.Index);
|
||||
|
||||
Assert.IsTrue (scope.HasScopes);
|
||||
Assert.AreEqual (1, scope.Scopes.Count);
|
||||
|
||||
scope = scope.Scopes [0];
|
||||
|
||||
Assert.IsNotNull (scope);
|
||||
Assert.IsTrue (scope.HasVariables);
|
||||
Assert.AreEqual (1, scope.Variables.Count);
|
||||
|
||||
variable = scope.Variables [0];
|
||||
|
||||
Assert.AreEqual ("u", variable.Name);
|
||||
Assert.IsFalse (variable.IsDebuggerHidden);
|
||||
Assert.AreEqual (5, variable.Index);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LocalConstants ()
|
||||
{
|
||||
TestModule ("ComplexPdb.dll", module => {
|
||||
var type = module.GetType ("ComplexPdb.Program");
|
||||
var method = type.GetMethod ("Bar");
|
||||
var debug_info = method.DebugInformation;
|
||||
|
||||
Assert.IsNotNull (debug_info.Scope);
|
||||
Assert.IsTrue (debug_info.Scope.HasScopes);
|
||||
Assert.AreEqual (2, debug_info.Scope.Scopes.Count);
|
||||
|
||||
var scope = debug_info.Scope.Scopes [1];
|
||||
|
||||
Assert.IsNotNull (scope);
|
||||
Assert.IsTrue (scope.HasConstants);
|
||||
Assert.AreEqual (2, scope.Constants.Count);
|
||||
|
||||
var constant = scope.Constants [0];
|
||||
|
||||
Assert.AreEqual ("b", constant.Name);
|
||||
Assert.AreEqual (12, constant.Value);
|
||||
Assert.AreEqual (MetadataType.Int32, constant.ConstantType.MetadataType);
|
||||
|
||||
constant = scope.Constants [1];
|
||||
Assert.AreEqual ("c", constant.Name);
|
||||
Assert.AreEqual ((decimal) 74, constant.Value);
|
||||
Assert.AreEqual (MetadataType.ValueType, constant.ConstantType.MetadataType);
|
||||
|
||||
method = type.GetMethod ("Foo");
|
||||
debug_info = method.DebugInformation;
|
||||
|
||||
Assert.IsNotNull (debug_info.Scope);
|
||||
Assert.IsTrue (debug_info.Scope.HasConstants);
|
||||
Assert.AreEqual (4, debug_info.Scope.Constants.Count);
|
||||
|
||||
constant = debug_info.Scope.Constants [0];
|
||||
Assert.AreEqual ("s", constant.Name);
|
||||
Assert.AreEqual ("const string", constant.Value);
|
||||
Assert.AreEqual (MetadataType.String, constant.ConstantType.MetadataType);
|
||||
|
||||
constant = debug_info.Scope.Constants [1];
|
||||
Assert.AreEqual ("f", constant.Name);
|
||||
Assert.AreEqual (1, constant.Value);
|
||||
Assert.AreEqual (MetadataType.Int32, constant.ConstantType.MetadataType);
|
||||
|
||||
constant = debug_info.Scope.Constants [2];
|
||||
Assert.AreEqual ("o", constant.Name);
|
||||
Assert.AreEqual (null, constant.Value);
|
||||
Assert.AreEqual (MetadataType.Object, constant.ConstantType.MetadataType);
|
||||
|
||||
constant = debug_info.Scope.Constants [3];
|
||||
Assert.AreEqual ("u", constant.Name);
|
||||
Assert.AreEqual (null, constant.Value);
|
||||
Assert.AreEqual (MetadataType.String, constant.ConstantType.MetadataType);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportScope ()
|
||||
{
|
||||
TestModule ("ComplexPdb.dll", module => {
|
||||
var type = module.GetType ("ComplexPdb.Program");
|
||||
var method = type.GetMethod ("Bar");
|
||||
var debug_info = method.DebugInformation;
|
||||
|
||||
Assert.IsNotNull (debug_info.Scope);
|
||||
|
||||
var import = debug_info.Scope.Import;
|
||||
Assert.IsNotNull (import);
|
||||
|
||||
Assert.IsTrue (import.HasTargets);
|
||||
Assert.AreEqual (6, import.Targets.Count);
|
||||
var target = import.Targets [0];
|
||||
|
||||
Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind);
|
||||
Assert.AreEqual ("System", target.Namespace);
|
||||
|
||||
target = import.Targets [1];
|
||||
|
||||
Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind);
|
||||
Assert.AreEqual ("System.Collections.Generic", target.Namespace);
|
||||
|
||||
target = import.Targets [2];
|
||||
|
||||
Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind);
|
||||
Assert.AreEqual ("System.Threading.Tasks", target.Namespace);
|
||||
|
||||
target = import.Targets [3];
|
||||
|
||||
Assert.AreEqual (ImportTargetKind.ImportType, target.Kind);
|
||||
Assert.AreEqual ("System.Console", target.Type.FullName);
|
||||
|
||||
target = import.Targets [4];
|
||||
|
||||
Assert.AreEqual (ImportTargetKind.DefineTypeAlias, target.Kind);
|
||||
Assert.AreEqual ("Foo1", target.Alias);
|
||||
Assert.AreEqual ("System.Console", target.Type.FullName);
|
||||
|
||||
target = import.Targets [5];
|
||||
|
||||
Assert.AreEqual (ImportTargetKind.DefineNamespaceAlias, target.Kind);
|
||||
Assert.AreEqual ("Foo2", target.Alias);
|
||||
Assert.AreEqual ("System.Reflection", target.Namespace);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StateMachineKickOff ()
|
||||
{
|
||||
TestModule ("ComplexPdb.dll", module => {
|
||||
var state_machine = module.GetType ("ComplexPdb.Program/<TestAsync>d__2");
|
||||
var move_next = state_machine.GetMethod ("MoveNext");
|
||||
var symbol = move_next.DebugInformation;
|
||||
|
||||
Assert.IsNotNull (symbol);
|
||||
Assert.IsNotNull (symbol.StateMachineKickOffMethod);
|
||||
Assert.AreEqual ("System.Threading.Tasks.Task ComplexPdb.Program::TestAsync()", symbol.StateMachineKickOffMethod.FullName);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Iterators ()
|
||||
{
|
||||
TestModule ("ComplexPdb.dll", module => {
|
||||
var state_machine = module.GetType ("ComplexPdb.Program/<TestAsync>d__2");
|
||||
var move_next = state_machine.GetMethod ("MoveNext");
|
||||
|
||||
Assert.IsTrue (move_next.DebugInformation.HasCustomDebugInformations);
|
||||
Assert.AreEqual (2, move_next.DebugInformation.CustomDebugInformations.Count);
|
||||
|
||||
var state_machine_scope = move_next.DebugInformation.CustomDebugInformations [0] as StateMachineScopeDebugInformation;
|
||||
Assert.IsNotNull (state_machine_scope);
|
||||
Assert.AreEqual (142, state_machine_scope.Start.Offset);
|
||||
Assert.AreEqual (319, state_machine_scope.End.Offset);
|
||||
|
||||
var async_body = move_next.DebugInformation.CustomDebugInformations [1] as AsyncMethodBodyDebugInformation;
|
||||
Assert.IsNotNull (async_body);
|
||||
Assert.AreEqual (-1, async_body.CatchHandler.Offset);
|
||||
|
||||
Assert.AreEqual (2, async_body.Yields.Count);
|
||||
Assert.AreEqual (68, async_body.Yields [0].Offset);
|
||||
Assert.AreEqual (197, async_body.Yields [1].Offset);
|
||||
|
||||
Assert.AreEqual (2, async_body.Resumes.Count);
|
||||
Assert.AreEqual (98, async_body.Resumes [0].Offset);
|
||||
Assert.AreEqual (227, async_body.Resumes [1].Offset);
|
||||
|
||||
Assert.AreEqual (move_next, async_body.MoveNextMethod);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImportsForFirstMethod ()
|
||||
{
|
||||
TestModule ("CecilTest.exe", module => {
|
||||
var type = module.GetType ("CecilTest.Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
|
||||
var debug = method.DebugInformation;
|
||||
var scope = debug.Scope;
|
||||
|
||||
Assert.IsTrue (scope.End.IsEndOfMethod);
|
||||
|
||||
var import = scope.Import;
|
||||
|
||||
Assert.IsNotNull (import);
|
||||
Assert.AreEqual (5, import.Targets.Count);
|
||||
|
||||
var ns = new [] {
|
||||
"System",
|
||||
"System.Collections.Generic",
|
||||
"System.Linq",
|
||||
"System.Text",
|
||||
"System.Threading.Tasks",
|
||||
};
|
||||
|
||||
for (int i = 0; i < import.Targets.Count; i++) {
|
||||
var target = import.Targets [i];
|
||||
|
||||
Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind);
|
||||
Assert.AreEqual (ns [i], target.Namespace);
|
||||
}
|
||||
|
||||
Assert.AreEqual ("System", import.Targets [0].Namespace);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateMethodFromScratch ()
|
||||
{
|
||||
@@ -208,3 +448,4 @@ namespace Mono.Cecil.Tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BIN
external/cecil/symbols/pdb/Test/Resources/assemblies/CecilTest.pdb
vendored
Normal file
BIN
external/cecil/symbols/pdb/Test/Resources/assemblies/CecilTest.pdb
vendored
Normal file
Binary file not shown.
71
external/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.cs
vendored
Normal file
71
external/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.cs
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Console;
|
||||
using Foo1 = System.Console;
|
||||
using Foo2 = System.Reflection;
|
||||
|
||||
namespace ComplexPdb
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private static void Foo()
|
||||
{
|
||||
const string s = "const string";
|
||||
const int f = 1;
|
||||
const object o = null;
|
||||
const string u = null;
|
||||
WriteLine(s);
|
||||
WriteLine(2);
|
||||
}
|
||||
|
||||
private static void Bar(int i)
|
||||
{
|
||||
int result;
|
||||
if (i < 0)
|
||||
{
|
||||
int s = 1;
|
||||
result = s;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int b = 12;
|
||||
const decimal c = 74;
|
||||
int s = -1;
|
||||
result = s + b + (int)c;
|
||||
if (result > b)
|
||||
{
|
||||
int u = result * b;
|
||||
Console.WriteLine(u);
|
||||
}
|
||||
}
|
||||
WriteLine(result);
|
||||
}
|
||||
|
||||
public async Task TestAsync()
|
||||
{
|
||||
WriteLine("Hello1");
|
||||
await Task.Delay(100);
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
WriteLine("Hello2");
|
||||
await Task.Delay(100);
|
||||
WriteLine("Hello3");
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> TestIterator()
|
||||
{
|
||||
WriteLine("Hello1");
|
||||
yield return "Hello1";
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
WriteLine("Hello1");
|
||||
yield return "Hello2";
|
||||
WriteLine("Hello3");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
external/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.pdb
vendored
Normal file
BIN
external/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.pdb
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user