Skip to content

Commit

Permalink
component in global namespace works
Browse files Browse the repository at this point in the history
  • Loading branch information
FlurinBruehwilerCMI committed Mar 8, 2024
1 parent 2749261 commit 0b2651f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Flamui.SourceGenerators/BuilderClassGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ public static string Generate(FlamuiComponentSg component)
{
var sb = new SourceBuilder();

sb.AppendFormat("namespace {0};", component.Component.ContainingNamespace.ToDisplayString()).AppendLine();
sb.AppendLine();
if (!component.Component.ContainingNamespace.IsGlobalNamespace)
{
sb.AppendFormat("namespace {0};", component.Component.ContainingNamespace.ToDisplayString()).AppendLine();
sb.AppendLine();
}

sb.Append("public partial struct ");
AppendBuilderName(sb, component.Component);
Expand Down
7 changes: 5 additions & 2 deletions Flamui.SourceGenerators/CreateMethodGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ public static string Generate(FlamuiComponentSg component)
{
var sb = new SourceBuilder();

sb.AppendFormat("namespace {0};", component.Component.ContainingNamespace.ToDisplayString()).AppendLine();
sb.AppendLine();
if (!component.Component.ContainingNamespace.IsGlobalNamespace)
{
sb.AppendFormat("namespace {0};", component.Component.ContainingNamespace.ToDisplayString()).AppendLine();
sb.AppendLine();
}

sb.AppendLine("public static partial class UiExtensions");
sb.AppendLine("{");
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ app.CreateWindow<RootComponent>("Hello World Window");

app.Run();

//ToDo, put this class into a namespace, global namspace doesn't work currently
public class RootComponent : FlamuiComponent
{
public override void Build(Ui ui)
Expand Down

0 comments on commit 0b2651f

Please sign in to comment.