Skip to content

Commit 2a7f36f

Browse files
committed
Extract C# base type printing in CSharpSources.GetBaseClassTypeName.
1 parent 863566e commit 2a7f36f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Generator/Generators/CSharp/CSharpSources.cs

+14-7
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,18 @@ public static bool ShouldGenerateClassNativeField(Class @class)
672672
return @class.IsValueType || !@class.HasBase || !@class.HasRefBase();
673673
}
674674

675+
public virtual string GetBaseClassTypeName(BaseClassSpecifier @base)
676+
{
677+
this.DisableTypeMap(@base.Class);
678+
679+
var typeName = @base.Type.Desugar().Visit(TypePrinter);
680+
681+
foreach (var typeMap in Context.TypeMaps.TypeMaps.Values)
682+
typeMap.IsEnabled = true;
683+
684+
return typeName;
685+
}
686+
675687
public override void GenerateClassSpecifier(Class @class)
676688
{
677689
// private classes must be visible to because the internal structs can be used in dependencies
@@ -707,13 +719,8 @@ public override void GenerateClassSpecifier(Class @class)
707719
foreach (var @base in @class.Bases.Where(b => b.IsGenerated &&
708720
b.IsClass && b.Class.IsGenerated))
709721
{
710-
var typeMaps = new List<System.Type>();
711-
var keys = new List<string>();
712-
this.DisableTypeMap(@base.Class);
713-
var printedBase = @base.Type.Desugar().Visit(TypePrinter);
714-
bases.Add(printedBase.Type);
715-
foreach (var typeMap in Context.TypeMaps.TypeMaps.Values)
716-
typeMap.IsEnabled = true;
722+
var printedBase = GetBaseClassTypeName(@base);
723+
bases.Add(printedBase);
717724
}
718725
}
719726

0 commit comments

Comments
 (0)