Repository: alloy-framework/alloy
Pull request #36 (2024-09-24 18:17:48)

Add some extra new lines
New lines between the last using statement and namespace decl. Add trailing new line at the end of the namespace.

github-actions[bot]: <!--chronus-github-change-commenter-->
:x: There is undocummented changes. Run `chronus add` to add a changeset or [click here](https://github.com/jhendrixMSFT/alloy/new/csharp-spacing?filename=.chronus/changes/csharp-spacing-2024-8-24-18-18-17.md&value=---%0A%23%20Change%20versionKind%20to%20one%20of%3A%20breaking%2C%20feature%2C%20fix%2C%20internal%0AchangeKind%3A%20fix%0Apackages%3A%0A%20%20-%20%22%40alloy-js%2Fcsharp%22%0A---%0A%0AAdd%20some%20extra%20new%20lines).

**The following packages have changes but are not documented.**
 - :x:`@alloy-js/csharp`

<details>
<summary>Show changes</summary>


</details>

pkg-pr-new[bot]: 
[Open in Stackblitz](https://pkg.pr.new/template/33102772-9176-4ad0-8ee4-04a392b067e6)


<details><summary><b>@alloy-js/babel-plugin</b></summary><p>

```
pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/babel-plugin@36
```

</p></details>
      
    

<details><summary><b>@alloy-js/babel-plugin-jsx-dom-expressions</b></summary><p>

```
pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/babel-plugin-jsx-dom-expressions@36
```

</p></details>
      
    

<details><summary><b>@alloy-js/babel-preset</b></summary><p>

```
pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/babel-preset@36
```

</p></details>
      
    

<details><summary><b>@alloy-js/core</b></summary><p>

```
pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/core@36
```

</p></details>
      
    

<details><summary><b>@alloy-js/java</b></summary><p>

```
pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/java@36
```

</p></details>
      
    

<details><summary><b>@alloy-js/prettier-plugin-alloy</b></summary><p>

```
pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/prettier-plugin-alloy@36
```

</p></details>
      
    

<details><summary><b>@alloy-js/csharp</b></summary><p>

```
pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/csharp@36
```

</p></details>
      
    

<details><summary><b>@alloy-js/typescript</b></summary><p>

```
pnpm add https://pkg.pr.new/alloy-framework/alloy/@alloy-js/typescript@36
```

</p></details>
      
    

_commit: <a href="https://github.com/alloy-framework/alloy/runs/30602553155"><code>5674972</code></a>_


Patch:
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) {
         <core.Scope name={props.path} kind="source-file">
           {using.length > 0 ? (
             <>
-              <UsingDirective namespaces={using} />{"\n"}
+              <UsingDirective namespaces={using} />{"\n\n"}
             </>
-          ) : undefined}namespace {namespaceCtx.name}{!props.children && " {}"}{props.children && 
+          ) : undefined}namespace {namespaceCtx.name}{!props.children && " {}\n"}{props.children && 
             <>
               {"\n{"}
                 {props.children}
-              {"}"}
+              {"}\n"}
             </>
           }
         </core.Scope>


Test patch:
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;
     }
+
   `);
 });