Skip to content

Commit 215dc6d

Browse files
committed
format and chronus
1 parent 4940d3c commit 215dc6d

2 files changed

Lines changed: 11 additions & 38 deletions

File tree

packages/http-server-csharp/src/lib/service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ export async function $onEmit(context: EmitContext<CSharpServiceEmitterOptions>)
213213
#getDefaultNamespace(): string {
214214
return "TypeSpec.Service";
215215
}
216-
216+
217217
arrayDeclarationContext(array: Model, name: string, elementType: Type) {
218-
const arrayName = ensureCSharpIdentifier(this.emitter.getProgram(), array, name);
219-
const arrayFile = this.emitter.createSourceFile(`generated/models/${arrayName}.cs`);
220-
arrayFile.meta[this.#sourceTypeKey] = CSharpSourceType.Model;
221-
const arrayNamespace = this.#getOrAddNamespace(array.namespace);
222-
return this.#createModelContext(arrayNamespace, arrayFile, arrayName);
218+
const arrayName = ensureCSharpIdentifier(this.emitter.getProgram(), array, name);
219+
const arrayFile = this.emitter.createSourceFile(`generated/models/${arrayName}.cs`);
220+
arrayFile.meta[this.#sourceTypeKey] = CSharpSourceType.Model;
221+
const arrayNamespace = this.#getOrAddNamespace(array.namespace);
222+
return this.#createModelContext(arrayNamespace, arrayFile, arrayName);
223223
}
224224

225225
arrayDeclaration(array: Model, name: string, elementType: Type): EmitterOutput<string> {

packages/http-server-csharp/test/generation.test.ts

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,13 +3432,7 @@ describe("arrayDeclarationContext", () => {
34323432
"My.Custom.Ns",
34333433
],
34343434
[
3435-
[
3436-
"Items.cs",
3437-
[
3438-
"// Generated by @typespec/http-server-csharp",
3439-
"using System;",
3440-
],
3441-
],
3435+
["Items.cs", ["// Generated by @typespec/http-server-csharp", "using System;"]],
34423436
["INsOperations.cs", ["Task<int[]> GetItemsAsync( )"]],
34433437
],
34443438
);
@@ -3464,13 +3458,7 @@ describe("arrayDeclarationContext", () => {
34643458
"public string Name { get; set; }",
34653459
],
34663460
],
3467-
[
3468-
"WidgetList.cs",
3469-
[
3470-
"// Generated by @typespec/http-server-csharp",
3471-
"using System;",
3472-
],
3473-
],
3461+
["WidgetList.cs", ["// Generated by @typespec/http-server-csharp", "using System;"]],
34743462
["IContosoOperations.cs", ["Task<Widget[]> GetWidgetsAsync( )"]],
34753463
],
34763464
);
@@ -3503,24 +3491,9 @@ describe("arrayDeclarationContext", () => {
35033491
@route("/chat") op chat(): AssistantMessage;
35043492
`,
35053493
[
3506-
[
3507-
"AssistantMessage.cs",
3508-
[
3509-
`public string Role { get; } = "assistant";`,
3510-
],
3511-
],
3512-
[
3513-
"ToolCalls.cs",
3514-
[
3515-
"// Generated by @typespec/http-server-csharp",
3516-
],
3517-
],
3518-
[
3519-
"IContosoOperations.cs",
3520-
[
3521-
"Task<AssistantMessage> ChatAsync( );",
3522-
],
3523-
],
3494+
["AssistantMessage.cs", [`public string Role { get; } = "assistant";`]],
3495+
["ToolCalls.cs", ["// Generated by @typespec/http-server-csharp"]],
3496+
["IContosoOperations.cs", ["Task<AssistantMessage> ChatAsync( );"]],
35243497
],
35253498
);
35263499
});

0 commit comments

Comments
 (0)