@@ -13,7 +13,7 @@ namespace CppSharp.Generators.CSharp
13
13
{
14
14
public class CSharpTypePrinter : TypePrinter
15
15
{
16
- public string IntPtrType => "global:: System.IntPtr";
16
+ public string IntPtrType => QualifiedType ( " System.IntPtr") ;
17
17
18
18
public BindingContext Context { get ; set ; }
19
19
@@ -25,6 +25,11 @@ public CSharpTypePrinter(BindingContext context)
25
25
Context = context ;
26
26
}
27
27
28
+ public string QualifiedType ( string name )
29
+ {
30
+ return IsGlobalQualifiedScope ? $ "global::{ name } " : name ;
31
+ }
32
+
28
33
public override TypePrinterResult VisitTagType ( TagType tag , TypeQualifiers quals )
29
34
{
30
35
if ( tag . Declaration == null )
@@ -429,7 +434,8 @@ public override TypePrinterResult VisitCILType(CILType type, TypeQualifiers qual
429
434
case TypeCode . String :
430
435
return "string" ;
431
436
}
432
- return $ "global::{ type . Type . FullName } ";
437
+
438
+ return QualifiedType ( type . Type . FullName ) ;
433
439
}
434
440
435
441
public static void GetPrimitiveTypeWidth ( PrimitiveType primitive ,
@@ -545,7 +551,7 @@ public override TypePrinterResult VisitPrimitiveType(PrimitiveType primitive,
545
551
case PrimitiveType . LongDouble : return new TypePrinterResult { Type = "fixed byte" ,
546
552
NameSuffix = $ "[{ Context . TargetInfo . LongDoubleWidth } ]"} ;
547
553
case PrimitiveType . IntPtr : return IntPtrType ;
548
- case PrimitiveType . UIntPtr : return "global:: System.UIntPtr";
554
+ case PrimitiveType . UIntPtr : return QualifiedType ( " System.UIntPtr") ;
549
555
case PrimitiveType . Null : return "void*" ;
550
556
case PrimitiveType . String : return "string" ;
551
557
case PrimitiveType . Float128 : return "__float128" ;
@@ -645,7 +651,7 @@ string GetName(Declaration decl)
645
651
! string . IsNullOrWhiteSpace ( unit . Module . OutputNamespace ) )
646
652
names . Push ( unit . Module . OutputNamespace ) ;
647
653
648
- return $ "global:: { string . Join ( "." , names ) } " ;
654
+ return QualifiedType ( string . Join ( "." , names ) ) ;
649
655
}
650
656
651
657
public override TypePrinterResult VisitParameters ( IEnumerable < Parameter > @params ,
0 commit comments