@@ -134,8 +134,8 @@ static void EmitCodeForCommonLibrary(TextWriter tw)
134134 tw . WriteLine ( @" .method public newslot virtual abstract static void GenericMethod<U>() {}" ) ;
135135 tw . WriteLine ( @"}" ) ;
136136 tw . WriteLine ( @"" ) ;
137- tw . WriteLine ( @".class public auto ansi GenericStruct`1<T>" ) ;
138- tw . WriteLine ( @" extends[System.Runtime] System.Valuetype " ) ;
137+ tw . WriteLine ( @".class public sealed auto ansi GenericStruct`1<T>" ) ;
138+ tw . WriteLine ( @" extends[System.Runtime] System.ValueType " ) ;
139139 tw . WriteLine ( @"{" ) ;
140140 tw . WriteLine ( @"}" ) ;
141141 }
@@ -319,6 +319,27 @@ void GenerateMethodBody(bool genericMethod)
319319 methodNameToEmit = methodNameToEmit . Substring ( 0 , methodNameToEmit . Length - 3 ) ;
320320 }
321321 implsGenerated . WriteLine ( $ " ldstr \" { methodNameToEmit } \" ") ;
322+ if ( methodNameToEmit . Contains ( "!!0" ) )
323+ {
324+ implsGenerated . WriteLine ( $ " ldstr \" !!0\" ") ;
325+ implsGenerated . WriteLine ( $ " ldtoken !!0") ;
326+ implsGenerated . WriteLine ( $ " call string { CommonCsPrefix } Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)") ;
327+ implsGenerated . WriteLine ( $ " call instance string [System.Runtime]System.String::Replace(string, string)") ;
328+ }
329+ if ( methodNameToEmit . Contains ( "!!1" ) )
330+ {
331+ implsGenerated . WriteLine ( $ " ldstr \" !!1\" ") ;
332+ implsGenerated . WriteLine ( $ " ldtoken !!1") ;
333+ implsGenerated . WriteLine ( $ " call string { CommonCsPrefix } Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)") ;
334+ implsGenerated . WriteLine ( $ " call instance string [System.Runtime]System.String::Replace(string, string)") ;
335+ }
336+ if ( methodNameToEmit . Contains ( "!0" ) )
337+ {
338+ implsGenerated . WriteLine ( $ " ldstr \" !0\" ") ;
339+ implsGenerated . WriteLine ( $ " ldtoken !0") ;
340+ implsGenerated . WriteLine ( $ " call string { CommonCsPrefix } Statics::MakeName(valuetype[System.Runtime]System.RuntimeTypeHandle)") ;
341+ implsGenerated . WriteLine ( $ " call instance string [System.Runtime]System.String::Replace(string, string)") ;
342+ }
322343 if ( genericMethod )
323344 {
324345 implsGenerated . WriteLine ( $ " ldstr \" <\" ") ;
@@ -546,10 +567,22 @@ static void Main(string[] args)
546567
547568 EmitTestMethod ( ) ;
548569
549- string callCommand = $ " call void TestEntrypoint::{ basicTestMethodName } <{ constrainedTypePrefix } { constrainedType } ,string>()";
570+ string callCommand = GetSetBangBang1IfNeeded ( "string" ) + $ " call void TestEntrypoint::{ basicTestMethodName } <{ constrainedTypePrefix } { constrainedType } ,string>()";
550571 if ( scenario . InterfaceType == InterfaceType . GenericOverObject )
551- callCommand = callCommand + Environment . NewLine + $ " call void TestEntrypoint::{ basicTestMethodName } <{ constrainedTypePrefix } { constrainedType } ,object>()";
572+ callCommand = callCommand + Environment . NewLine + GetSetBangBang1IfNeeded ( "object" ) + $ " call void TestEntrypoint::{ basicTestMethodName } <{ constrainedTypePrefix } { constrainedType } ,object>()";
552573 CallTestEntrypoint ( callCommand ) ;
574+
575+ string GetSetBangBang1IfNeeded ( string bangBang1Expected )
576+ {
577+ if ( expectedString . Contains ( "!!1" ) )
578+ {
579+ return $ " ldstr \" { bangBang1Expected } \" " + Environment . NewLine + " stsfld string [GenericContextCommonCs]Statics::BangBang1Param" + Environment . NewLine ;
580+ }
581+ else
582+ {
583+ return "" ;
584+ }
585+ }
553586 break ;
554587 default :
555588 throw new Exception ( "AACLL" ) ;
@@ -589,6 +622,12 @@ void EmitTestMethod()
589622 EmitILToCallActualMethod ( swTestClassMethods ) ;
590623 swTestClassMethods . WriteLine ( $ " ldstr \" { scenario . ToString ( ) } \" ") ;
591624 swTestClassMethods . WriteLine ( $ " ldstr \" { expectedString } \" ") ;
625+ if ( expectedString . Contains ( "!!1" ) )
626+ {
627+ swTestClassMethods . WriteLine ( " ldstr \" !!1\" " ) ;
628+ swTestClassMethods . WriteLine ( " ldsfld string [GenericContextCommonCs]Statics::BangBang1Param" ) ;
629+ swTestClassMethods . WriteLine ( " call instance string [System.Runtime]System.String::Replace(string, string)" ) ;
630+ }
592631 swTestClassMethods . WriteLine ( $ " call void { CommonCsPrefix } Statics::CheckForFailure(string,string)") ;
593632 swTestClassMethods . WriteLine ( $ " ret") ;
594633 twIL = swTestClassMethods ;
0 commit comments