@@ -297,7 +297,7 @@ public void CSharpTuple()
297297 var member = GetMethod ( typeof ( NullablesAndTuples ) , m => m . Name == "TupleReturn" ) ;
298298 var formatter = new CSharpFullMemberFormatter ( ) ;
299299 var sig = formatter . GetDeclaration ( member ) ;
300- Assert . AreEqual ( "public (int,string) TupleReturn ();" , sig ) ;
300+ Assert . AreEqual ( "public (int, string) TupleReturn ();" , sig ) ;
301301 }
302302
303303 [ Test ]
@@ -420,6 +420,69 @@ public void CSharpReadOnlyMemberStructTest(string methodName, string expectedSig
420420 Assert . AreEqual ( expectedSignature , methodSignature ) ;
421421 }
422422
423+ [ Test ]
424+ public void CSharpTupleNamesTypeTest ( )
425+ {
426+ var type = GetType ( typeof ( SampleClasses . TupleNamesTestClass < , > ) ) ;
427+ var typeSignature = formatter . GetDeclaration ( type ) ;
428+ Assert . AreEqual ( "public class TupleNamesTestClass<T1,T2> : IComparable<(T1, T2)>" , typeSignature ) ;
429+ }
430+
431+ [ Test ]
432+ public void CSharpTupleNamesPropertyTest ( )
433+ {
434+ var property = GetProperty ( typeof ( SampleClasses . TupleNamesTestClass < , > ) , m => m . Name == "TuplePropertyType" ) ;
435+ var propertySignature = formatter . GetDeclaration ( property ) ;
436+ Assert . AreEqual ( "public (int a, int b) TuplePropertyType { get; }" , propertySignature ) ;
437+ }
438+
439+ [ Test ]
440+ public void CSharpTupleNamesFieldTest ( )
441+ {
442+ var field = GetField ( GetType ( typeof ( SampleClasses . TupleNamesTestClass < , > ) ) , "TupleField" ) ;
443+ var fieldSignature = formatter . GetDeclaration ( field ) ;
444+ Assert . AreEqual ( "public (int a, int b, int c) TupleField;" , fieldSignature ) ;
445+ }
446+
447+ [ TestCase ( "TupleMethod" , "public (int a, int, int b) TupleMethod ((int, int) t1, (int b, int c, int d) t2, (int, int) t3);" ) ]
448+ [ TestCase ( "RecursiveTupleMethod" , "public ((int a, long b) c, int d) RecursiveTupleMethod ((((int a, long) b, string c) d, (int e, (float f, float g) h) i, int j) t);" ) ]
449+ public void CSharpTupleNamesMethodTest ( string methodName , string expectedSignature )
450+ {
451+ var method = GetMethod ( typeof ( SampleClasses . TupleNamesTestClass < , > ) , m => m . Name == methodName ) ;
452+ var methodSignature = formatter . GetDeclaration ( method ) ;
453+ Assert . AreEqual ( expectedSignature , methodSignature ) ;
454+ }
455+
456+ [ TestCase ( "Property1" , "public int Property1 { get; set; }" ) ]
457+ [ TestCase ( "Property2" , "public int Property2 { get; init; }" ) ]
458+ [ TestCase ( "Property3" , "public int Property3 { get; protected init; }" ) ]
459+ [ TestCase ( "Item" , "public int this[int index] { get; init; }" ) ]
460+ public void CSharpInitOnlySetterTest ( string propertyName , string expectedSignature )
461+ {
462+ var property = GetProperty ( typeof ( SampleClasses . InitOnlySetter ) , p => p . Name == propertyName ) ;
463+ var propertySignature = formatter . GetDeclaration ( property ) ;
464+ Assert . AreEqual ( expectedSignature , propertySignature ) ;
465+ }
466+
467+ [ Test ]
468+ public void CSharpNativeIntGenericTypeTest ( )
469+ {
470+ var type = GetType ( typeof ( SampleClasses . GenericNativeIntClass < > ) ) ;
471+ var typeSignature = formatter . GetDeclaration ( type ) ;
472+ Assert . AreEqual ( "public class GenericNativeIntClass<nint>" , typeSignature ) ;
473+ }
474+
475+ [ TestCase ( "Method1" , "public (nint, nuint) Method1 (nint a, nuint b, IntPtr c, UIntPtr d);" ) ]
476+ [ TestCase ( "Method2" , "public (nint, nuint) Method2 (List<nint> a, Dictionary<int,nuint> b);" ) ]
477+ [ TestCase ( "Method3" , "public (nint, nuint) Method3 ((nint, nuint) a, (nuint, IntPtr) b, (UIntPtr, string) c);" ) ]
478+ [ TestCase ( "Method4" , "public (((nint a, IntPtr) b, UIntPtr c) d, (nint e, (nuint f, IntPtr g) h) i) Method4 ();" ) ]
479+ public void CSharpNativeIntMethodTest ( string methodName , string expectedSignature )
480+ {
481+ var method = GetMethod ( typeof ( SampleClasses . NativeIntClass ) , m => m . Name == methodName ) ;
482+ var methodSignature = formatter . GetDeclaration ( method ) ;
483+ Assert . AreEqual ( expectedSignature , methodSignature ) ;
484+ }
485+
423486 #region Helper Methods
424487 string RealTypeName ( string name ) {
425488 switch ( name ) {
0 commit comments