You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.47
Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
parent
88ff76fe28
commit
e46a49ecf1
@@ -1,10 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\Mono.Cecil.Tests.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}</ProjectGuid>
|
||||
<RootNamespace>Mono.Cecil.Tests</RootNamespace>
|
||||
<AssemblyName>Mono.Cecil.Tests</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="$(NetStandard)">
|
||||
<PackageReference Include="System.Reflection.TypeExtensions">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Diagnostics.Process">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Diagnostics.StackTrace">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Diagnostics.FileVersionInfo">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Runtime.Loader">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp">
|
||||
<Version>2.3.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic">
|
||||
<Version>2.3.2</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Mono.Cecil.csproj">
|
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
|
||||
@@ -26,6 +50,5 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\**\*" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\Mono.Cecil.Tests.props" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition="!$(NetStandard)" />
|
||||
</Project>
|
@@ -59,6 +59,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void Retargetable ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
TestModule ("RetargetableExample.dll", module => {
|
||||
var type = module.Types [1];
|
||||
var property = type.Properties [0];
|
||||
@@ -76,6 +79,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void SystemRuntime ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
TestModule ("System.Runtime.dll", module => {
|
||||
Assert.AreEqual ("System.Runtime", module.Assembly.Name.Name);
|
||||
Assert.AreEqual (1, module.AssemblyReferences.Count);
|
||||
@@ -83,5 +89,19 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.AreEqual (module.AssemblyReferences [0], module.TypeSystem.CoreLibrary);
|
||||
}, verify: !Platform.OnMono);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MismatchedLibraryAndSymbols_DoNotThrow ()
|
||||
{
|
||||
// SQLite-net.dll (from nuget) shiped with mismatched symbol files, but throwIfNoSymbol did not prevent it from throwing
|
||||
var readerParms = new ReaderParameters {
|
||||
ReadSymbols = true,
|
||||
SymbolReaderProvider = new Cil.DefaultSymbolReaderProvider (throwIfNoSymbol: false)
|
||||
};
|
||||
|
||||
using (var module = GetResourceModule ("SQLite-net.dll", readerParms)) {
|
||||
Assert.Null (module.SymbolReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
external/linker/cecil/Test/Mono.Cecil.Tests/CallerMemberNameAttribute.cs
vendored
Normal file
10
external/linker/cecil/Test/Mono.Cecil.Tests/CallerMemberNameAttribute.cs
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
#if NET_3_5 || NET_4_0
|
||||
namespace System.Runtime.CompilerServices {
|
||||
[AttributeUsage (AttributeTargets.Parameter, Inherited = false)]
|
||||
public sealed class CallerMemberNameAttribute : Attribute {
|
||||
public CallerMemberNameAttribute ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -4,9 +4,16 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
|
||||
#if NET_CORE
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Emit;
|
||||
using CS = Microsoft.CodeAnalysis.CSharp;
|
||||
using VB = Microsoft.CodeAnalysis.VisualBasic;
|
||||
#endif
|
||||
|
||||
namespace Mono.Cecil.Tests {
|
||||
|
||||
struct CompilationResult {
|
||||
@@ -22,7 +29,23 @@ namespace Mono.Cecil.Tests {
|
||||
|
||||
public static class Platform {
|
||||
|
||||
public static bool OnMono { get { return typeof (object).Assembly.GetType ("Mono.Runtime") != null; } }
|
||||
public static bool OnMono {
|
||||
get { return TryGetType ("Mono.Runtime") != null; }
|
||||
}
|
||||
|
||||
public static bool OnCoreClr {
|
||||
get { return TryGetType ("System.Runtime.Loader.AssemblyLoadContext, System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") != null; }
|
||||
}
|
||||
|
||||
static Type TryGetType (string assemblyQualifiedName)
|
||||
{
|
||||
try {
|
||||
// Note that throwOnError=false only suppresses some exceptions, not all.
|
||||
return Type.GetType(assemblyQualifiedName, throwOnError: false);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CompilationService {
|
||||
@@ -68,8 +91,11 @@ namespace Mono.Cecil.Tests {
|
||||
return IlasmCompilationService.Instance.Compile (name);
|
||||
|
||||
if (extension == ".cs" || extension == ".vb")
|
||||
#if NET_CORE
|
||||
return RoslynCompilationService.Instance.Compile (name);
|
||||
#else
|
||||
return CodeDomCompilationService.Instance.Compile (name);
|
||||
|
||||
#endif
|
||||
throw new NotSupportedException (extension);
|
||||
}
|
||||
|
||||
@@ -84,9 +110,11 @@ namespace Mono.Cecil.Tests {
|
||||
|
||||
public static void Verify (string name)
|
||||
{
|
||||
#if !NET_CORE
|
||||
var output = Platform.OnMono ? ShellService.PEDump (name) : ShellService.PEVerify (name);
|
||||
if (output.ExitCode != 0)
|
||||
Assert.Fail (output.ToString ());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +140,76 @@ namespace Mono.Cecil.Tests {
|
||||
}
|
||||
}
|
||||
|
||||
#if NET_CORE
|
||||
|
||||
class RoslynCompilationService : CompilationService {
|
||||
|
||||
public static readonly RoslynCompilationService Instance = new RoslynCompilationService ();
|
||||
|
||||
protected override string CompileFile (string name)
|
||||
{
|
||||
var compilation = GetCompilation (name);
|
||||
var outputName = GetCompiledFilePath (name);
|
||||
|
||||
var result = compilation.Emit (outputName);
|
||||
Assert.IsTrue (result.Success, GetErrorMessage (result));
|
||||
|
||||
return outputName;
|
||||
}
|
||||
|
||||
static Compilation GetCompilation (string name)
|
||||
{
|
||||
var assemblyName = Path.GetFileNameWithoutExtension (name);
|
||||
var source = File.ReadAllText (name);
|
||||
|
||||
var tpa = BaseAssemblyResolver.TrustedPlatformAssemblies.Value;
|
||||
|
||||
var references = new []
|
||||
{
|
||||
MetadataReference.CreateFromFile (tpa ["netstandard"]),
|
||||
MetadataReference.CreateFromFile (tpa ["mscorlib"]),
|
||||
MetadataReference.CreateFromFile (tpa ["System.Private.CoreLib"]),
|
||||
MetadataReference.CreateFromFile (tpa ["System.Runtime"]),
|
||||
MetadataReference.CreateFromFile (tpa ["System.Console"]),
|
||||
MetadataReference.CreateFromFile (tpa ["System.Security.AccessControl"]),
|
||||
};
|
||||
|
||||
var extension = Path.GetExtension (name);
|
||||
switch (extension) {
|
||||
case ".cs":
|
||||
return CS.CSharpCompilation.Create (
|
||||
assemblyName,
|
||||
new [] { CS.SyntaxFactory.ParseSyntaxTree (source) },
|
||||
references,
|
||||
new CS.CSharpCompilationOptions (OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release));
|
||||
|
||||
case ".vb":
|
||||
return VB.VisualBasicCompilation.Create (
|
||||
assemblyName,
|
||||
new [] { VB.SyntaxFactory.ParseSyntaxTree (source) },
|
||||
references,
|
||||
new VB.VisualBasicCompilationOptions (OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release));
|
||||
|
||||
default:
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
}
|
||||
|
||||
static string GetErrorMessage (EmitResult result)
|
||||
{
|
||||
if (result.Success)
|
||||
return string.Empty;
|
||||
|
||||
var builder = new StringBuilder ();
|
||||
foreach (var diagnostic in result.Diagnostics)
|
||||
builder.AppendLine (diagnostic.ToString ());
|
||||
|
||||
return builder.ToString ();
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
class CodeDomCompilationService : CompilationService {
|
||||
|
||||
public static readonly CodeDomCompilationService Instance = new CodeDomCompilationService ();
|
||||
@@ -166,6 +264,8 @@ namespace Mono.Cecil.Tests {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
class ShellService {
|
||||
|
||||
public class ProcessOutput {
|
||||
@@ -243,9 +343,13 @@ namespace Mono.Cecil.Tests {
|
||||
|
||||
static string NetFrameworkTool (string tool)
|
||||
{
|
||||
#if NET_CORE
|
||||
return Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Windows), "Microsoft.NET", "Framework", "v4.0.30319", tool + ".exe");
|
||||
#else
|
||||
return Path.Combine (
|
||||
Path.GetDirectoryName (typeof (object).Assembly.Location),
|
||||
tool + ".exe");
|
||||
#endif
|
||||
}
|
||||
|
||||
static string WinSdkTool (string tool)
|
||||
|
@@ -21,15 +21,15 @@ namespace Mono.Cecil.Tests {
|
||||
TestCSharp ("CustomAttributes.cs", module => {
|
||||
var hamster = module.GetType ("Hamster");
|
||||
|
||||
Assert.IsTrue (hamster.HasCustomAttributes);
|
||||
Assert.AreEqual (1, hamster.CustomAttributes.Count);
|
||||
Assert.IsTrue (hamster.HasCustomAttributes);
|
||||
Assert.AreEqual (1, hamster.CustomAttributes.Count);
|
||||
|
||||
var attribute = hamster.CustomAttributes [0];
|
||||
Assert.AreEqual ("System.Void FooAttribute::.ctor(System.String)",
|
||||
attribute.Constructor.FullName);
|
||||
var attribute = hamster.CustomAttributes [0];
|
||||
Assert.AreEqual ("System.Void FooAttribute::.ctor(System.String)",
|
||||
attribute.Constructor.FullName);
|
||||
|
||||
Assert.IsTrue (attribute.HasConstructorArguments);
|
||||
Assert.AreEqual (1, attribute.ConstructorArguments.Count);
|
||||
Assert.IsTrue (attribute.HasConstructorArguments);
|
||||
Assert.AreEqual (1, attribute.ConstructorArguments.Count);
|
||||
|
||||
AssertArgument ("bar", attribute.ConstructorArguments [0]);
|
||||
});
|
||||
@@ -559,10 +559,10 @@ namespace Mono.Cecil.Tests {
|
||||
}
|
||||
|
||||
switch (Type.GetTypeCode (value.GetType ())) {
|
||||
case TypeCode.String:
|
||||
case System.TypeCode.String:
|
||||
signature.AppendFormat ("\"{0}\"", value);
|
||||
break;
|
||||
case TypeCode.Char:
|
||||
case System.TypeCode.Char:
|
||||
signature.AppendFormat ("'{0}'", (char) value);
|
||||
break;
|
||||
default:
|
||||
|
@@ -170,6 +170,7 @@ namespace Mono.Cecil.Tests {
|
||||
}, verify: false);
|
||||
}
|
||||
|
||||
#if !NET_CORE
|
||||
[Test]
|
||||
public void WindowsRuntimeComponentAssembly ()
|
||||
{
|
||||
@@ -181,7 +182,7 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.IsTrue (module.Assembly.Name.IsWindowsRuntime);
|
||||
}, verify: false, assemblyResolver: resolver);
|
||||
}
|
||||
|
||||
#endif
|
||||
[Test]
|
||||
public void DeterministicAssembly ()
|
||||
{
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#if !READ_ONLY
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SR = System.Reflection;
|
||||
@@ -255,6 +254,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void ContextGenericTest ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
var module = ModuleDefinition.ReadModule (typeof (ContextGeneric1Method2<>).Module.FullyQualifiedName);
|
||||
// by mixing open generics with 2 & 1 parameters, we make sure the right context is used (because otherwise, an exception will be thrown)
|
||||
var type = typeof (ContextGeneric1Method2<>).MakeGenericType (typeof (ContextGeneric2Method1<,>));
|
||||
@@ -287,11 +289,10 @@ namespace Mono.Cecil.Tests {
|
||||
|
||||
delegate void Emitter (ModuleDefinition module, MethodBody body);
|
||||
|
||||
[MethodImpl (MethodImplOptions.NoInlining)]
|
||||
static TDelegate Compile<TDelegate> (Emitter emitter)
|
||||
static TDelegate Compile<TDelegate> (Emitter emitter, [CallerMemberName] string testMethodName = null)
|
||||
where TDelegate : class
|
||||
{
|
||||
var name = GetTestCaseName ();
|
||||
var name = "ImportCecil_" + testMethodName;
|
||||
|
||||
var module = CreateTestModule<TDelegate> (name, emitter);
|
||||
var assembly = LoadTestModule (module);
|
||||
@@ -362,15 +363,6 @@ namespace Mono.Cecil.Tests {
|
||||
{
|
||||
return ModuleDefinition.CreateModule (name, ModuleKind.Dll);
|
||||
}
|
||||
|
||||
[MethodImpl (MethodImplOptions.NoInlining)]
|
||||
static string GetTestCaseName ()
|
||||
{
|
||||
var stack_trace = new StackTrace ();
|
||||
var stack_frame = stack_trace.GetFrame (2);
|
||||
|
||||
return "ImportCecil_" + stack_frame.GetMethod ().Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#if !READ_ONLY
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using SR = System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -156,6 +155,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void ImportGenericField ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
var get_field = Compile<Func<Generic<string>, string>> ((module, body) => {
|
||||
var il = body.GetILProcessor ();
|
||||
il.Emit (OpCodes.Ldarg_0);
|
||||
@@ -173,6 +175,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void ImportGenericMethod ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
var generic_identity = Compile<Func<Generic<int>, int, int>> ((module, body) => {
|
||||
var il = body.GetILProcessor ();
|
||||
il.Emit (OpCodes.Ldarg_0);
|
||||
@@ -187,6 +192,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void ImportGenericMethodSpec ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
var gen_spec_id = Compile<Func<Generic<string>, int, int>> ((module, body) => {
|
||||
var il = body.GetILProcessor ();
|
||||
il.Emit (OpCodes.Ldarg_0);
|
||||
@@ -202,6 +210,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void ImportComplexGenericMethodSpec ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
var gen_spec_id = Compile<Func<Generic<string>, int, int>> ((module, body) => {
|
||||
var il = body.GetILProcessor ();
|
||||
il.Emit (OpCodes.Ldarg_0);
|
||||
@@ -279,6 +290,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void ImportGenericFieldFromContext ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
var list_foo = typeof (Foo<>).GetField ("list").FieldType;
|
||||
var generic_list_foo_open = typeof (Generic<>).MakeGenericType (list_foo);
|
||||
var generic_list_foo_open_field = generic_list_foo_open.GetField ("Field");
|
||||
@@ -295,6 +309,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void ImportGenericMethodFromContext ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
var list_foo = typeof (Foo<>).GetField ("list").FieldType;
|
||||
var generic_list_foo_open = typeof (Generic<>).MakeGenericType (list_foo);
|
||||
var generic_list_foo_open_method = generic_list_foo_open.GetMethod ("Method");
|
||||
@@ -334,11 +351,10 @@ namespace Mono.Cecil.Tests {
|
||||
|
||||
delegate void Emitter (ModuleDefinition module, MethodBody body);
|
||||
|
||||
[MethodImpl (MethodImplOptions.NoInlining)]
|
||||
static TDelegate Compile<TDelegate> (Emitter emitter)
|
||||
static TDelegate Compile<TDelegate> (Emitter emitter, [CallerMemberName] string testMethodName = null)
|
||||
where TDelegate : class
|
||||
{
|
||||
var name = GetTestCaseName ();
|
||||
var name = "ImportReflection_" + testMethodName;
|
||||
|
||||
var module = CreateTestModule<TDelegate> (name, emitter);
|
||||
var assembly = LoadTestModule (module);
|
||||
@@ -409,15 +425,6 @@ namespace Mono.Cecil.Tests {
|
||||
{
|
||||
return ModuleDefinition.CreateModule (name, ModuleKind.Dll);
|
||||
}
|
||||
|
||||
[MethodImpl (MethodImplOptions.NoInlining)]
|
||||
static string GetTestCaseName ()
|
||||
{
|
||||
var stack_trace = new StackTrace ();
|
||||
var stack_frame = stack_trace.GetFrame (2);
|
||||
|
||||
return "ImportReflection_" + stack_frame.GetMethod ().Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -204,6 +204,8 @@ namespace Mono.Cecil.Tests {
|
||||
var beta = type.GetMethod ("Beta");
|
||||
var charlie = type.GetMethod ("Charlie");
|
||||
|
||||
// Note that the test depends on the C# compiler emitting the constructor call instruction as
|
||||
// the first instruction of the method body. This requires optimizations to be enabled.
|
||||
var new_list_beta = (MethodReference) beta.Body.Instructions [0].Operand;
|
||||
var new_list_charlie = (MethodReference) charlie.Body.Instructions [0].Operand;
|
||||
|
||||
|
@@ -49,7 +49,10 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void MultiModules ()
|
||||
{
|
||||
TestModule ("mma.exe", module => {
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
TestModule("mma.exe", module => {
|
||||
var assembly = module.Assembly;
|
||||
|
||||
Assert.AreEqual (3, assembly.Modules.Count);
|
||||
@@ -157,6 +160,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void ExportedTypeFromNetModule ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
TestModule ("mma.exe", module => {
|
||||
Assert.IsTrue (module.HasExportedTypes);
|
||||
Assert.AreEqual (2, module.ExportedTypes.Count);
|
||||
@@ -183,14 +189,14 @@ namespace Mono.Cecil.Tests {
|
||||
var exported_type = module.ExportedTypes [0];
|
||||
|
||||
Assert.AreEqual ("System.Diagnostics.DebuggableAttribute", exported_type.FullName);
|
||||
Assert.AreEqual ("mscorlib", exported_type.Scope.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", exported_type.Scope.Name);
|
||||
Assert.IsTrue (exported_type.IsForwarder);
|
||||
|
||||
var nested_exported_type = module.ExportedTypes [1];
|
||||
|
||||
Assert.AreEqual ("System.Diagnostics.DebuggableAttribute/DebuggingModes", nested_exported_type.FullName);
|
||||
Assert.AreEqual (exported_type, nested_exported_type.DeclaringType);
|
||||
Assert.AreEqual ("mscorlib", nested_exported_type.Scope.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", nested_exported_type.Scope.Name);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,7 +205,7 @@ namespace Mono.Cecil.Tests {
|
||||
{
|
||||
TestCSharp ("CustomAttributes.cs", module => {
|
||||
Assert.IsTrue (module.HasTypeReference ("System.Attribute"));
|
||||
Assert.IsTrue (module.HasTypeReference ("mscorlib", "System.Attribute"));
|
||||
Assert.IsTrue (module.HasTypeReference (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", "System.Attribute"));
|
||||
|
||||
Assert.IsFalse (module.HasTypeReference ("System.Core", "System.Attribute"));
|
||||
Assert.IsFalse (module.HasTypeReference ("System.Linq.Enumerable"));
|
||||
@@ -234,10 +240,9 @@ namespace Mono.Cecil.Tests {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (BadImageFormatException))]
|
||||
public void OpenIrrelevantFile ()
|
||||
{
|
||||
GetResourceModule ("text_file.txt");
|
||||
Assert.Throws<BadImageFormatException> (() => GetResourceModule ("text_file.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -273,7 +278,8 @@ namespace Mono.Cecil.Tests {
|
||||
{
|
||||
using (var module = ModuleDefinition.ReadModule (file))
|
||||
{
|
||||
Assert.IsNotNullOrEmpty (module.FileName);
|
||||
Assert.IsNotNull (module.FileName);
|
||||
Assert.IsNotEmpty (module.FileName);
|
||||
Assert.AreEqual (path, module.FileName);
|
||||
}
|
||||
}
|
||||
|
@@ -320,8 +320,15 @@ namespace Mono.Cecil.Tests {
|
||||
|
||||
var state_machine_scope = move_next.CustomDebugInformations.OfType<StateMachineScopeDebugInformation> ().FirstOrDefault ();
|
||||
Assert.IsNotNull (state_machine_scope);
|
||||
Assert.AreEqual (0, state_machine_scope.Start.Offset);
|
||||
Assert.IsTrue (state_machine_scope.End.IsEndOfMethod);
|
||||
Assert.AreEqual (3, state_machine_scope.Scopes.Count);
|
||||
Assert.AreEqual (0, state_machine_scope.Scopes [0].Start.Offset);
|
||||
Assert.IsTrue (state_machine_scope.Scopes [0].End.IsEndOfMethod);
|
||||
|
||||
Assert.AreEqual (0, state_machine_scope.Scopes [1].Start.Offset);
|
||||
Assert.AreEqual (0, state_machine_scope.Scopes [1].End.Offset);
|
||||
|
||||
Assert.AreEqual (184, state_machine_scope.Scopes [2].Start.Offset);
|
||||
Assert.AreEqual (343, state_machine_scope.Scopes [2].End.Offset);
|
||||
|
||||
var async_body = move_next.CustomDebugInformations.OfType<AsyncMethodBodyDebugInformation> ().FirstOrDefault ();
|
||||
Assert.IsNotNull (async_body);
|
||||
@@ -335,7 +342,8 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.AreEqual (91, async_body.Resumes [0].Offset);
|
||||
Assert.AreEqual (252, async_body.Resumes [1].Offset);
|
||||
|
||||
Assert.AreEqual (move_next, async_body.MoveNextMethod);
|
||||
Assert.AreEqual (move_next, async_body.ResumeMethods [0]);
|
||||
Assert.AreEqual (move_next, async_body.ResumeMethods [1]);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,8 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.IsNotNull (definition);
|
||||
|
||||
Assert.AreEqual ("System.String System.String::Empty", definition.FullName);
|
||||
Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib",
|
||||
definition.Module.Assembly.Name.Name);
|
||||
}
|
||||
|
||||
delegate string GetSubstring (string str, int start, int length);
|
||||
@@ -42,7 +43,8 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.IsNotNull (definition);
|
||||
|
||||
Assert.AreEqual ("System.String System.String::Substring(System.Int32,System.Int32)", definition.FullName);
|
||||
Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib",
|
||||
definition.Module.Assembly.Name.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -56,7 +58,8 @@ namespace Mono.Cecil.Tests {
|
||||
|
||||
Assert.AreEqual ("get_Length", definition.Name);
|
||||
Assert.AreEqual ("System.String", definition.DeclaringType.FullName);
|
||||
Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib",
|
||||
definition.Module.Assembly.Name.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -72,7 +75,8 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.IsNotNull (definition);
|
||||
|
||||
Assert.AreEqual ("System.Void System.Collections.Generic.List`1::Add(T)", definition.FullName);
|
||||
Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib",
|
||||
definition.Module.Assembly.Name.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -92,7 +96,8 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.IsNotNull (definition);
|
||||
|
||||
Assert.AreEqual ("System.Boolean System.Collections.Generic.Dictionary`2::TryGetValue(TKey,TValue&)", definition.FullName);
|
||||
Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib",
|
||||
definition.Module.Assembly.Name.Name);
|
||||
}
|
||||
|
||||
class CustomResolver : DefaultAssemblyResolver {
|
||||
@@ -140,7 +145,7 @@ namespace Mono.Cecil.Tests {
|
||||
var definition = reference.Resolve ();
|
||||
Assert.IsNotNull (definition);
|
||||
Assert.AreEqual ("System.Diagnostics.DebuggableAttribute", definition.FullName);
|
||||
Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", definition.Module.Assembly.Name.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -162,7 +167,7 @@ namespace Mono.Cecil.Tests {
|
||||
var definition = reference.Resolve ();
|
||||
Assert.IsNotNull (definition);
|
||||
Assert.AreEqual ("System.Diagnostics.DebuggableAttribute/DebuggingModes", definition.FullName);
|
||||
Assert.AreEqual ("mscorlib", definition.Module.Assembly.Name.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", definition.Module.Assembly.Name.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -175,6 +180,19 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.IsNull (get_a_b.Resolve ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenericRectangularArrayGetMethodInMemberReferences ()
|
||||
{
|
||||
using (var module = GetResourceModule ("FSharp.Core.dll")) {
|
||||
foreach (var member in module.GetMemberReferences ()) {
|
||||
if (!member.DeclaringType.IsArray)
|
||||
continue;
|
||||
|
||||
Assert.IsNull (member.Resolve ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResolveFunctionPointer ()
|
||||
{
|
||||
@@ -223,7 +241,9 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.IsTrue (reference.IsRetargetable);
|
||||
var assembly = resolver.Resolve (reference);
|
||||
Assert.IsNotNull (assembly);
|
||||
Assert.AreEqual (typeof (object).Assembly.GetName ().Version, assembly.Name.Version);
|
||||
|
||||
if (!Platform.OnCoreClr)
|
||||
Assert.AreEqual (typeof (object).Assembly.GetName ().Version, assembly.Name.Version);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -249,10 +249,10 @@ namespace Mono.Cecil.Tests {
|
||||
}
|
||||
|
||||
switch (Type.GetTypeCode (value.GetType ())) {
|
||||
case TypeCode.String:
|
||||
case System.TypeCode.String:
|
||||
signature.AppendFormat ("\"{0}\"", value);
|
||||
break;
|
||||
case TypeCode.Char:
|
||||
case System.TypeCode.Char:
|
||||
signature.AppendFormat ("'{0}'", (char) value);
|
||||
break;
|
||||
default:
|
||||
|
@@ -233,6 +233,9 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void GenericInstanceExternArguments ()
|
||||
{
|
||||
if (Platform.OnCoreClr)
|
||||
return;
|
||||
|
||||
var module = GetCurrentModule ();
|
||||
|
||||
var fullname = string.Format ("System.Collections.Generic.Dictionary`2[[System.Int32, {0}],[System.String, {0}]]",
|
||||
@@ -280,7 +283,7 @@ namespace Mono.Cecil.Tests {
|
||||
var instance = type as GenericInstanceType;
|
||||
Assert.IsNotNull (instance);
|
||||
Assert.AreEqual (2, instance.GenericArguments.Count);
|
||||
Assert.AreEqual ("mscorlib", type.Scope.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Runtime" : "mscorlib", type.Scope.Name);
|
||||
Assert.AreEqual (module, type.Module);
|
||||
Assert.AreEqual ("System.Collections.Generic", type.Namespace);
|
||||
Assert.AreEqual ("Dictionary`2", type.Name);
|
||||
@@ -296,7 +299,7 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.AreEqual ("TypeParserTests", argument.Name);
|
||||
|
||||
argument = instance.GenericArguments [1];
|
||||
Assert.AreEqual ("mscorlib", argument.Scope.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", argument.Scope.Name);
|
||||
Assert.AreEqual (module, argument.Module);
|
||||
Assert.AreEqual ("System", argument.Namespace);
|
||||
Assert.AreEqual ("String", argument.Name);
|
||||
@@ -319,7 +322,7 @@ namespace Mono.Cecil.Tests {
|
||||
var instance = type as GenericInstanceType;
|
||||
Assert.IsNotNull (instance);
|
||||
Assert.AreEqual (2, instance.GenericArguments.Count);
|
||||
Assert.AreEqual ("mscorlib", type.Scope.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", type.Scope.Name);
|
||||
Assert.AreEqual (module, type.Module);
|
||||
Assert.AreEqual ("System.Collections.Generic", type.Namespace);
|
||||
Assert.AreEqual ("Dictionary`2", type.Name);
|
||||
@@ -354,7 +357,7 @@ namespace Mono.Cecil.Tests {
|
||||
var instance = type as GenericInstanceType;
|
||||
Assert.IsNotNull (instance);
|
||||
Assert.AreEqual (2, instance.GenericArguments.Count);
|
||||
Assert.AreEqual ("mscorlib", type.Scope.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Runtime" : "mscorlib", type.Scope.Name);
|
||||
Assert.AreEqual (module, type.Module);
|
||||
Assert.AreEqual ("System.Collections.Generic", type.Namespace);
|
||||
Assert.AreEqual ("Dictionary`2", type.Name);
|
||||
@@ -364,7 +367,7 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.AreEqual (2, type.GenericParameters.Count);
|
||||
|
||||
var argument = instance.GenericArguments [0];
|
||||
Assert.AreEqual ("mscorlib", argument.Scope.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", argument.Scope.Name);
|
||||
Assert.AreEqual (module, argument.Module);
|
||||
Assert.AreEqual ("System", argument.Namespace);
|
||||
Assert.AreEqual ("String", argument.Name);
|
||||
@@ -385,7 +388,7 @@ namespace Mono.Cecil.Tests {
|
||||
Assert.IsInstanceOf (typeof (TypeDefinition), argument);
|
||||
|
||||
argument = instance.GenericArguments [1];
|
||||
Assert.AreEqual ("mscorlib", argument.Scope.Name);
|
||||
Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", argument.Scope.Name);
|
||||
Assert.AreEqual (module, argument.Module);
|
||||
Assert.AreEqual ("System", argument.Namespace);
|
||||
Assert.AreEqual ("Int32", argument.Name);
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
#if !NET_CORE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Win32;
|
||||
@@ -91,3 +93,4 @@ namespace Mono.Cecil.Tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,4 +1,6 @@
|
||||
using NUnit.Framework;
|
||||
#if !NET_CORE
|
||||
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -141,3 +143,4 @@ namespace Mono.Cecil.Tests {
|
||||
protected override string [] CustomListTypeNames { get { return new [] { "CustomList" }; } }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
BIN
external/linker/cecil/Test/Resources/assemblies/SQLite-net.dll.mdb
vendored
Normal file
BIN
external/linker/cecil/Test/Resources/assemblies/SQLite-net.dll.mdb
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user