+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public static void Generate(SourceProductionContext context, SubclassData subcla
}
private static string ToCode(SubclassData subclassData)
{
return $$"""
namespace {{subclassData.Namespace}};

{{RenderClassHierarchy(subclassData)}}
""";
return subclassData.IsGlobalNamespace
? RenderClassHierarchy(subclassData)
: $"""
namespace {subclassData.Namespace};
{RenderClassHierarchy(subclassData)}
""";
}

private static string RenderClassHierarchy(SubclassData subclassData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ internal sealed record SubclassData(
string Parent,
string ParentHandle,
string Namespace,
bool IsGlobalNamespace,
string Accessibility,
string FileName,
Stack<TypeData> UpperNestedClasses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static IncrementalValuesProvider<SubclassData> GetSubclassValuesProvider(
Parent: parentType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat),
ParentHandle: parentHandle,
Namespace: context.TargetSymbol.ContainingNamespace.ToDisplayString(),
IsGlobalNamespace: context.TargetSymbol.ContainingNamespace.IsGlobalNamespace,
Accessibility: accessibility,
FileName: GetFileName(subclass),
UpperNestedClasses: upperNestedClasses
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[GObject.Subclass<GObject.Object>]
internal partial class SomeGlobalSubClass;
8 changes: 8 additions & 0 deletions src/Tests/Libs/GirTest-0.1.Tests/SubclassIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,34 @@ public void GenericSubclassesShouldBePossible()
var type4 = SomeGenericSubclass<SomeGenericSubclass<string>>.GetGType();
var type5 = SomeSubSubClass.GetGType();
var type6 = SomeContainingClass.SomeNestedGenericSubSubSubClass.GetGType();
var type7 = SomeGlobalSubClass.GetGType();

type1.Should().NotBe(type2);
type1.Should().NotBe(type3);
type1.Should().NotBe(type4);
type1.Should().NotBe(type5);
type1.Should().NotBe(type6);
type1.Should().NotBe(type7);

type2.Should().NotBe(type3);
type2.Should().NotBe(type4);
type2.Should().NotBe(type5);
type2.Should().NotBe(type6);
type2.Should().NotBe(type7);

type3.Should().NotBe(type4);
type3.Should().NotBe(type5);
type3.Should().NotBe(type6);
type3.Should().NotBe(type7);

type4.Should().NotBe(type5);
type4.Should().NotBe(type6);
type4.Should().NotBe(type7);

type5.Should().NotBe(type6);
type5.Should().NotBe(type7);

type6.Should().NotBe(type7);
}
}

Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载