2020using Silk . NET . SilkTouch . Logging ;
2121using Silk . NET . SilkTouch . Utility ;
2222using static Microsoft . CodeAnalysis . CSharp . SyntaxFactory ;
23- using static Silk . NET . SilkTouch . Utility . KeyedStringTree ;
2423
2524namespace Silk . NET . SilkTouch . Mods
2625{
@@ -149,7 +148,12 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct =
149148 ? compilation . GetSemanticModel ( syntaxTree ! )
150149 : await doc . GetSemanticModelAsync ( ) ;
151150
152- doc = doc . WithSyntaxRoot ( updater . Visit ( root ) . NormalizeWhitespace ( ) ) ;
151+ doc = doc . WithSyntaxRoot ( root = ( updater . Visit ( root ) . NormalizeWhitespace ( ) ) ) ;
152+
153+ if ( doc . FilePath ? . ToLower ( ) . Contains ( "idxgifactory.gen.cs" ) ?? false )
154+ {
155+ File . WriteAllText ( $ "IDXGIFactory.TransformInterface.UsageUpdater.cs", root . ToFullString ( ) ) ;
156+ }
153157
154158 proj = doc . Project ;
155159
@@ -176,7 +180,12 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct =
176180 continue ;
177181 }
178182
179- doc = doc . WithSyntaxRoot ( rewriter . Visit ( root ) . NormalizeWhitespace ( ) ) ;
183+ doc = doc . WithSyntaxRoot ( root = rewriter . Visit ( root ) . NormalizeWhitespace ( ) ) ;
184+
185+ if ( doc . FilePath ? . ToLower ( ) . Contains ( "idxgifactory.gen.cs" ) ?? false )
186+ {
187+ File . WriteAllText ( $ "IDXGIFactory.TransformInterface.Rewriter.cs", root . ToFullString ( ) ) ;
188+ }
180189
181190 proj = doc . Project ;
182191
@@ -437,7 +446,7 @@ typeInfoL.Type is null
437446 return BinaryExpression (
438447 node . Kind ( ) ,
439448 node . Left ,
440- IdentifierName ( $ " { node . Right . ToString ( ) } . lpVtbl")
449+ MemberAccessExpression ( SyntaxKind . SimpleMemberAccessExpression , node . Right , IdentifierName ( " lpVtbl") )
441450 ) ;
442451 }
443452 }
@@ -448,7 +457,7 @@ typeInfoL.Type is null
448457 {
449458 return BinaryExpression (
450459 node . Kind ( ) ,
451- IdentifierName ( $ " { node . Left . ToString ( ) } . lpVtbl") ,
460+ MemberAccessExpression ( SyntaxKind . SimpleMemberAccessExpression , node . Left , IdentifierName ( " lpVtbl") ) ,
452461 node . Right
453462 ) ;
454463 }
@@ -476,7 +485,7 @@ var.Initializer is not null
476485
477486 if ( pointerDepth == 0 )
478487 {
479- return node . WithType ( ParseTypeName ( $ "{ variableType } . Native") ) ;
488+ return node . WithType ( QualifiedName ( IdentifierName ( $ "{ variableType } " ) , IdentifierName ( " Native") ) ) ;
480489 }
481490
482491 var name = GetTypeName ( innerType . ToString ( ) ?? string . Empty ) ;
@@ -531,7 +540,7 @@ variableExpression is not null
531540 {
532541 pointerDepth = GetPointerDepth ( orig . ReturnType , out innerType ) ;
533542 var returnType = shouldEditReturnType
534- ? IdentifierName ( $ "{ innerType } . Native")
543+ ? QualifiedName ( IdentifierName ( $ "{ innerType } " ) , IdentifierName ( " Native") )
535544 : orig . ReturnType ;
536545 if ( shouldEditReturnType )
537546 {
@@ -793,7 +802,7 @@ anc is MethodDeclarationSyntax mds
793802 return
794803 InterfaceTypes . ContainsKey ( name )
795804 && node . Ancestors ( ) . OfType < TypeSyntax > ( ) . Count ( ) > 0
796- ? IdentifierName ( $ " { name } . Native")
805+ ? QualifiedName ( IdentifierName ( name ) , IdentifierName ( " Native") )
797806 : base . VisitIdentifierName ( node ) ;
798807 }
799808
@@ -868,7 +877,7 @@ visitedParameter is null
868877 node . RemoveNodes ( interfaceNodes ?? [ ] , SyntaxRemoveOptions . KeepNoTrivia )
869878 ?? node ;
870879
871- var nativeName = $ " { name } . Native";
880+ var nativeName = QualifiedName ( IdentifierName ( name ) , IdentifierName ( " Native") ) ;
872881
873882 var parentNode = StructDeclaration (
874883 node . AttributeLists ,
@@ -1059,7 +1068,7 @@ mem is MethodDeclarationSyntax
10591068 SyntaxKind . SimpleAssignmentExpression ,
10601069 IdentifierName ( "lpVtbl" ) ,
10611070 CastExpression (
1062- PointerType ( ParseTypeName ( nativeName ) ) ,
1071+ PointerType ( nativeName ) ,
10631072 IdentifierName ( "vtbl" )
10641073 )
10651074 )
@@ -1193,7 +1202,7 @@ mem is MethodDeclarationSyntax
11931202 ParameterList (
11941203 SingletonSeparatedList (
11951204 Parameter ( Identifier ( "vtbl" ) )
1196- . WithType ( ParseTypeName ( $ "Ptr< { nativeName } >" ) )
1205+ . WithType ( GenericName ( Identifier ( "Ptr" ) , TypeArgumentList ( SingletonSeparatedList < TypeSyntax > ( nativeName ) ) ) )
11971206 )
11981207 )
11991208 )
@@ -1333,8 +1342,8 @@ mem is MethodDeclarationSyntax
13331342 parentNode = generateCasts (
13341343 parentNode ,
13351344 name ,
1336- PointerType ( ParseTypeName ( nativeName ) ) ,
1337- nativeName ,
1345+ PointerType ( nativeName ) ,
1346+ nativeName . ToString ( ) ,
13381347 CastExpression ( ParseTypeName ( "Ptr<Native>" ) , IdentifierName ( "value" ) ) ,
13391348 false ,
13401349 true
0 commit comments