@@ -424,7 +424,7 @@ public override bool VisitClassDecl(Class @class)
424
424
var dict = $@ "global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, {
425
425
printedClass } >" ;
426
426
WriteLine ( "internal static readonly {0} NativeToManagedMap = new {0}();" , dict ) ;
427
- WriteLine ( "protected void*[] __OriginalVTables;" ) ;
427
+ WriteLine ( "protected internal void*[] __OriginalVTables;" ) ;
428
428
}
429
429
PopBlock ( NewLineKind . BeforeNextBlock ) ;
430
430
}
@@ -2272,7 +2272,10 @@ public void GenerateFunction(Function function, string parentName)
2272
2272
2273
2273
public override void GenerateMethodSpecifier ( Method method , Class @class )
2274
2274
{
2275
- if ( method . IsVirtual && ! method . IsGeneratedOverride ( ) && ! method . IsOperator && ! method . IsPure )
2275
+ bool isTemplateMethod = method . Parameters . Any (
2276
+ p => p . Kind == ParameterKind . Extension ) ;
2277
+ if ( method . IsVirtual && ! method . IsGeneratedOverride ( ) &&
2278
+ ! method . IsOperator && ! method . IsPure && ! isTemplateMethod )
2276
2279
Write ( "virtual " ) ;
2277
2280
2278
2281
var isBuiltinOperator = method . IsOperator &&
@@ -2573,11 +2576,19 @@ private string GetVirtualCallDelegate(Method method)
2573
2576
var i = VTables . GetVTableIndex ( @virtual ) ;
2574
2577
int vtableIndex = 0 ;
2575
2578
var @class = ( Class ) method . Namespace ;
2579
+ var thisParam = method . Parameters . Find (
2580
+ p => p . Kind == ParameterKind . Extension ) ;
2581
+ if ( thisParam != null )
2582
+ @class = ( Class ) method . OriginalFunction . Namespace ;
2583
+
2576
2584
if ( Context . ParserOptions . IsMicrosoftAbi )
2577
2585
vtableIndex = @class . Layout . VFTables . IndexOf ( @class . Layout . VFTables . Where (
2578
2586
v => v . Layout . Components . Any ( c => c . Method == @virtual ) ) . First ( ) ) ;
2579
- WriteLine ( "var {0} = *(void**) ((IntPtr) __OriginalVTables[{1}] + {2} * {3});" ,
2580
- Helpers . SlotIdentifier , vtableIndex , i , Context . TargetInfo . PointerWidth / 8 ) ;
2587
+
2588
+ WriteLine ( $@ "var { Helpers . SlotIdentifier } = *(void**) ((IntPtr) {
2589
+ ( thisParam != null ? $ "{ thisParam . Name } ."
2590
+ : string . Empty ) } __OriginalVTables[{ vtableIndex } ] + { i } * {
2591
+ Context . TargetInfo . PointerWidth / 8 } );" ) ;
2581
2592
if ( method . IsDestructor && @class . IsAbstract )
2582
2593
{
2583
2594
WriteLine ( "if ({0} != null)" , Helpers . SlotIdentifier ) ;
0 commit comments