Skip to content

Commit

Permalink
use file scoped namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed May 16, 2024
1 parent 942f581 commit 902a9c6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
// <auto-generated />
//-----------------------------------------------------

namespace Foo
namespace Foo;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
partial class Bar
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
partial class Bar
public TestContext TestContext
{
public TestContext TestContext
{
get => Verifier.CurrentTestContext.Value!;
set => Verifier.CurrentTestContext.Value = value;
}
get => Verifier.CurrentTestContext.Value!;
set => Verifier.CurrentTestContext.Value = value;
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,38 @@
// <auto-generated />
//-----------------------------------------------------

namespace A.B
namespace A.B;
partial class C<T>
{
partial class C<T>
partial class D
{
partial class D
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
partial class TestClass1<U>
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
partial class TestClass1<U>
public TestContext TestContext
{
public TestContext TestContext
{
get => Verifier.CurrentTestContext.Value!;
set => Verifier.CurrentTestContext.Value = value;
}
get => Verifier.CurrentTestContext.Value!;
set => Verifier.CurrentTestContext.Value = value;
}
}
}
}

namespace A.B
namespace A.B;
partial class C<T>
{
partial class C<T>
partial class D
{
partial class D
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
partial class TestClass2
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Verify.MSTest.SourceGenerator", "1.0.0.0")]
partial class TestClass2
public TestContext TestContext
{
public TestContext TestContext
{
get => Verifier.CurrentTestContext.Value!;
set => Verifier.CurrentTestContext.Value = value;
}
get => Verifier.CurrentTestContext.Value!;
set => Verifier.CurrentTestContext.Value = value;
}
}
}
}

}
}
10 changes: 1 addition & 9 deletions src/Verify.MSTest.SourceGenerator/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,10 @@ static void WriteNamespace(IndentedStringBuilder builder, ClassToGenerate classT
{
if (classToGenerate.Namespace is not null)
{
builder.Append("namespace ").AppendLine(classToGenerate.Namespace)
.AppendLine("{")
.IncreaseIndent();
builder.AppendLine($"namespace {classToGenerate.Namespace};");
}

WriteParentTypes(builder, classToGenerate);

if (classToGenerate.Namespace is not null)
{
builder.DecreaseIndent()
.AppendLine("}");
};
}

static void WriteParentTypes(IndentedStringBuilder builder, ClassToGenerate classToGenerate)
Expand Down

0 comments on commit 902a9c6

Please sign in to comment.