Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ static void EmitCodeForCommonLibrary(TextWriter tw)
tw.WriteLine(@" .method public newslot virtual abstract static void GenericMethod<U>() {}");
tw.WriteLine(@"}");
tw.WriteLine(@"");
tw.WriteLine(@".class public auto ansi GenericStruct`1<T>");
tw.WriteLine(@" extends[System.Runtime] System.Valuetype");
tw.WriteLine(@".class public sealed auto ansi GenericStruct`1<T>");
tw.WriteLine(@" extends[System.Runtime] System.ValueType");
tw.WriteLine(@"{");
tw.WriteLine(@"}");
}
Expand Down Expand Up @@ -319,6 +319,27 @@ void GenerateMethodBody(bool genericMethod)
methodNameToEmit = methodNameToEmit.Substring(0, methodNameToEmit.Length - 3);
}
implsGenerated.WriteLine($" ldstr \"{methodNameToEmit}\"");
if (methodNameToEmit.Contains("!!0"))
{
implsGenerated.WriteLine($" ldstr \"!!0\"");
implsGenerated.WriteLine($" ldtoken !!0");
implsGenerated.WriteLine($" call string {CommonCsPrefix}Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)");
implsGenerated.WriteLine($" call instance string [System.Runtime]System.String::Replace(string, string)");
}
if (methodNameToEmit.Contains("!!1"))
{
implsGenerated.WriteLine($" ldstr \"!!1\"");
implsGenerated.WriteLine($" ldtoken !!1");
implsGenerated.WriteLine($" call string {CommonCsPrefix}Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)");
implsGenerated.WriteLine($" call instance string [System.Runtime]System.String::Replace(string, string)");
}
if (methodNameToEmit.Contains("!0"))
{
implsGenerated.WriteLine($" ldstr \"!0\"");
implsGenerated.WriteLine($" ldtoken !0");
implsGenerated.WriteLine($" call string {CommonCsPrefix}Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)");
implsGenerated.WriteLine($" call instance string [System.Runtime]System.String::Replace(string, string)");
}
if (genericMethod)
{
implsGenerated.WriteLine($" ldstr \"<\"");
Expand Down Expand Up @@ -546,10 +567,22 @@ static void Main(string[] args)

EmitTestMethod();

string callCommand = $" call void TestEntrypoint::{basicTestMethodName}<{constrainedTypePrefix}{constrainedType},string>()";
string callCommand = GetSetBangBang1IfNeeded("string") + $" call void TestEntrypoint::{basicTestMethodName}<{constrainedTypePrefix}{constrainedType},string>()";
if (scenario.InterfaceType == InterfaceType.GenericOverObject)
callCommand = callCommand + Environment.NewLine + $" call void TestEntrypoint::{basicTestMethodName}<{constrainedTypePrefix}{constrainedType},object>()";
callCommand = callCommand + Environment.NewLine + GetSetBangBang1IfNeeded("object") + $" call void TestEntrypoint::{basicTestMethodName}<{constrainedTypePrefix}{constrainedType},object>()";
CallTestEntrypoint(callCommand);

string GetSetBangBang1IfNeeded(string bangBang1Expected)
{
if (expectedString.Contains("!!1"))
{
return $" ldstr \"{bangBang1Expected}\"" + Environment.NewLine + " stsfld string [GenericContextCommonCs]Statics::BangBang1Param" + Environment.NewLine;
}
else
{
return "";
}
}
break;
default:
throw new Exception("AACLL");
Expand Down Expand Up @@ -589,6 +622,12 @@ void EmitTestMethod()
EmitILToCallActualMethod(swTestClassMethods);
swTestClassMethods.WriteLine($" ldstr \"{scenario.ToString()}\"");
swTestClassMethods.WriteLine($" ldstr \"{expectedString}\"");
if (expectedString.Contains("!!1"))
{
swTestClassMethods.WriteLine(" ldstr \"!!1\"");
swTestClassMethods.WriteLine(" ldsfld string [GenericContextCommonCs]Statics::BangBang1Param");
swTestClassMethods.WriteLine(" call instance string [System.Runtime]System.String::Replace(string, string)");
}
swTestClassMethods.WriteLine($" call void {CommonCsPrefix}Statics::CheckForFailure(string,string)");
swTestClassMethods.WriteLine($" ret");
twIL = swTestClassMethods;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
.method public newslot virtual abstract static void GenericMethod<U>() {}
}

