You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
4
external/cecil/symbols/pdb/Test/.gitignore
vendored
4
external/cecil/symbols/pdb/Test/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
bin
|
||||
obj
|
||||
*.xml
|
||||
*.user
|
@@ -1,77 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">net_4_0_Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Mono.Cecil.Pdb.Tests</RootNamespace>
|
||||
<AssemblyName>Mono.Cecil.Pdb.Tests</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_2_0_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\net_2_0_Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_2_0_Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\net_2_0_Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_3_5_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\net_3_5_Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NET_3_5</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_3_5_Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\net_3_5_Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NET_3_5</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_0_Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\net_4_0_Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NET_3_5;NET_4_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net_4_0_Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\net_4_0_Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NET_3_5;NET_4_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(TargetFrameworkVersion)' != 'v2.0' ">
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Mono.Cecil.csproj">
|
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
|
||||
@@ -87,38 +20,11 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Mono.Cecil.Tests\Addin.cs" />
|
||||
<Compile Include="Mono.Cecil.Tests\Linq.cs" />
|
||||
<Compile Include="Mono.Cecil.Tests\PdbTests.cs" />
|
||||
<Compile Include="Mono.Cecil.Tests\*.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\assemblies\fsapp.exe" />
|
||||
<Content Include="Resources\assemblies\fsapp.pdb" />
|
||||
<Content Include="Resources\assemblies\test.exe" />
|
||||
<Content Include="Resources\assemblies\test.pdb" />
|
||||
<Content Include="Resources\assemblies\VBConsApp.exe" />
|
||||
<Content Include="Resources\assemblies\VBConsApp.pdb" />
|
||||
<None Include="Resources\**\*" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.core">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core.interfaces">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.core.interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\Test\libs\nunit-2.6.2\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<Import Project="..\..\..\Mono.Cecil.Tests.props" />
|
||||
<Import Project="$(MSBuildCSharpTargets)" />
|
||||
</Project>
|
@@ -1,8 +0,0 @@
|
||||
using NUnit.Core.Extensibility;
|
||||
|
||||
namespace Mono.Cecil.Tests {
|
||||
|
||||
[NUnitAddin]
|
||||
public class CecilPdbAddin : CecilTestAddin {
|
||||
}
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if !NET_3_5 && !NET_4_0
|
||||
|
||||
namespace System {
|
||||
|
||||
delegate TResult Func<T, TResult> (T t);
|
||||
}
|
||||
|
||||
namespace System.Runtime.CompilerServices {
|
||||
|
||||
[AttributeUsage (AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
|
||||
sealed class ExtensionAttribute : Attribute {
|
||||
}
|
||||
}
|
||||
|
||||
namespace System.Linq {
|
||||
|
||||
static class Enumerable {
|
||||
|
||||
public static IEnumerable<TRet> Select<TItem, TRet> (this IEnumerable<TItem> self, Func<TItem, TRet> selector)
|
||||
{
|
||||
foreach (var item in self)
|
||||
yield return selector (item);
|
||||
}
|
||||
|
||||
public static IEnumerable<T> Where<T> (this IEnumerable<T> self, Func<T, bool> predicate)
|
||||
{
|
||||
foreach (var item in self)
|
||||
if (predicate (item))
|
||||
yield return item;
|
||||
}
|
||||
|
||||
public static T First<T> (this IEnumerable<T> self)
|
||||
{
|
||||
using (var enumerator = self.GetEnumerator ()) {
|
||||
if (!enumerator.MoveNext ())
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
return enumerator.Current;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -12,13 +12,14 @@ namespace Mono.Cecil.Tests {
|
||||
[TestFixture]
|
||||
public class PdbTests : BaseTestFixture {
|
||||
|
||||
[TestModule ("test.exe", SymbolReaderProvider = typeof (PdbReaderProvider), SymbolWriterProvider = typeof (PdbWriterProvider))]
|
||||
public void Main (ModuleDefinition module)
|
||||
[Test]
|
||||
public void Main ()
|
||||
{
|
||||
var type = module.GetType ("Program");
|
||||
var main = type.GetMethod ("Main");
|
||||
TestModule ("test.exe", module => {
|
||||
var type = module.GetType ("Program");
|
||||
var main = type.GetMethod ("Main");
|
||||
|
||||
AssertCode (@"
|
||||
AssertCode (@"
|
||||
.locals init (System.Int32 i, System.Int32 CS$1$0000, System.Boolean CS$4$0001)
|
||||
.line 6,6:2,3 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs'
|
||||
IL_0000: nop
|
||||
@@ -56,70 +57,106 @@ namespace Mono.Cecil.Tests {
|
||||
IL_0020: ldloc.1
|
||||
IL_0021: ret
|
||||
", main);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[TestModule ("test.exe", SymbolReaderProvider = typeof (PdbReaderProvider), SymbolWriterProvider = typeof (PdbWriterProvider))]
|
||||
public void Document (ModuleDefinition module)
|
||||
[Test]
|
||||
public void DebuggerHiddenVariable ()
|
||||
{
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
TestModule ("test.exe", module => {
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
|
||||
var sequence_point = method.Body.Instructions.Where (i => i.SequencePoint != null).First ().SequencePoint;
|
||||
var document = sequence_point.Document;
|
||||
var scope = method.DebugInformation.Scope;
|
||||
|
||||
Assert.IsNotNull (document);
|
||||
Assert.IsTrue (scope.HasVariables);
|
||||
var variables = scope.Variables;
|
||||
|
||||
Assert.AreEqual (@"c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.CSharp, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
Assert.AreEqual ("CS$1$0000", variables [0].Name);
|
||||
Assert.IsTrue (variables [0].IsDebuggerHidden);
|
||||
Assert.AreEqual ("CS$4$0001", variables [1].Name);
|
||||
Assert.IsTrue (variables [1].IsDebuggerHidden);
|
||||
|
||||
Assert.AreEqual (1, scope.Scopes.Count);
|
||||
scope = scope.Scopes [0];
|
||||
variables = scope.Variables;
|
||||
|
||||
Assert.AreEqual ("i", variables [0].Name);
|
||||
Assert.IsFalse (variables [0].IsDebuggerHidden);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[TestModule ("VBConsApp.exe", SymbolReaderProvider = typeof (PdbReaderProvider), SymbolWriterProvider = typeof (PdbWriterProvider))]
|
||||
public void BasicDocument (ModuleDefinition module)
|
||||
|
||||
[Test]
|
||||
public void Document ()
|
||||
{
|
||||
var type = module.GetType ("VBConsApp.Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
TestModule ("test.exe", module => {
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
|
||||
var sequence_point = method.Body.Instructions.Where (i => i.SequencePoint != null).First ().SequencePoint;
|
||||
var document = sequence_point.Document;
|
||||
var sequence_point = method.DebugInformation.SequencePoints.First (sp => sp != null);
|
||||
var document = sequence_point.Document;
|
||||
|
||||
Assert.IsNotNull (document);
|
||||
Assert.IsNotNull (document);
|
||||
|
||||
Assert.AreEqual (@"c:\tmp\VBConsApp\Program.vb", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.Basic, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
Assert.AreEqual (@"c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.CSharp, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[TestModule ("fsapp.exe", SymbolReaderProvider = typeof (PdbReaderProvider), SymbolWriterProvider = typeof (PdbWriterProvider))]
|
||||
public void FSharpDocument (ModuleDefinition module)
|
||||
[Test]
|
||||
public void BasicDocument ()
|
||||
{
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("fact");
|
||||
TestModule ("VBConsApp.exe", module => {
|
||||
var type = module.GetType ("VBConsApp.Program");
|
||||
var method = type.GetMethod ("Main");
|
||||
|
||||
var sequence_point = method.Body.Instructions.Where (i => i.SequencePoint != null).First ().SequencePoint;
|
||||
var document = sequence_point.Document;
|
||||
var sequence_point = method.DebugInformation.SequencePoints.First (sp => sp != null);
|
||||
var document = sequence_point.Document;
|
||||
|
||||
Assert.IsNotNull (document);
|
||||
Assert.IsNotNull (document);
|
||||
|
||||
Assert.AreEqual (@"c:\tmp\fsapp\Program.fs", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.FSharp, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
Assert.AreEqual (@"c:\tmp\VBConsApp\Program.vb", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.Basic, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FSharpDocument ()
|
||||
{
|
||||
TestModule ("fsapp.exe", module => {
|
||||
var type = module.GetType ("Program");
|
||||
var method = type.GetMethod ("fact");
|
||||
|
||||
var sequence_point = method.DebugInformation.SequencePoints.First (sp => sp != null);
|
||||
var document = sequence_point.Document;
|
||||
|
||||
Assert.IsNotNull (document);
|
||||
|
||||
Assert.AreEqual (@"c:\tmp\fsapp\Program.fs", document.Url);
|
||||
Assert.AreEqual (DocumentType.Text, document.Type);
|
||||
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
|
||||
Assert.AreEqual (DocumentLanguage.FSharp, document.Language);
|
||||
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
|
||||
}, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateMethodFromScratch ()
|
||||
{
|
||||
IgnoreOnMono ();
|
||||
|
||||
var module = ModuleDefinition.CreateModule ("Pan", ModuleKind.Dll);
|
||||
var type = new TypeDefinition ("Pin", "Pon", TypeAttributes.Public | TypeAttributes.Abstract | TypeAttributes.Sealed, module.Import (typeof (object)));
|
||||
var type = new TypeDefinition ("Pin", "Pon", TypeAttributes.Public | TypeAttributes.Abstract | TypeAttributes.Sealed, module.ImportReference (typeof (object)));
|
||||
module.Types.Add (type);
|
||||
|
||||
var method = new MethodDefinition ("Pang", MethodAttributes.Public | MethodAttributes.Static, module.Import (typeof (string)));
|
||||
var method = new MethodDefinition ("Pang", MethodAttributes.Public | MethodAttributes.Static, module.ImportReference (typeof (string)));
|
||||
type.Methods.Add (method);
|
||||
|
||||
var body = method.Body;
|
||||
@@ -127,7 +164,7 @@ namespace Mono.Cecil.Tests {
|
||||
body.InitLocals = true;
|
||||
|
||||
var il = body.GetILProcessor ();
|
||||
var temp = new VariableDefinition ("temp", module.Import (typeof (string)));
|
||||
var temp = new VariableDefinition (module.ImportReference (typeof (string)));
|
||||
body.Variables.Add (temp);
|
||||
|
||||
il.Emit (OpCodes.Nop);
|
||||
@@ -136,13 +173,19 @@ namespace Mono.Cecil.Tests {
|
||||
il.Emit (OpCodes.Ldloc, temp);
|
||||
il.Emit (OpCodes.Ret);
|
||||
|
||||
body.Instructions [0].SequencePoint = new SequencePoint (new Document (@"C:\test.cs")) {
|
||||
var sequence_point = new SequencePoint (body.Instructions [0], new Document (@"C:\test.cs")) {
|
||||
StartLine = 0,
|
||||
StartColumn = 0,
|
||||
EndLine = 0,
|
||||
EndColumn = 4,
|
||||
};
|
||||
|
||||
method.DebugInformation.SequencePoints.Add (sequence_point);
|
||||
|
||||
method.DebugInformation.Scope = new ScopeDebugInformation (body.Instructions [0], null) {
|
||||
Variables = { new VariableDebugInformation (temp, "temp") }
|
||||
};
|
||||
|
||||
var file = Path.Combine (Path.GetTempPath (), "Pan.dll");
|
||||
module.Write (file, new WriterParameters {
|
||||
SymbolWriterProvider = new PdbWriterProvider (),
|
||||
@@ -154,22 +197,7 @@ namespace Mono.Cecil.Tests {
|
||||
|
||||
method = module.GetType ("Pin.Pon").GetMethod ("Pang");
|
||||
|
||||
Assert.AreEqual ("temp", method.Body.Variables [0].Name);
|
||||
}
|
||||
|
||||
static void AssertCode (string expected, MethodDefinition method)
|
||||
{
|
||||
Assert.IsTrue (method.HasBody);
|
||||
Assert.IsNotNull (method.Body);
|
||||
|
||||
System.Console.WriteLine (Formatter.FormatMethodBody (method));
|
||||
|
||||
Assert.AreEqual (Normalize (expected), Normalize (Formatter.FormatMethodBody (method)));
|
||||
}
|
||||
|
||||
static string Normalize (string str)
|
||||
{
|
||||
return str.Trim ().Replace ("\r\n", "\n");
|
||||
Assert.AreEqual ("temp", method.DebugInformation.Scope.Variables [0].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
external/cecil/symbols/pdb/Test/Resources/assemblies/PdbTarget.pdb
vendored
Normal file
BIN
external/cecil/symbols/pdb/Test/Resources/assemblies/PdbTarget.pdb
vendored
Normal file
Binary file not shown.
0
external/cecil/symbols/pdb/Test/Resources/assemblies/VBConsApp.pdb
vendored
Executable file → Normal file
0
external/cecil/symbols/pdb/Test/Resources/assemblies/VBConsApp.pdb
vendored
Executable file → Normal file
0
external/cecil/symbols/pdb/Test/Resources/assemblies/fsapp.pdb
vendored
Executable file → Normal file
0
external/cecil/symbols/pdb/Test/Resources/assemblies/fsapp.pdb
vendored
Executable file → Normal file
Reference in New Issue
Block a user