diff --git a/.chronus/changes/csharp-spacing-2024-8-24-11-22-26.md b/.chronus/changes/csharp-spacing-2024-8-24-11-22-26.md new file mode 100644 index 0000000..8dd9285 --- /dev/null +++ b/.chronus/changes/csharp-spacing-2024-8-24-11-22-26.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@alloy-js/csharp" +--- + +add extra new-lines to improve readability \ No newline at end of file diff --git a/packages/csharp/src/components/SourceFile.tsx b/packages/csharp/src/components/SourceFile.tsx index 3dd99de..00bbee7 100644 --- a/packages/csharp/src/components/SourceFile.tsx +++ b/packages/csharp/src/components/SourceFile.tsx @@ -54,13 +54,13 @@ export function SourceFile(props: SourceFileProps) { {using.length > 0 ? ( <> - {"\n"} + {"\n\n"} - ) : undefined}namespace {namespaceCtx.name}{!props.children && " {}"}{props.children && + ) : undefined}namespace {namespaceCtx.name}{!props.children && " {}\n"}{props.children && <> {"\n{"} {props.children} - {"}"} + {"}\n"} } diff --git a/packages/csharp/test/class.test.tsx b/packages/csharp/test/class.test.tsx index 127f3d8..0bab8da 100644 --- a/packages/csharp/test/class.test.tsx +++ b/packages/csharp/test/class.test.tsx @@ -14,6 +14,7 @@ it("declares class with no members", () => { { public class TestClass; } + `); }); @@ -34,6 +35,7 @@ it("declares class with some members", () => { private int memberTwo; } } + `); }); @@ -54,6 +56,7 @@ it("declares class with some methods", () => { private virtual void MethodTwo() {} } } + `); }); @@ -82,6 +85,7 @@ it("declares class with params and return type", () => { public string MethodOne(int intParam, string stringParam) {} } } + `); }); @@ -141,6 +145,7 @@ it("uses refkeys for members, params, and return type", () => { } } } + `); }); @@ -166,6 +171,7 @@ it("declares class with generic parameters", () => { private U memberTwo; } } + `); }); @@ -196,6 +202,7 @@ it("declares class with constructor", () => { public TestClass() {} } } + `); }); @@ -245,5 +252,6 @@ it("declares class with constructor params and assigns values to fields", () => } } } + `); }); diff --git a/packages/csharp/test/enum.test.tsx b/packages/csharp/test/enum.test.tsx index 53bbd4c..3c7683a 100644 --- a/packages/csharp/test/enum.test.tsx +++ b/packages/csharp/test/enum.test.tsx @@ -14,6 +14,7 @@ it("declares enum with no members", () => { { public enum TestEnum; } + `); }); @@ -34,6 +35,7 @@ it("declares enum with members", () => { Two } } + `); }); @@ -54,6 +56,7 @@ it("applies naming policy to enum and members", () => { Two } } + `); }); @@ -87,6 +90,7 @@ it("can reference things by refkey", () => { TestEnum; TestEnum.Two; } + `); }); @@ -129,6 +133,7 @@ it("can reference things by refkey across files", () => { OtherEnum; OtherEnum.Bar; } + `); expect(res.contents[1].path).toBe("Other.cs"); @@ -143,5 +148,6 @@ it("can reference things by refkey across files", () => { OtherEnum; OtherEnum.Bar; } + `); }); diff --git a/packages/csharp/test/namespace.test.tsx b/packages/csharp/test/namespace.test.tsx index 231ca4e..2aebfe3 100644 --- a/packages/csharp/test/namespace.test.tsx +++ b/packages/csharp/test/namespace.test.tsx @@ -31,6 +31,7 @@ it("defines multiple namespaces and source files with unique content", () => { { public class Model1; } + `); expect(res.contents[1].path).equals("Model2.cs"); @@ -39,6 +40,7 @@ it("defines multiple namespaces and source files with unique content", () => { { public class Model2; } + `); expect(res.contents[2].path).equals("Model3.cs"); @@ -47,6 +49,7 @@ it("defines multiple namespaces and source files with unique content", () => { { public class Model3; } + `); expect(res.contents[3].path).equals("Model4.cs"); @@ -55,5 +58,6 @@ it("defines multiple namespaces and source files with unique content", () => { { public class Model4; } + `); }); diff --git a/packages/csharp/test/projectdirectory.test.tsx b/packages/csharp/test/projectdirectory.test.tsx index 345612d..6bed2a3 100644 --- a/packages/csharp/test/projectdirectory.test.tsx +++ b/packages/csharp/test/projectdirectory.test.tsx @@ -43,6 +43,7 @@ it("defines a project directory file with multiple source files", () => { { public class TestClass1; } + `); expect(srcDir.contents[1].path).equals("~/projects/TestProject/src/Test2.cs"); @@ -51,6 +52,7 @@ it("defines a project directory file with multiple source files", () => { { public class TestClass2; } + `); }); @@ -94,6 +96,7 @@ it("defines a project directory file with multiple source files and a custom TFM { public class TestClass1; } + `); expect(srcDir.contents[1].path).equals("~/projects/TestProject/src/Test2.cs"); @@ -102,5 +105,6 @@ it("defines a project directory file with multiple source files and a custom TFM { public class TestClass2; } + `); }); diff --git a/packages/csharp/test/sourcefile.test.tsx b/packages/csharp/test/sourcefile.test.tsx index d9afba2..1824477 100644 --- a/packages/csharp/test/sourcefile.test.tsx +++ b/packages/csharp/test/sourcefile.test.tsx @@ -23,6 +23,7 @@ it("defines multiple source files with unique content", () => { { public class TestClass1; } + `); expect(res.contents[1].path).equals("Test2.cs"); @@ -31,6 +32,7 @@ it("defines multiple source files with unique content", () => { { public class TestClass2; } + `); }); diff --git a/packages/csharp/test/using.test.tsx b/packages/csharp/test/using.test.tsx index af07961..7b18a17 100644 --- a/packages/csharp/test/using.test.tsx +++ b/packages/csharp/test/using.test.tsx @@ -14,7 +14,9 @@ it("uses a single namespace", () => { expect(res.contents[0].contents).toBe(coretest.d` using Foo; + namespace TestCode {} + `); }); @@ -30,7 +32,9 @@ it("uses multiple namespaces", () => { expect(res.contents[0].contents).toBe(coretest.d` using Bar.Baz; using Foo; + namespace TestCode {} + `); }); @@ -80,11 +84,13 @@ it("adds using statement across namespaces", () => { Two } } + `); expect(res.contents[1].contents).toBe(coretest.d` using Models; using System; + namespace Client { public class Client @@ -93,5 +99,6 @@ it("adds using statement across namespaces", () => { } TestEnum.Two; } + `); });