.class public auto ansi GenericStruct`1<T>
extends[System.Runtime] System.Valuetype
.class public sealed auto ansi GenericStruct`1<T>
extends[System.Runtime] System.ValueType
{
}
.class public auto ansi NonGenericClass
Expand Down Expand Up @@ -351,6 +351,10 @@
ldtoken class GenericClass`1<!0>
call string [GenericContextCommonCs]Statics::MakeName(valuetype [System.Runtime]System.RuntimeTypeHandle)
ldstr "'IFaceCuriouslyRecurringGeneric`1<class GenericClass`1<!0>>.NormalMethod'"
ldstr "!0"
ldtoken !0
call string [GenericContextCommonCs]Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)
call instance string [System.Runtime]System.String::Replace(string, string)
call string[System.Runtime] System.String::Concat(string, string)
stsfld string [GenericContextCommonCs]Statics::String
ret
Expand All @@ -361,6 +365,10 @@
ldtoken class GenericClass`1<!0>
call string [GenericContextCommonCs]Statics::MakeName(valuetype [System.Runtime]System.RuntimeTypeHandle)
ldstr "'IFaceCuriouslyRecurringGeneric`1<class GenericClass`1<!0>>.GenericMethod'"
ldstr "!0"
ldtoken !0
call string [GenericContextCommonCs]Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)
call instance string [System.Runtime]System.String::Replace(string, string)
ldstr "<"
ldtoken !!0
call string [GenericContextCommonCs]Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)
Expand Down Expand Up @@ -460,6 +468,10 @@
ldtoken valuetype GenericValuetype`1<!0>
call string [GenericContextCommonCs]Statics::MakeName(valuetype [System.Runtime]System.RuntimeTypeHandle)
ldstr "'IFaceCuriouslyRecurringGeneric`1<valuetype GenericValuetype`1<!0>>.NormalMethod'"
ldstr "!0"
ldtoken !0
call string [GenericContextCommonCs]Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)
call instance string [System.Runtime]System.String::Replace(string, string)
call string[System.Runtime] System.String::Concat(string, string)
stsfld string [GenericContextCommonCs]Statics::String
ret
Expand All @@ -470,6 +482,10 @@
ldtoken valuetype GenericValuetype`1<!0>
call string [GenericContextCommonCs]Statics::MakeName(valuetype [System.Runtime]System.RuntimeTypeHandle)
ldstr "'IFaceCuriouslyRecurringGeneric`1<valuetype GenericValuetype`1<!0>>.GenericMethod'"
ldstr "!0"
ldtoken !0
call string [GenericContextCommonCs]Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)
call instance string [System.Runtime]System.String::Replace(string, string)
ldstr "<"
ldtoken !!0
call string [GenericContextCommonCs]Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ public static class Statics
public static string String;
public static int Failures;
public static int Successes;
public static string BangBang1Param = "string";
public static volatile IntPtr FtnHolder;
public static volatile Action ActionHolder;

public static void CheckForFailure(string scenario, string expectedResult, string actualResult)
{
if (expectedResult != actualResult)
{
Console.WriteLine($"Scenario {scenario} failed - expected {expectedResult ?? "<null>"}, got {actualResult ?? "<null>"}");
Console.WriteLine($"FAILURE({Failures}) - Scenario {scenario} failed - expected {expectedResult ?? "<null>"}, got {actualResult ?? "<null>"}");
Failures++;
}
else
{
Console.WriteLine($"Scenario {scenario} succeeded ({expectedResult ?? "<null>"})");
Console.WriteLine($"Scenario {scenario} succeeded ({expectedResult ?? "<null>"}) Success ({Successes})");
Successes++;
}
}
Expand Down
Loading