@@ -265,7 +265,7 @@ private string GenericTypeNameExpr() {
265265 if ( ! generic )
266266 return $ "\" { t . FullName } \" ";
267267 if ( t . FullName == "!0[]" )
268- return $ "(string)typeof(T).GetField( \" REFTypeName \" ).GetValue(null ) + \" []\" ";
268+ return $ "REFrameworkNET.TypeName.Get<T>( ) + \" []\" ";
269269 var hierarchy = TypeHandler . NameHierarchy ( t ) ;
270270 int genericCount = 0 ;
271271 var expr = "\" \" " ;
@@ -284,7 +284,7 @@ private string GenericTypeNameExpr() {
284284 for ( int i = 0 ; i < count ; ++ i ) {
285285 if ( i > 0 ) expr += "+ \" ,\" " ;
286286 var genericParamName = GenericNames [ genericCount ++ ] ;
287- expr += $ "+ (string) typeof( { genericParamName } ).GetField( \" REFTypeName \" ).GetValue(null )";
287+ expr += $ "+ REFrameworkNET.TypeName.Get< { genericParamName } >( )";
288288 }
289289 expr += $ "+ \" >\" ";
290290 }
@@ -321,12 +321,16 @@ private void GenerateProperties() {
321321 bool shouldAddStaticKeyword = false ;
322322
323323 if ( property . Value . getter != null ) {
324- var getter = SyntaxFactory . AccessorDeclaration ( SyntaxKind . GetAccessorDeclaration )
325- . AddAttributeLists ( SyntaxFactory . AttributeList ( ) . AddAttributes ( SyntaxFactory . Attribute (
326- SyntaxFactory . ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
327- SyntaxFactory . ParseAttributeArgumentList ( "(" + property . Value . getter . Index . ToString ( ) + ", global::REFrameworkNET.FieldFacadeType.None)" ) )
324+ var getter = AccessorDeclaration ( SyntaxKind . GetAccessorDeclaration ) ;
325+ if ( ! generic ) {
326+ getter = getter . AddAttributeLists (
327+ AttributeList ( )
328+ . AddAttributes ( Attribute (
329+ ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
330+ ParseAttributeArgumentList ( $ "({ property . Value . getter . Index } , global::REFrameworkNET.FieldFacadeType.None)") )
328331 ) ) ;
329-
332+ }
333+
330334 if ( property . Value . getter . IsStatic ( ) ) {
331335 shouldAddStaticKeyword = true ;
332336 }
@@ -359,12 +363,16 @@ private void GenerateProperties() {
359363 }
360364
361365 if ( property . Value . setter != null ) {
362- var setter = SyntaxFactory . AccessorDeclaration ( SyntaxKind . SetAccessorDeclaration )
363- . AddAttributeLists ( SyntaxFactory . AttributeList ( ) . AddAttributes ( SyntaxFactory . Attribute (
364- SyntaxFactory . ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
365- SyntaxFactory . ParseAttributeArgumentList ( "(" + property . Value . setter . Index . ToString ( ) + ", global::REFrameworkNET.FieldFacadeType.None)" ) )
366+ var setter = AccessorDeclaration ( SyntaxKind . SetAccessorDeclaration ) ;
367+ if ( ! generic ) {
368+ setter = setter . AddAttributeLists (
369+ AttributeList ( )
370+ . AddAttributes ( Attribute (
371+ ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
372+ ParseAttributeArgumentList ( $ "({ property . Value . setter . Index } , global::REFrameworkNET.FieldFacadeType.None)") )
366373 ) ) ;
367-
374+ }
375+
368376 if ( property . Value . setter . IsStatic ( ) ) {
369377 shouldAddStaticKeyword = true ;
370378 }
@@ -469,21 +477,24 @@ private void GenerateFields() {
469477 fieldName = fieldName [ 1 ..fieldName . IndexOf ( ">k__" ) ] ;
470478 }
471479
472- // So this is actually going to be made a property with get/set instead of an actual field
473- // 1. Because interfaces can't have fields
474- // 2. Because we don't actually have a concrete reference to the field in our VM, so we'll be a facade for the field
475- var fieldFacadeGetter = SyntaxFactory . AttributeList ( ) . AddAttributes ( SyntaxFactory . Attribute (
476- SyntaxFactory . ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
477- SyntaxFactory . ParseAttributeArgumentList ( "(" + field . Index . ToString ( ) + ", global::REFrameworkNET.FieldFacadeType.Getter)" ) )
478- ) ;
479-
480- var fieldFacadeSetter = SyntaxFactory . AttributeList ( ) . AddAttributes ( SyntaxFactory . Attribute (
481- SyntaxFactory . ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
482- SyntaxFactory . ParseAttributeArgumentList ( "(" + field . Index . ToString ( ) + ", global::REFrameworkNET.FieldFacadeType.Setter)" ) )
483- ) ;
484-
485- AccessorDeclarationSyntax getter = SyntaxFactory . AccessorDeclaration ( SyntaxKind . GetAccessorDeclaration ) . AddAttributeLists ( fieldFacadeGetter ) ;
486- AccessorDeclarationSyntax setter = SyntaxFactory . AccessorDeclaration ( SyntaxKind . SetAccessorDeclaration ) . AddAttributeLists ( fieldFacadeSetter ) ;
480+ AccessorDeclarationSyntax getter = AccessorDeclaration ( SyntaxKind . GetAccessorDeclaration ) ;
481+ AccessorDeclarationSyntax setter = AccessorDeclaration ( SyntaxKind . SetAccessorDeclaration ) ;
482+ if ( ! generic ) {
483+ // So this is actually going to be made a property with get/set instead of an actual field
484+ // 1. Because interfaces can't have fields
485+ // 2. Because we don't actually have a concrete reference to the field in our VM, so we'll be a facade for the field
486+ var fieldFacadeGetter = AttributeList ( )
487+ . AddAttributes ( Attribute (
488+ ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
489+ ParseAttributeArgumentList ( "(" + field . Index . ToString ( ) + ", global::REFrameworkNET.FieldFacadeType.Getter)" ) ) ) ;
490+
491+ var fieldFacadeSetter = AttributeList ( )
492+ . AddAttributes ( Attribute (
493+ ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
494+ ParseAttributeArgumentList ( "(" + field . Index . ToString ( ) + ", global::REFrameworkNET.FieldFacadeType.Setter)" ) ) ) ;
495+ getter = getter . AddAttributeLists ( fieldFacadeGetter ) ;
496+ setter = setter . AddAttributeLists ( fieldFacadeSetter ) ;
497+ }
487498
488499 var propertyDeclaration = SyntaxFactory . PropertyDeclaration ( fieldType , fieldName )
489500 . AddModifiers ( [ SyntaxFactory . Token ( SyntaxKind . PublicKeyword ) ] ) ;
@@ -505,7 +516,7 @@ private void GenerateFields() {
505516 List < StatementSyntax > bodyStatementsSetter = [ ] ;
506517 List < StatementSyntax > bodyStatementsGetter = [ ] ;
507518
508- var instance = field . IsStatic ( )
519+ var instance = field . IsStatic ( )
509520 ? "0"
510521 : "(this as REFrameworkNET.IObject).GetAddress()" ;
511522
@@ -631,12 +642,15 @@ private void GenerateMethods() {
631642
632643 simpleMethodSignature += methodName ;
633644
645+
634646 // Add full method name as a MethodName attribute to the method
635- methodDeclaration = methodDeclaration . AddAttributeLists (
636- SyntaxFactory . AttributeList ( ) . AddAttributes ( SyntaxFactory . Attribute (
637- SyntaxFactory . ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
638- SyntaxFactory . ParseAttributeArgumentList ( "(" + method . GetIndex ( ) . ToString ( ) + ", global::REFrameworkNET.FieldFacadeType.None)" ) ) )
639- ) ;
647+ if ( ! generic ) {
648+ methodDeclaration = methodDeclaration . AddAttributeLists (
649+ AttributeList ( )
650+ . AddAttributes ( Attribute (
651+ ParseName ( "global::REFrameworkNET.Attributes.Method" ) ,
652+ ParseAttributeArgumentList ( "(" + method . GetIndex ( ) . ToString ( ) + ", global::REFrameworkNET.FieldFacadeType.None)" ) ) ) ) ;
653+ }
640654
641655 bool anyOutParams = false ;
642656 List < string > paramNames = [ ] ;
@@ -741,7 +755,7 @@ private void GenerateMethods() {
741755 }
742756
743757 if ( method . IsStatic ( ) || generic ) {
744-
758+
745759 // lets see what happens if we just make it static
746760 if ( method . IsStatic ( ) )
747761 methodDeclaration = methodDeclaration . AddModifiers ( Token ( SyntaxKind . StaticKeyword ) ) ;
0 commit comments