Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
authorTautvydas Žilys <tautvydas.zilys@gmail.com>2020-09-16 01:48:36 +0300
committerGitHub <noreply@github.com>2020-09-16 01:48:36 +0300
commit1e3bbed3ef66b79be7818f6c6ecf2ac639ffeb19 (patch)
treefaa9bd53158a19546066706747c9f3c739251b24 /Test
parente94d04f9196e3bdec9226bcfb89571249f62b6f3 (diff)
Unity's Windows Runtime changes (#394)
* Implemented Windows Runtime projections for implemented interface overrides. * Don't redirect Windows Runtime projected methods on interfaces. * Add additional test cases for Windows Runtime interface projection. * Fix reading interface impl attributes when using immediate reading mode. * Do not project for windows runtime during read. A type will not be fully initialized during read, so don't attempt to project for Windows runtime until after all of the metadata reading is correct. If a type reading for a module is no completed, a call to BinaryRangeSearch in MetadataSystem can fail, because some of the entries in the types array will still be null. * Fix build warnings. * Remove method that got duplicated during a cherry pick. * Fixed an issue with MethodReferenceComparer where it would incorrectly identify two method references to be the same if they had the same declaring types, the same parameter counts and were both unresolvable. * Sync up latest changes to MethodReferenceComparer and TypeReferenceEquality comparer and also add tests for them. * Fix code formatting. * Remove extra char * Style fix Co-authored-by: Ignas Ziberkas <ignas@unity3d.com> Co-authored-by: Josh Peterson <petersonjm1@gmail.com> Co-authored-by: Jb Evain <jb@evain.net>
Diffstat (limited to 'Test')
-rw-r--r--Test/Mono.Cecil.Tests/LoadAssemblyDefinitionForTestsBaseSimple.cs16
-rw-r--r--Test/Mono.Cecil.Tests/MethodReferenceComparerTests.cs135
-rw-r--r--Test/Mono.Cecil.Tests/TypeDefinitionUtils.cs41
-rw-r--r--Test/Mono.Cecil.Tests/TypeReferenceComparisonTests.cs84
-rw-r--r--Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs144
-rw-r--r--Test/Resources/assemblies/NativeWinmd.winmdbin3584 -> 4608 bytes
6 files changed, 420 insertions, 0 deletions
diff --git a/Test/Mono.Cecil.Tests/LoadAssemblyDefinitionForTestsBaseSimple.cs b/Test/Mono.Cecil.Tests/LoadAssemblyDefinitionForTestsBaseSimple.cs
new file mode 100644
index 0000000..5c3b713
--- /dev/null
+++ b/Test/Mono.Cecil.Tests/LoadAssemblyDefinitionForTestsBaseSimple.cs
@@ -0,0 +1,16 @@
+using System.Reflection;
+
+namespace Mono.Cecil.Tests {
+
+ public class LoadAssemblyDefinitionForTestsBaseSimple {
+
+ protected AssemblyDefinition _assembly;
+ protected AssemblyDefinition _mscorlib;
+
+ public void SetupAssemblyDefinitions (Assembly testAssembly)
+ {
+ _assembly = AssemblyDefinition.ReadAssembly (testAssembly.Location);
+ _mscorlib = _assembly.MainModule.TypeSystem.Object.Resolve ().Module.Assembly;
+ }
+ }
+}
diff --git a/Test/Mono.Cecil.Tests/MethodReferenceComparerTests.cs b/Test/Mono.Cecil.Tests/MethodReferenceComparerTests.cs
new file mode 100644
index 0000000..92e5de3
--- /dev/null
+++ b/Test/Mono.Cecil.Tests/MethodReferenceComparerTests.cs
@@ -0,0 +1,135 @@
+using NUnit.Framework;
+using System;
+using System.Linq;
+
+namespace Mono.Cecil.Tests {
+
+ [TestFixture]
+ public class MethodReferenceComparerTests : LoadAssemblyDefinitionForTestsBaseSimple {
+
+ private TypeDefinition _class1;
+ private TypeDefinition _class2;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ SetupAssemblyDefinitions (typeof (MethodReferenceComparerTests).Assembly);
+ _class1 = TypeDefinitionUtils.TypeDefinitionFor (typeof (Class1), _assembly);
+ _class2 = TypeDefinitionUtils.TypeDefinitionFor (typeof (Class2), _assembly);
+ }
+
+ [Test]
+ public void MethodReferenceEqualsMethodDefinition ()
+ {
+ var typeDefinition = TypeDefinitionUtils.TypeDefinitionFor (typeof (Int32), _mscorlib);
+ var method = typeDefinition.Methods.Single (m => m.Name == "GetHashCode");
+ var methodReference = new MethodReference (method.Name, method.ReturnType, method.DeclaringType);
+ methodReference.HasThis = method.HasThis;
+
+ Assert.That (MethodReferenceComparer.AreEqual (method, methodReference), Is.True);
+ }
+
+ [Test]
+ public void VerifyMethodSignatureMatches ()
+ {
+ Assert.IsTrue (CompareSignatures ("MethodWithNoParametersOrReturn"));
+ Assert.IsTrue (CompareSignatures ("GenericMethodWithNoParametersOrReturn"));
+ Assert.IsFalse (CompareSignatures ("MethodWithNoParametersOrReturn", "GenericMethodWithNoParametersOrReturn"));
+
+ Assert.IsTrue (CompareSignatures ("MethodWithIntParameterAndVoidReturn"));
+ }
+
+ [Test]
+ public void VerifySignatureComparisonConsidersStatic ()
+ {
+ Assert.IsTrue (CompareSignatures ("StaticMethodWithNoParametersOrReturn"));
+ Assert.IsTrue (CompareSignatures ("StaticMethodWithNoParametersOrReturn"));
+ Assert.IsFalse (CompareSignatures ("MethodWithNoParametersOrReturn", "StaticMethodWithNoParametersOrReturn"));
+ Assert.IsFalse (CompareSignatures ("GenericMethodWithNoParametersOrReturn", "GenericStaticMethodWithNoParametersOrReturn"));
+ }
+
+ [Test]
+ public void VerifyMethodSignatureWithGenericParameters ()
+ {
+ Assert.IsTrue (CompareSignatures ("GenericMethodWithGenericParameter"));
+ Assert.IsTrue (CompareSignatures ("GenericMethodWithGenericParameterArray"));
+ Assert.IsTrue (CompareSignatures ("GenericMethodWithByReferenceGenericParameter"));
+ Assert.IsTrue (CompareSignatures ("GenericMethodWithGenericInstanceGenericParameter"));
+ }
+
+ [Test]
+ public void VerifyNonResolvableMethodReferencesWithDifferentParameterTypesAreNotEqual ()
+ {
+ var method1 = new MethodReference ("TestMethod", _class1.Module.TypeSystem.Void, _class1);
+ method1.Parameters.Add (new ParameterDefinition (new ByReferenceType (_class1.Module.TypeSystem.Int16)));
+
+ var method2 = new MethodReference ("TestMethod", _class1.Module.TypeSystem.Void, _class1);
+ method2.Parameters.Add (new ParameterDefinition (new ByReferenceType (_class1.Module.TypeSystem.Char)));
+
+ Assert.IsFalse (MethodReferenceComparer.AreEqual (method1, method2));
+ }
+
+ [Test]
+ public void VerifyNonResolvableRecursiveMethodsDontStackOverflow ()
+ {
+ var method1 = new MethodReference ("TestMethod", _class1.Module.TypeSystem.Void, _class1);
+ method1.GenericParameters.Add (new GenericParameter (method1));
+ method1.Parameters.Add (new ParameterDefinition (method1.GenericParameters[0]));
+
+ var method2 = new MethodReference ("TestMethod", _class1.Module.TypeSystem.Void, _class1);
+ method2.GenericParameters.Add (new GenericParameter (method2));
+ method2.Parameters.Add (new ParameterDefinition (method2.GenericParameters[0]));
+
+ Assert.IsTrue (MethodReferenceComparer.AreEqual (method1, method2));
+ }
+
+ bool CompareSignatures (string name)
+ {
+ return CompareSignatures (name, name);
+ }
+
+ bool CompareSignatures (string name1, string name2)
+ {
+ return MethodReferenceComparer.AreSignaturesEqual (GetMethod (_class1, name1), GetMethod (_class2, name2), TypeComparisonMode.SignatureOnly);
+ }
+
+ static MethodDefinition GetMethod (TypeDefinition type, string name)
+ {
+ return type.Methods.Single (m => m.Name == name);
+ }
+
+ class GenericClass<T> {
+
+ }
+
+ class Class1 {
+
+ void MethodWithNoParametersOrReturn () {}
+ void GenericMethodWithNoParametersOrReturn<T> () {}
+ static void StaticMethodWithNoParametersOrReturn () {}
+ static void GenericStaticMethodWithNoParametersOrReturn<T> () {}
+
+ void MethodWithIntParameterAndVoidReturn (int a) {}
+
+ void GenericMethodWithGenericParameter<T> (T t) {}
+ void GenericMethodWithGenericParameterArray<T> (T[] t) {}
+ void GenericMethodWithByReferenceGenericParameter<T> (ref T a) {}
+ void GenericMethodWithGenericInstanceGenericParameter<T> (GenericClass<T> a) {}
+ }
+
+ class Class2 {
+
+ void MethodWithNoParametersOrReturn () {}
+ void GenericMethodWithNoParametersOrReturn<T> () {}
+ static void StaticMethodWithNoParametersOrReturn () {}
+ static void GenericStaticMethodWithNoParametersOrReturn<T> () {}
+
+ void MethodWithIntParameterAndVoidReturn (int a) {}
+
+ void GenericMethodWithGenericParameter<T> (T t) {}
+ void GenericMethodWithGenericParameterArray<T> (T[] t) {}
+ void GenericMethodWithByReferenceGenericParameter<T> (ref T a) {}
+ void GenericMethodWithGenericInstanceGenericParameter<T> (GenericClass<T> a) {}
+ }
+ }
+}
diff --git a/Test/Mono.Cecil.Tests/TypeDefinitionUtils.cs b/Test/Mono.Cecil.Tests/TypeDefinitionUtils.cs
new file mode 100644
index 0000000..7324584
--- /dev/null
+++ b/Test/Mono.Cecil.Tests/TypeDefinitionUtils.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Mono.Cecil {
+
+ public static class TypeDefinitionUtils {
+
+ public static TypeReference TypeDefinitionForGeneric (
+ Type genericType, AssemblyDefinition genericAssemblyDefinition,
+ Type paramterType, AssemblyDefinition parameterAssemblyDefinition)
+ {
+ var paramDefinition = TypeDefinitionUtils.TypeDefinitionFor (paramterType, parameterAssemblyDefinition);
+ var genericDefinition = TypeDefinitionUtils.TypeDefinitionFor (genericType, genericAssemblyDefinition);
+ var genericInstance = new GenericInstanceType (genericDefinition);
+ genericInstance.GenericArguments.Add (paramDefinition);
+ return genericInstance;
+ }
+
+ public static TypeDefinition TypeDefinitionFor (Type type, AssemblyDefinition assemblyDefinition)
+ {
+ var stack = new Stack<string> ();
+ var currentType = type;
+ while (currentType != null) {
+ stack.Push ( (currentType.DeclaringType == null ? currentType.Namespace + "." : "") + currentType.Name);
+ currentType = currentType.DeclaringType;
+ }
+
+ var typeDefinition = assemblyDefinition.MainModule.GetType (stack.Pop ());
+ if (typeDefinition == null)
+ return null;
+
+ while (stack.Count > 0) {
+ var name = stack.Pop ();
+ typeDefinition = typeDefinition.NestedTypes.Single (t => t.Name == name);
+ }
+
+ return typeDefinition;
+ }
+ }
+}
diff --git a/Test/Mono.Cecil.Tests/TypeReferenceComparisonTests.cs b/Test/Mono.Cecil.Tests/TypeReferenceComparisonTests.cs
new file mode 100644
index 0000000..d8332eb
--- /dev/null
+++ b/Test/Mono.Cecil.Tests/TypeReferenceComparisonTests.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using Mono.Cecil;
+using NUnit.Framework;
+
+namespace Mono.Cecil.Tests {
+
+ [TestFixture]
+ public class TypeReferenceComparisonTests : LoadAssemblyDefinitionForTestsBaseSimple {
+
+ [SetUp]
+ public void SetUp ()
+ {
+ SetupAssemblyDefinitions (typeof (TypeReferenceComparisonTests).Assembly);
+ }
+
+ [Test]
+ public void TypeReferenceEqualsTypeDefinition ()
+ {
+ var typeDefinition = TypeDefinitionUtils.TypeDefinitionFor (typeof (Int32), _mscorlib);
+ var typeReference = new TypeReference (typeDefinition.Namespace, typeDefinition.Name, typeDefinition.Module, typeDefinition.Scope);
+
+ Assert.That (TypeReferenceEqualityComparer.AreEqual (typeDefinition, typeReference), Is.True);
+ }
+
+ [Test]
+ public void GenericParametersFromTwoTypesAreNotEqual ()
+ {
+ var listDefinition = TypeDefinitionUtils.TypeDefinitionFor (typeof (List<>), _mscorlib);
+ var stackDefinition = TypeDefinitionUtils.TypeDefinitionFor (typeof (Comparer<>), _mscorlib);
+
+ Assert.That (TypeReferenceEqualityComparer.AreEqual (listDefinition.GenericParameters[0], stackDefinition.GenericParameters[0]), Is.False);
+ }
+
+ [Test]
+ public void ArrayTypesDoNotMatchIfRankIsDifferent ()
+ {
+ var elementType = TypeDefinitionUtils.TypeDefinitionFor (typeof (Int32), _mscorlib);
+
+ Assert.That (TypeReferenceEqualityComparer.AreEqual (new ArrayType (elementType, 1), new ArrayType (elementType, 2)), Is.False, "Two array types with different ranks match, which is not expected.");
+ }
+
+ [Test]
+ public void ArrayTypesDoNotMatchIfElementTypeIsDifferent ()
+ {
+ Assert.That (TypeReferenceEqualityComparer.AreEqual (new ArrayType (TypeDefinitionUtils.TypeDefinitionFor (typeof (Int32), _mscorlib), 1), new ArrayType (TypeDefinitionUtils.TypeDefinitionFor (typeof (Int64), _mscorlib), 1)), Is.False, "Two array types with different element types match, which is not expected.");
+ }
+
+ [Test]
+ public void ArrayTypesWithDifferentRanksToNotMatch ()
+ {
+ var elementType = TypeDefinitionUtils.TypeDefinitionFor (typeof (Int32), _mscorlib);
+
+ Assert.That (TypeReferenceEqualityComparer.AreEqual ( (TypeSpecification) new ArrayType (elementType, 1), (TypeSpecification) new ArrayType (elementType, 2)), Is.False, "Two type specifications that are array types with different ranks match, which is not expected.");
+ }
+
+ [Test]
+ public void GenericInstanceTypeFromTwoTypesAreNotEqual ()
+ {
+ var int32Definition = TypeDefinitionUtils.TypeDefinitionFor (typeof (Int32), _mscorlib);
+ var listDefinition = TypeDefinitionUtils.TypeDefinitionFor (typeof (List<>), _mscorlib);
+ var listGenericInstance = new GenericInstanceType (listDefinition);
+ listGenericInstance.GenericArguments.Add (int32Definition);
+ var stackDefinition = TypeDefinitionUtils.TypeDefinitionFor (typeof (Comparer<>), _mscorlib);
+ var stackGenericInstance = new GenericInstanceType (stackDefinition);
+ stackGenericInstance.GenericArguments.Add (int32Definition);
+
+ Assert.That (TypeReferenceEqualityComparer.AreEqual (listGenericInstance, stackGenericInstance), Is.False);
+ }
+
+ [Test]
+ public void GenericInstanceTypeForSameTypeIsEqual ()
+ {
+ var int32Definition = TypeDefinitionUtils.TypeDefinitionFor (typeof (Int32), _mscorlib);
+ var listDefinition = TypeDefinitionUtils.TypeDefinitionFor (typeof (List<>), _mscorlib);
+ var listGenericInstance = new GenericInstanceType (listDefinition);
+ listGenericInstance.GenericArguments.Add (int32Definition);
+ var listGenericInstance2 = new GenericInstanceType (listDefinition);
+ listGenericInstance2.GenericArguments.Add (int32Definition);
+
+ Assert.That (TypeReferenceEqualityComparer.AreEqual (listGenericInstance, listGenericInstance2), Is.True);
+ }
+ }
+}
diff --git a/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs b/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs
index 9b10fd5..bac85cf 100644
--- a/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs
+++ b/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs
@@ -8,8 +8,10 @@ using System.Linq;
using System.Text;
namespace Mono.Cecil.Tests {
+
[TestFixture]
public abstract class BaseWindowsRuntimeProjectionsTests : BaseTestFixture {
+
protected abstract string ModuleName { get; }
protected abstract MetadataKind ExpectedMetadataKind { get; }
protected abstract string [] ManagedClassTypeNames { get; }
@@ -96,6 +98,7 @@ namespace Mono.Cecil.Tests {
[TestFixture]
public class ManagedWindowsRuntimeProjectionsTests : BaseWindowsRuntimeProjectionsTests {
+
protected override string ModuleName { get { return "ManagedWinmd.winmd"; } }
protected override MetadataKind ExpectedMetadataKind { get { return MetadataKind.ManagedWindowsMetadata; } }
@@ -132,6 +135,7 @@ namespace Mono.Cecil.Tests {
[TestFixture]
public class NativeWindowsRuntimeProjectionsTests : BaseWindowsRuntimeProjectionsTests {
+
protected override string ModuleName { get { return "NativeWinmd.winmd"; } }
protected override MetadataKind ExpectedMetadataKind { get { return MetadataKind.WindowsMetadata; } }
@@ -139,6 +143,146 @@ namespace Mono.Cecil.Tests {
protected override string [] ManagedClassTypeNames { get { return new [] { "ManagedClass" }; } }
protected override string [] CustomListTypeNames { get { return new [] { "CustomList" }; } }
+
+ [Test]
+ public void CanProjectAndRedirectInterfaces ()
+ {
+ if (Platform.OnMono)
+ return;
+
+ TestModule (ModuleName, (module) => {
+ var customListClass = module.Types.Single (t => t.Name == "CustomList");
+ Assert.AreEqual (5, customListClass.Interfaces.Count);
+
+ Assert.AreEqual (1, customListClass.Interfaces[0].CustomAttributes.Count);
+ Assert.AreEqual ("Windows.Foundation.Metadata.DefaultAttribute", customListClass.Interfaces[0].CustomAttributes[0].AttributeType.FullName);
+ Assert.AreEqual ("NativeWinmd.__ICustomListPublicNonVirtuals", customListClass.Interfaces[0].InterfaceType.FullName);
+
+ Assert.AreEqual (0, customListClass.Interfaces[1].CustomAttributes.Count);
+ Assert.AreEqual ("System.Collections.Generic.IList`1<System.Int32>", customListClass.Interfaces[1].InterfaceType.FullName);
+
+ Assert.AreEqual (0, customListClass.Interfaces[2].CustomAttributes.Count);
+ Assert.AreEqual ("System.Collections.Generic.IEnumerable`1<System.Int32>", customListClass.Interfaces[2].InterfaceType.FullName);
+
+ Assert.AreEqual (0, customListClass.Interfaces[3].CustomAttributes.Count);
+ Assert.AreEqual ("Windows.Foundation.Collections.IVector`1<System.Int32>", customListClass.Interfaces[3].InterfaceType.FullName);
+
+ Assert.AreEqual (0, customListClass.Interfaces[4].CustomAttributes.Count);
+ Assert.AreEqual ("Windows.Foundation.Collections.IIterable`1<System.Int32>", customListClass.Interfaces[4].InterfaceType.FullName);
+
+ var customPropertySetClass = module.Types.Single (t => t.Name == "CustomPropertySet");
+ Assert.AreEqual (7, customPropertySetClass.Interfaces.Count);
+
+ Assert.AreEqual (0, customPropertySetClass.Interfaces[0].CustomAttributes.Count);
+ Assert.AreEqual ("Windows.Foundation.Collections.IPropertySet", customPropertySetClass.Interfaces[0].InterfaceType.FullName);
+
+ Assert.AreEqual (1, customPropertySetClass.Interfaces[1].CustomAttributes.Count);
+ Assert.AreEqual ("Windows.Foundation.Metadata.DefaultAttribute", customPropertySetClass.Interfaces[1].CustomAttributes[0].AttributeType.FullName);
+ Assert.AreEqual ("NativeWinmd.__ICustomPropertySetPublicNonVirtuals", customPropertySetClass.Interfaces[1].InterfaceType.FullName);
+
+ Assert.AreEqual (0, customPropertySetClass.Interfaces[2].CustomAttributes.Count);
+ Assert.AreEqual ("Windows.Foundation.Collections.IObservableMap`2<System.String,System.Object>", customPropertySetClass.Interfaces[2].InterfaceType.FullName);
+
+ Assert.AreEqual (0, customPropertySetClass.Interfaces[3].CustomAttributes.Count);
+ Assert.AreEqual ("System.Collections.Generic.IDictionary`2<System.String,System.Object>", customPropertySetClass.Interfaces[3].InterfaceType.FullName);
+
+ Assert.AreEqual (0, customPropertySetClass.Interfaces[4].CustomAttributes.Count);
+ Assert.AreEqual ("System.Collections.Generic.IEnumerable`1<System.Collections.Generic.KeyValuePair`2<System.String,System.Object>>", customPropertySetClass.Interfaces[4].InterfaceType.FullName);
+
+ Assert.AreEqual (0, customPropertySetClass.Interfaces[5].CustomAttributes.Count);
+ Assert.AreEqual ("Windows.Foundation.Collections.IMap`2<System.String,System.Object>", customPropertySetClass.Interfaces[5].InterfaceType.FullName);
+
+ Assert.AreEqual (0, customPropertySetClass.Interfaces[6].CustomAttributes.Count);
+ Assert.AreEqual ("Windows.Foundation.Collections.IIterable`1<System.Collections.Generic.KeyValuePair`2<System.String,System.Object>>", customPropertySetClass.Interfaces[6].InterfaceType.FullName);
+
+ }, verify: false, assemblyResolver: WindowsRuntimeAssemblyResolver.CreateInstance (), applyWindowsRuntimeProjections: true);
+ }
+
+ [Test]
+ public void CanProjectInterfaceMethods ()
+ {
+ if (Platform.OnMono)
+ return;
+
+ TestModule (ModuleName, (module) => {
+ var customListClass = module.Types.Single (t => t.Name == "CustomList");
+ Assert.AreEqual (28, customListClass.Methods.Count);
+ Assert.AreEqual (TypeDefinitionTreatment.RedirectImplementedMethods, customListClass.WindowsRuntimeProjection.Treatment);
+
+ // Verify that projections add implementations for all projected interfaces methods
+ Assert.AreEqual (customListClass.Methods[0].FullName, "System.Void NativeWinmd.CustomList::.ctor()");
+ Assert.AreEqual (customListClass.Methods[1].FullName, "Windows.Foundation.Collections.IIterator`1<System.Int32> NativeWinmd.CustomList::First()");
+ Assert.AreEqual (customListClass.Methods[2].FullName, "System.UInt32 NativeWinmd.CustomList::get_Size()");
+ Assert.AreEqual (customListClass.Methods[3].FullName, "System.Int32 NativeWinmd.CustomList::GetAt(System.UInt32)");
+ Assert.AreEqual (customListClass.Methods[4].FullName, "System.Collections.Generic.IReadOnlyList`1<System.Int32> NativeWinmd.CustomList::GetView()");
+ Assert.AreEqual (customListClass.Methods[5].FullName, "System.Boolean NativeWinmd.CustomList::IndexOf(System.Int32,System.UInt32&)");
+ Assert.AreEqual (customListClass.Methods[6].FullName, "System.Void NativeWinmd.CustomList::SetAt(System.UInt32,System.Int32)");
+ Assert.AreEqual (customListClass.Methods[7].FullName, "System.Void NativeWinmd.CustomList::InsertAt(System.UInt32,System.Int32)");
+ Assert.AreEqual (customListClass.Methods[8].FullName, "System.Void NativeWinmd.CustomList::RemoveAt(System.UInt32)");
+ Assert.AreEqual (customListClass.Methods[9].FullName, "System.Void NativeWinmd.CustomList::Append(System.Int32)");
+ Assert.AreEqual (customListClass.Methods[10].FullName, "System.Void NativeWinmd.CustomList::RemoveAtEnd()");
+ Assert.AreEqual (customListClass.Methods[11].FullName, "System.Void NativeWinmd.CustomList::Clear()");
+ Assert.AreEqual (customListClass.Methods[12].FullName, "System.UInt32 NativeWinmd.CustomList::GetMany(System.UInt32,System.Int32[])");
+ Assert.AreEqual (customListClass.Methods[13].FullName, "System.Void NativeWinmd.CustomList::ReplaceAll(System.Int32[])");
+ Assert.AreEqual (customListClass.Methods[14].FullName, "System.Int32 NativeWinmd.CustomList::get_Item(System.Int32)");
+ Assert.AreEqual (customListClass.Methods[15].FullName, "System.Void NativeWinmd.CustomList::set_Item(System.Int32,System.Int32)");
+ Assert.AreEqual (customListClass.Methods[16].FullName, "System.Int32 NativeWinmd.CustomList::IndexOf(System.Int32)");
+ Assert.AreEqual (customListClass.Methods[17].FullName, "System.Void NativeWinmd.CustomList::Insert(System.Int32,System.Int32)");
+ Assert.AreEqual (customListClass.Methods[18].FullName, "System.Void NativeWinmd.CustomList::RemoveAt(System.Int32)");
+ Assert.AreEqual (customListClass.Methods[19].FullName, "System.Int32 NativeWinmd.CustomList::get_Count()");
+ Assert.AreEqual (customListClass.Methods[20].FullName, "System.Boolean NativeWinmd.CustomList::get_IsReadOnly()");
+ Assert.AreEqual (customListClass.Methods[21].FullName, "System.Void NativeWinmd.CustomList::Add(System.Int32)");
+ Assert.AreEqual (customListClass.Methods[22].FullName, "System.Void NativeWinmd.CustomList::Clear()");
+ Assert.AreEqual (customListClass.Methods[23].FullName, "System.Boolean NativeWinmd.CustomList::Contains(System.Int32)");
+ Assert.AreEqual (customListClass.Methods[24].FullName, "System.Void NativeWinmd.CustomList::CopyTo(System.Int32[],System.Int32)");
+ Assert.AreEqual (customListClass.Methods[25].FullName, "System.Boolean NativeWinmd.CustomList::Remove(System.Int32)");
+ Assert.AreEqual (customListClass.Methods[26].FullName, "System.Collections.Generic.IEnumerator`1<System.Int32> NativeWinmd.CustomList::GetEnumerator()");
+ Assert.AreEqual (customListClass.Methods[27].FullName, "System.Collections.IEnumerator NativeWinmd.CustomList::GetEnumerator()");
+ }, verify: false, assemblyResolver: WindowsRuntimeAssemblyResolver.CreateInstance (), applyWindowsRuntimeProjections: true);
+ }
+
+ [Test]
+ public void CanProjectMethodOverrides ()
+ {
+ if (Platform.OnMono)
+ return;
+
+ TestModule (ModuleName, (module) => {
+ var customListClass = module.Types.Single (t => t.Name == "CustomList");
+
+ for (int i = 1; i < customListClass.Methods.Count; i++)
+ Assert.AreEqual (1, customListClass.Methods[i].Overrides.Count);
+
+ Assert.AreEqual (customListClass.Methods[1].Overrides[0].FullName, "Windows.Foundation.Collections.IIterator`1<!0> Windows.Foundation.Collections.IIterable`1<System.Int32>::First()");
+ Assert.AreEqual (customListClass.Methods[2].Overrides[0].FullName, "System.UInt32 Windows.Foundation.Collections.IVector`1<System.Int32>::get_Size()");
+ Assert.AreEqual (customListClass.Methods[3].Overrides[0].FullName, "!0 Windows.Foundation.Collections.IVector`1<System.Int32>::GetAt(System.UInt32)");
+ Assert.AreEqual (customListClass.Methods[4].Overrides[0].FullName, "System.Collections.Generic.IReadOnlyList`1<!0> Windows.Foundation.Collections.IVector`1<System.Int32>::GetView()");
+ Assert.AreEqual (customListClass.Methods[5].Overrides[0].FullName, "System.Boolean Windows.Foundation.Collections.IVector`1<System.Int32>::IndexOf(!0,System.UInt32&)");
+ Assert.AreEqual (customListClass.Methods[6].Overrides[0].FullName, "System.Void Windows.Foundation.Collections.IVector`1<System.Int32>::SetAt(System.UInt32,!0)");
+ Assert.AreEqual (customListClass.Methods[7].Overrides[0].FullName, "System.Void Windows.Foundation.Collections.IVector`1<System.Int32>::InsertAt(System.UInt32,!0)");
+ Assert.AreEqual (customListClass.Methods[8].Overrides[0].FullName, "System.Void Windows.Foundation.Collections.IVector`1<System.Int32>::RemoveAt(System.UInt32)");
+ Assert.AreEqual (customListClass.Methods[9].Overrides[0].FullName, "System.Void Windows.Foundation.Collections.IVector`1<System.Int32>::Append(!0)");
+ Assert.AreEqual (customListClass.Methods[10].Overrides[0].FullName, "System.Void Windows.Foundation.Collections.IVector`1<System.Int32>::RemoveAtEnd()");
+ Assert.AreEqual (customListClass.Methods[11].Overrides[0].FullName, "System.Void Windows.Foundation.Collections.IVector`1<System.Int32>::Clear()");
+ Assert.AreEqual (customListClass.Methods[12].Overrides[0].FullName, "System.UInt32 Windows.Foundation.Collections.IVector`1<System.Int32>::GetMany(System.UInt32,!0[])");
+ Assert.AreEqual (customListClass.Methods[13].Overrides[0].FullName, "System.Void Windows.Foundation.Collections.IVector`1<System.Int32>::ReplaceAll(!0[])");
+ Assert.AreEqual (customListClass.Methods[14].Overrides[0].FullName, "T System.Collections.Generic.IList`1<System.Int32>::get_Item(System.Int32)");
+ Assert.AreEqual (customListClass.Methods[15].Overrides[0].FullName, "System.Void System.Collections.Generic.IList`1<System.Int32>::set_Item(System.Int32,T)");
+ Assert.AreEqual (customListClass.Methods[16].Overrides[0].FullName, "System.Int32 System.Collections.Generic.IList`1<System.Int32>::IndexOf(T)");
+ Assert.AreEqual (customListClass.Methods[17].Overrides[0].FullName, "System.Void System.Collections.Generic.IList`1<System.Int32>::Insert(System.Int32,T)");
+ Assert.AreEqual (customListClass.Methods[18].Overrides[0].FullName, "System.Void System.Collections.Generic.IList`1<System.Int32>::RemoveAt(System.Int32)");
+ Assert.AreEqual (customListClass.Methods[19].Overrides[0].FullName, "System.Int32 System.Collections.Generic.ICollection`1<System.Int32>::get_Count()");
+ Assert.AreEqual (customListClass.Methods[20].Overrides[0].FullName, "System.Boolean System.Collections.Generic.ICollection`1<System.Int32>::get_IsReadOnly()");
+ Assert.AreEqual (customListClass.Methods[21].Overrides[0].FullName, "System.Void System.Collections.Generic.ICollection`1<System.Int32>::Add(T)");
+ Assert.AreEqual (customListClass.Methods[22].Overrides[0].FullName, "System.Void System.Collections.Generic.ICollection`1<System.Int32>::Clear()");
+ Assert.AreEqual (customListClass.Methods[23].Overrides[0].FullName, "System.Boolean System.Collections.Generic.ICollection`1<System.Int32>::Contains(T)");
+ Assert.AreEqual (customListClass.Methods[24].Overrides[0].FullName, "System.Void System.Collections.Generic.ICollection`1<System.Int32>::CopyTo(T[],System.Int32)");
+ Assert.AreEqual (customListClass.Methods[25].Overrides[0].FullName, "System.Boolean System.Collections.Generic.ICollection`1<System.Int32>::Remove(T)");
+ Assert.AreEqual (customListClass.Methods[26].Overrides[0].FullName, "System.Collections.Generic.IEnumerator`1<T> System.Collections.Generic.IEnumerable`1<System.Int32>::GetEnumerator()");
+ Assert.AreEqual (customListClass.Methods[27].Overrides[0].FullName, "System.Collections.IEnumerator System.Collections.IEnumerable::GetEnumerator()");
+
+ }, verify: false, assemblyResolver: WindowsRuntimeAssemblyResolver.CreateInstance (), applyWindowsRuntimeProjections: true);
+ }
}
}
#endif
diff --git a/Test/Resources/assemblies/NativeWinmd.winmd b/Test/Resources/assemblies/NativeWinmd.winmd
index 53fedff..b6417cf 100644
--- a/Test/Resources/assemblies/NativeWinmd.winmd
+++ b/Test/Resources/assemblies/NativeWinmd.winmd
Binary files differ