This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
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
86 changes: 86 additions & 0 deletions
86
src/ILCompiler.TypeSystem/tests/ILTestAssembly/Signature.il
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,86 @@ | ||
.class private auto ansi beforefieldinit Atom | ||
extends [CoreTestAssembly]System.Object | ||
{ | ||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
// Code size 8 (0x8) | ||
.maxstack 8 | ||
IL_0000: ldarg.0 | ||
IL_0001: call instance void [CoreTestAssembly]System.Object::.ctor() | ||
IL_0006: nop | ||
IL_0007: ret | ||
} // end of method I::.ctor | ||
|
||
} // end of class Atom | ||
|
||
.class private auto ansi beforefieldinit A`1<U> | ||
extends [CoreTestAssembly]System.Object | ||
{ | ||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
// Code size 8 (0x8) | ||
.maxstack 8 | ||
IL_0000: ldarg.0 | ||
IL_0001: call instance void [CoreTestAssembly]System.Object::.ctor() | ||
IL_0006: nop | ||
IL_0007: ret | ||
} // end of method A`1::.ctor | ||
|
||
} // end of class A`1 | ||
|
||
.class private auto ansi beforefieldinit BaseClass`2<U,T> | ||
extends [CoreTestAssembly]System.Object | ||
{ | ||
.method public hidebysig newslot virtual | ||
instance void Method(!U u, | ||
!T modopt (FooModifier) t) cil managed | ||
{ | ||
// Code size 2 (0x2) | ||
.maxstack 8 | ||
IL_0000: nop | ||
IL_0001: ret | ||
} // end of method BaseClass`2::Method | ||
|
||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
// Code size 8 (0x8) | ||
.maxstack 8 | ||
IL_0000: ldarg.0 | ||
IL_0001: call instance void [CoreTestAssembly]System.Object::.ctor() | ||
IL_0006: nop | ||
IL_0007: ret | ||
} // end of method BaseClass`2::.ctor | ||
|
||
} // end of class BaseClass`2 | ||
|
||
.class private auto ansi beforefieldinit DerivedClass | ||
extends class BaseClass`2<class A`1<class Atom>,class Atom> | ||
{ | ||
.method public hidebysig virtual instance void | ||
Method(class A`1<class Atom> u, | ||
class Atom modopt (FooModifier) t) cil managed | ||
{ | ||
// Code size 2 (0x2) | ||
.maxstack 8 | ||
IL_0000: nop | ||
IL_0001: ret | ||
} // end of method DerivedClass::Method | ||
|
||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
// Code size 8 (0x8) | ||
.maxstack 8 | ||
IL_0000: ldarg.0 | ||
IL_0001: call instance void class BaseClass`2<class A`1<class Atom>,class Atom>::.ctor() | ||
IL_0006: nop | ||
IL_0007: ret | ||
} // end of method DerivedClass::.ctor | ||
|
||
} // end of DerivedClass | ||
|
||
.class public FooModifier { } | ||
.class public BarModifier { } |
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,53 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Internal.IL; | ||
using Internal.TypeSystem; | ||
using Internal.TypeSystem.Ecma; | ||
|
||
using Xunit; | ||
|
||
namespace TypeSystemTests | ||
{ | ||
public class SignatureTests | ||
{ | ||
private TestTypeSystemContext _context; | ||
private ModuleDesc _testModule; | ||
|
||
public SignatureTests() | ||
{ | ||
_context = new TestTypeSystemContext(TargetArchitecture.X64); | ||
var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); | ||
_context.SetSystemModule(systemModule); | ||
|
||
_testModule = _context.GetModuleForSimpleName("ILTestAssembly"); | ||
} | ||
|
||
[Fact] | ||
public void TestSignatureMatches() | ||
{ | ||
MetadataType atomType = _testModule.GetType("", "Atom"); | ||
MetadataType aType = _testModule.GetType("", "A`1"); | ||
MetadataType aOfAtomType = aType.MakeInstantiatedType(new Instantiation(atomType)); | ||
|
||
|
||
MetadataType baseClassType = _testModule.GetType("", "BaseClass`2"); | ||
MethodDesc baseClassMethod = baseClassType.GetMethods().Single(m => string.Equals(m.Name, "Method")); | ||
MethodSignature baseClassMethodSignature = baseClassMethod.Signature; | ||
MethodSignatureBuilder matchingSignatureBuilder = new MethodSignatureBuilder(baseClassMethodSignature); | ||
matchingSignatureBuilder[0] = aOfAtomType; | ||
matchingSignatureBuilder[1] = atomType; | ||
MethodSignature matchingSignature = matchingSignatureBuilder.ToSignature(); | ||
|
||
MetadataType derivedClassType = _testModule.GetType("", "DerivedClass"); | ||
MethodDesc derivedClassMethod = derivedClassType.GetMethods().Single(m => string.Equals(m.Name, "Method")); | ||
MethodSignature derivedClassMethodSignature = derivedClassMethod.Signature; | ||
|
||
Assert.True(matchingSignature.Equals(derivedClassMethodSignature)); | ||
} | ||
} | ||
} |
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