@typespec/http-server-csharp 0.58.0-alpha.2 → 0.58.0-alpha.20-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +69 -6
  2. package/cmd/hscs.js +2 -0
  3. package/dist/src/cli/cli.d.ts +2 -0
  4. package/dist/src/cli/cli.d.ts.map +1 -0
  5. package/dist/src/cli/cli.js +173 -0
  6. package/dist/src/cli/cli.js.map +1 -0
  7. package/dist/src/{attributes.d.ts → lib/attributes.d.ts} +1 -1
  8. package/dist/src/lib/attributes.d.ts.map +1 -0
  9. package/dist/src/{attributes.js → lib/attributes.js} +113 -35
  10. package/dist/src/lib/attributes.js.map +1 -0
  11. package/dist/src/lib/boilerplate.d.ts +6 -0
  12. package/dist/src/lib/boilerplate.d.ts.map +1 -0
  13. package/dist/src/{boilerplate.js → lib/boilerplate.js} +253 -66
  14. package/dist/src/lib/boilerplate.js.map +1 -0
  15. package/dist/src/lib/doc.d.ts +5 -0
  16. package/dist/src/lib/doc.d.ts.map +1 -0
  17. package/dist/src/lib/doc.js +237 -0
  18. package/dist/src/lib/doc.js.map +1 -0
  19. package/dist/src/lib/index.d.ts.map +1 -0
  20. package/dist/src/lib/index.js.map +1 -0
  21. package/dist/src/{interfaces.d.ts → lib/interfaces.d.ts} +58 -4
  22. package/dist/src/lib/interfaces.d.ts.map +1 -0
  23. package/dist/src/{interfaces.js → lib/interfaces.js} +100 -27
  24. package/dist/src/lib/interfaces.js.map +1 -0
  25. package/dist/src/{lib.d.ts → lib/lib.d.ts} +54 -1
  26. package/dist/src/lib/lib.d.ts.map +1 -0
  27. package/dist/src/lib/lib.js +146 -0
  28. package/dist/src/lib/lib.js.map +1 -0
  29. package/dist/src/lib/project.d.ts +5 -0
  30. package/dist/src/lib/project.d.ts.map +1 -0
  31. package/dist/src/lib/project.js +101 -0
  32. package/dist/src/lib/project.js.map +1 -0
  33. package/dist/src/lib/scaffolding.d.ts +22 -0
  34. package/dist/src/lib/scaffolding.d.ts.map +1 -0
  35. package/dist/src/lib/scaffolding.js +461 -0
  36. package/dist/src/lib/scaffolding.js.map +1 -0
  37. package/dist/src/lib/service.d.ts.map +1 -0
  38. package/dist/src/lib/service.js +1188 -0
  39. package/dist/src/lib/service.js.map +1 -0
  40. package/dist/src/lib/testing/index.d.ts.map +1 -0
  41. package/dist/src/{testing → lib/testing}/index.js +1 -0
  42. package/dist/src/lib/testing/index.js.map +1 -0
  43. package/dist/src/{type-helpers.d.ts → lib/type-helpers.d.ts} +5 -1
  44. package/dist/src/lib/type-helpers.d.ts.map +1 -0
  45. package/dist/src/{type-helpers.js → lib/type-helpers.js} +31 -0
  46. package/dist/src/lib/type-helpers.js.map +1 -0
  47. package/dist/src/lib/utils.d.ts +114 -0
  48. package/dist/src/lib/utils.d.ts.map +1 -0
  49. package/dist/src/lib/utils.js +1557 -0
  50. package/dist/src/lib/utils.js.map +1 -0
  51. package/package.json +49 -27
  52. package/dist/src/attributes.d.ts.map +0 -1
  53. package/dist/src/attributes.js.map +0 -1
  54. package/dist/src/boilerplate.d.ts +0 -4
  55. package/dist/src/boilerplate.d.ts.map +0 -1
  56. package/dist/src/boilerplate.js.map +0 -1
  57. package/dist/src/index.d.ts.map +0 -1
  58. package/dist/src/index.js.map +0 -1
  59. package/dist/src/interfaces.d.ts.map +0 -1
  60. package/dist/src/interfaces.js.map +0 -1
  61. package/dist/src/lib.d.ts.map +0 -1
  62. package/dist/src/lib.js +0 -60
  63. package/dist/src/lib.js.map +0 -1
  64. package/dist/src/service.d.ts.map +0 -1
  65. package/dist/src/service.js +0 -829
  66. package/dist/src/service.js.map +0 -1
  67. package/dist/src/testing/index.d.ts.map +0 -1
  68. package/dist/src/testing/index.js.map +0 -1
  69. package/dist/src/type-helpers.d.ts.map +0 -1
  70. package/dist/src/type-helpers.js.map +0 -1
  71. package/dist/src/utils.d.ts +0 -48
  72. package/dist/src/utils.d.ts.map +0 -1
  73. package/dist/src/utils.js +0 -628
  74. package/dist/src/utils.js.map +0 -1
  75. /package/dist/src/{index.d.ts → lib/index.d.ts} +0 -0
  76. /package/dist/src/{index.js → lib/index.js} +0 -0
  77. /package/dist/src/{service.d.ts → lib/service.d.ts} +0 -0
  78. /package/dist/src/{testing → lib/testing}/index.d.ts +0 -0
@@ -0,0 +1,237 @@
1
+ import { LibrarySourceFile } from "./interfaces.js";
2
+ export function getProjectDocs(emitter, useSwagger, registrations) {
3
+ const sourceFiles = [];
4
+ const mocks = registrations === undefined ? [] : [...registrations.entries()].flatMap((e) => e[1]);
5
+ sourceFiles.push(new LibrarySourceFile({
6
+ filename: `README.md`,
7
+ emitter: emitter,
8
+ getContents: () => (mocks.length > 0 ? getMockReadme(mocks) : getNoMockReadme()),
9
+ path: ".",
10
+ }), new LibrarySourceFile({
11
+ filename: `usage.md`,
12
+ emitter: emitter,
13
+ getContents: () => getUsageDoc(),
14
+ path: "docs",
15
+ }), new LibrarySourceFile({
16
+ filename: `emitter.md`,
17
+ emitter: emitter,
18
+ getContents: () => getEmitterDoc(),
19
+ path: "docs",
20
+ }));
21
+ return sourceFiles;
22
+ }
23
+ function getNoMockReadme() {
24
+ return `---
25
+ title: Next Steps
26
+ ---
27
+
28
+ # Next Steps
29
+
30
+ - Use the SwaggerUI endpoint to test out the running service
31
+ - Implement business logic interfaces for your operations
32
+ - Register each of your implementations as part of application startup
33
+ - Update development and production configuration to suit your needs
34
+
35
+ ## More Information
36
+
37
+ - See [Code Layout](docs/usage.md) for information about the generated code
38
+ - See [Emitter Usage](docs/emitter.md) for details on how to use the emitter.
39
+ - File issues or provide feedback in [TypeSpec Issues](https://github.com/microsoft/typespec/issues/new/choose)
40
+ - Get information about Typespec on the [TypeSpec website](https://typespec.io)
41
+ `;
42
+ }
43
+ function getUsageDoc() {
44
+ return `---
45
+ title: Generated C-Sharp Overview
46
+ ---
47
+
48
+ # Generated C-Sharp Overview
49
+
50
+ ## Layout
51
+
52
+ The code layout inside the 'generated' folder is as follows:
53
+
54
+ - **generated**
55
+
56
+ - **controllers**: A set of ASP.Net core MVC controllers representing the operations in the spec, one for each interface or namespace with operations
57
+ - **lib**: A set of library files used in implementing generated models and controllers
58
+ - **models**: A set of models representing the data in requests and response
59
+ - **operations**: A set of interfaces called by the controllers, that should be implemented with the business logic for each operation.
60
+
61
+ You should recompile whenever you make changes in your TypeSpec and these files will be replaced inline to reflect the spec changes, without changing any of your hand-written implementation in the project.
62
+
63
+ ## Scaffolding
64
+
65
+ If you use the scaffolding cli (hscs) or use the \`--emit-mocks "mocks-and-project-files"\` option on compilation, a
66
+ fully-functional .Net 9 project will be created with mock implementations of your business
67
+ logic, ready to compile and run.
68
+
69
+ The following additional files will be generated. It is expected that you will edit or replace these
70
+ files as you implement your service, so you should only regenerate them when needed.
71
+ To protect from inadvertently changing any edits you may have made to these files,
72
+ these files will be overwritten by the emitter unless you specify the \`--overwrite\` option.
73
+
74
+ - **ServiceProject.csproj**: The project file
75
+ - **Program.cs**: Entry point that sets up the app
76
+ - **appSettings.Development.json**: Configuration settings for the development environment
77
+ - **appSettings.json**: Configuration settings for the production environment
78
+ - **Properties**
79
+ - **launchSettings.json**: Launch configurations for the service (including local ports)
80
+ - **mocks**: Simple implementations of business logic interfaces that return simple responses.
81
+ this allows testing your service out before writing any implementation code.
82
+
83
+ - **MockRegistration.cs**: Called from the Program.cs startup, registers each of the business
84
+ logic implementations in the dependency injection container.
85
+ - **IInitializer.cs**: Interface used in the mocks to create responses.
86
+ - **Initializer.cs**: Implementation of the interface to create mock responses.
87
+
88
+ ## SwaggerUI
89
+
90
+ If you include the \`@typespec/openapi3\` emitter in your typespec project, you can include a
91
+ SwaggerUI endpoint in the generated service using the \`--use-swaggerui\` option. This endpoint
92
+ provides a visual representation of operations and provides a web GUI client connected to the service that you can use right away to try out service operations.
93
+
94
+ ## How Components Work Together
95
+
96
+ ### Controllers
97
+
98
+ The generated controllers automatically listen at the routes you specified in TypeSpec. Controllers perform validation of input requests, call your implementation of business logic interfaces to perform the operation, and return the appropriate Http response.
99
+
100
+ ### Business Logic Interfaces
101
+
102
+ You must implement business loginc interfaces to perform the work of each operation. There is one
103
+ business logic interface for each \`interface\` type in your spec, or for each namespace that contain operations. Business logic can assume that input types meet the constraints specified in TypeSpec and are responsible for returning the response type for the operation.
104
+
105
+ You can use the \`--emit-mocks\` option to emit mock implementations of your business logic, these mocks demonstrate a simple implementation that returns responses that match the response type in TypeSpec. They also show how to use \`IHttpContextAccessor\` to access additional details of the Http request and response.
106
+
107
+ ### Discovery using the ASP.Net Core Dependency Injection Container
108
+
109
+ The Controllers find your business logic implementation through the ASP.Net dependency injection container. At server start, you register each of your implementations with the dependency injection container and they will automatically be instantiated and used by the controllers.
110
+
111
+ If you use the \`--emit-mocks\` option, sample code registering mock implementations is emitted to \`mocks/MockRegistration.cs\`.
112
+
113
+ ### Models
114
+
115
+ Model classes represent the data passed in Http requests and response and the data that passes from the front end controllers to your business logic.
116
+
117
+ Models are partial, so you can add additional members for internal usage as needed by putting a partial class definition with additional members outside the \`generated\` folder in your project.
118
+
119
+ ### Next Steps
120
+
121
+ After successful generation, you should:
122
+
123
+ - Use the SwaggerUI endpoint to test out the running service
124
+ - Implement the business logic interfaces for your operations
125
+ - Update MockRegistration.cs, or register each of your interfaces as part of application startup
126
+ - Update configuration to suit your needs
127
+ `;
128
+ }
129
+ function getEmitterDoc() {
130
+ return `---
131
+ title: "Emitter usage"
132
+ ---
133
+
134
+ # Emitter Usage
135
+
136
+ 1. Via the command line
137
+
138
+ \`\`\`bash
139
+ tsp compile . --emit=@typespec/http-server-csharp
140
+ \`\`\`
141
+
142
+ 2. Via the config
143
+
144
+ \`\`\`yaml
145
+ emit:
146
+ - "@typespec/http-server-csharp"
147
+ \`\`\`
148
+
149
+ The config can be extended with options as follows:
150
+
151
+ \`\`\`yaml
152
+ emit:
153
+ - "@typespec/http-server-csharp"
154
+ options:
155
+ "@typespec/http-server-csharp":
156
+ option: value
157
+ \`\`\`
158
+
159
+ ## Emitter options
160
+
161
+ ### \`skip-format\`
162
+
163
+ **Type:** \`boolean\`
164
+
165
+ Skips formatting of generated C# Types. By default, C# files are formatted using 'dotnet format'.
166
+
167
+ ### \`output-type\`
168
+
169
+ **Type:** \`"models" | "all"\`
170
+
171
+ Chooses which service artifacts to emit. choices include 'models' or 'all' artifacts.
172
+
173
+ ### \`emit-mocks\`
174
+
175
+ **Type:** \`"mocks-and-project-files" | "mocks-only" | "none"\`
176
+
177
+ Emits mock implementations of business logic, setup code, and project files enabling the service to respond to requests before a real implementation is provided
178
+
179
+ ### \`use-swaggerui\`
180
+
181
+ **Type:** \`boolean\`
182
+
183
+ Configure a Swagger UI endpoint in the development configuration
184
+
185
+ ### \`openapi-path\`
186
+
187
+ **Type:** \`string\`
188
+
189
+ Use openapi at the given path for generating SwaggerUI endpoints. By default, this will be 'openapi/openapi.yaml' if the 'use-swaggerui' option is enabled.
190
+
191
+ ### \`overwrite\`
192
+
193
+ **Type:** \`boolean\`
194
+
195
+ When generating mock files, setup code, and project files overwrite any existing files with the same name.
196
+
197
+ ### \`project-name\`
198
+
199
+ **Type:** \`string\`
200
+
201
+ The name of the generated project.
202
+
203
+ ### \`http-port\`
204
+
205
+ **Type:** \`number\`
206
+
207
+ The service http port when hosting the project locally.
208
+
209
+ ### \`https-port\`
210
+
211
+ **Type:** \`number\`
212
+
213
+ The service https port when hosting the project locally.
214
+ `;
215
+ }
216
+ function getMockReadme(mocks) {
217
+ return `---
218
+ title: Next Steps
219
+ ---
220
+
221
+ # Next Steps
222
+
223
+ - Use the SwaggerUI endpoint to test out the running service
224
+ - Update business logic mocks with real business logic
225
+ ${mocks.flatMap((m) => ` - \`mocks/${m.className}.cs\``).join("\n")}
226
+ - Update \`mocks/MockRegistration.cs\` if you update the constructor of business logic implementations.
227
+ - Update development and production configuration to suit your needs
228
+
229
+ ## More Information
230
+
231
+ - See [Code Layout](docs/usage.md) for information about the generated code
232
+ - See [Emitter Usage](docs/emitter.md) for details on how to use the emitter.
233
+ - File issues or provide feedback in [TypeSpec Issues](https://github.com/microsoft/typespec/issues/new/choose)
234
+ - Get information about Typespec on the [TypeSpec website](https://typespec.io)
235
+ `;
236
+ }
237
+ //# sourceMappingURL=doc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc.js","sourceRoot":"","sources":["../../../src/lib/doc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,MAAM,UAAU,cAAc,CAC5B,OAAoD,EACpD,UAAmB,EACnB,aAA0C;IAE1C,MAAM,WAAW,GAAwB,EAAE,CAAC;IAC5C,MAAM,KAAK,GACT,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvF,WAAW,CAAC,IAAI,CACd,IAAI,iBAAiB,CAAC;QACpB,QAAQ,EAAE,WAAW;QACrB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;QAChF,IAAI,EAAE,GAAG;KACV,CAAC,EACF,IAAI,iBAAiB,CAAC;QACpB,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE;QAChC,IAAI,EAAE,MAAM;KACb,CAAC,EACF,IAAI,iBAAiB,CAAC;QACpB,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,GAAG,EAAE,CAAC,aAAa,EAAE;QAClC,IAAI,EAAE,MAAM;KACb,CAAC,CACH,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AACD,SAAS,eAAe;IACtB,OAAO;;;;;;;;;;;;;;;;;CAiBR,CAAC;AACF,CAAC;AAED,SAAS,WAAW;IAClB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmFR,CAAC;AACF,CAAC;AAED,SAAS,aAAa;IACpB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoFR,CAAC;AACF,CAAC;AACD,SAAS,aAAa,CAAC,KAAoC;IACzD,OAAO;;;;;;;;EAQP,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;CAUnE,CAAC;AACF,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,4BAA4B,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,yBAAyB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -1,25 +1,63 @@
1
- import { Model } from "@typespec/compiler";
2
- import { AssetEmitter, Context, EmittedSourceFile, EmitterOutput, Scope, SourceFile } from "@typespec/compiler/emitter-framework";
1
+ import { AssetEmitter, Context, EmittedSourceFile, EmitterOutput, Scope, SourceFile } from "@typespec/asset-emitter";
2
+ import type { Model } from "@typespec/compiler";
3
+ import { HttpStatusCodeRange } from "@typespec/http";
4
+ import { HttpRequestParameterKind } from "@typespec/http/experimental/typekit";
5
+ import { CSharpServiceEmitterOptions } from "./lib.js";
3
6
  export declare const HelperNamespace: string;
4
7
  export interface CSharpTypeMetadata {
5
8
  name: string;
6
9
  namespace?: string;
7
10
  }
11
+ export interface ResponseInfo {
12
+ statusCode: number | HttpStatusCodeRange | "*";
13
+ csharpStatusCode: string;
14
+ resultType: CSharpType;
15
+ }
8
16
  export declare class CSharpType implements CSharpTypeMetadata {
9
17
  name: string;
10
18
  namespace: string;
11
19
  isBuiltIn: boolean;
12
20
  isValueType: boolean;
21
+ isNullable: boolean;
22
+ isClass: boolean;
23
+ isCollection: boolean;
13
24
  constructor(input: {
14
25
  name: string;
15
26
  namespace: string;
16
27
  isBuiltIn?: boolean;
17
28
  isValueType?: boolean;
29
+ isNullable?: boolean;
30
+ isClass?: boolean;
31
+ isCollection?: boolean;
18
32
  });
19
33
  isNamespaceInScope(scope?: Scope<string>, visited?: Set<Scope<string>>): boolean;
20
34
  getTypeReference(scope?: Scope<string>): string;
21
35
  equals(other: CSharpType | undefined): boolean;
22
36
  }
37
+ export declare function checkOrAddNamespaceToScope(ns: string, scope?: Scope<string>, visited?: Set<Scope<string>>): boolean;
38
+ export declare enum CollectionType {
39
+ ISet = "ISet",
40
+ ICollection = "ICollection",
41
+ IEnumerable = "IEnumerable",
42
+ Array = "[]"
43
+ }
44
+ export declare function resolveCollectionType(option?: string): CollectionType;
45
+ export declare class CSharpCollectionType extends CSharpType {
46
+ collectionType: CollectionType;
47
+ itemTypeName: string;
48
+ static readonly implementationType: Record<CollectionType, string>;
49
+ constructor(csharpType: {
50
+ name: string;
51
+ namespace: string;
52
+ isBuiltIn?: boolean;
53
+ isValueType?: boolean;
54
+ isNullable?: boolean;
55
+ isClass?: boolean;
56
+ isCollection?: boolean;
57
+ }, collectionType: CollectionType, itemTypeName: string);
58
+ getTypeReference(scope?: Scope<string> | undefined): string;
59
+ getImplementationType(): string;
60
+ }
23
61
  export declare abstract class CSharpValue {
24
62
  value?: any;
25
63
  abstract emitValue(scope?: Scope<string>): string;
@@ -91,7 +129,7 @@ export declare class CSharpController extends CSharpDeclaration {
91
129
  getDeclaration(scope: Scope<string>): EmitterOutput<string>;
92
130
  }
93
131
  export interface ControllerContext extends Context {
94
- file: SourceFile<string>;
132
+ namespace: string;
95
133
  resourceName: string;
96
134
  resourceType?: Model;
97
135
  scope: Scope<string>;
@@ -120,10 +158,26 @@ export declare class LibrarySourceFile {
120
158
  constructor(params: {
121
159
  filename: string;
122
160
  getContents: () => string;
123
- emitter: AssetEmitter<string, Record<string, never>>;
161
+ emitter: AssetEmitter<string, CSharpServiceEmitterOptions>;
162
+ path?: string;
163
+ conditional?: boolean;
124
164
  });
165
+ conditional: boolean;
125
166
  filename: string;
126
167
  source: SourceFile<string>;
127
168
  emitted: EmittedSourceFile;
169
+ path: string;
170
+ }
171
+ export interface CSharpOperationParameter {
172
+ name: string;
173
+ typeName: EmitterOutput<string>;
174
+ optional: boolean;
175
+ httpParameterKind: HttpRequestParameterKind;
176
+ httpParameterName?: string;
177
+ callName: string;
178
+ isExplicitBody: boolean;
179
+ nullable: boolean;
180
+ operationKind: "Http" | "BusinessLogic" | "All";
181
+ defaultValue?: string | boolean;
128
182
  }
129
183
  //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/lib/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,KAAK,EACL,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MA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iB,EAAE,wBAAwB,CAAC;IAC5C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,eAAe,GAAG,KAAK,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC"}
@@ -4,45 +4,112 @@ export class CSharpType {
4
4
  namespace;
5
5
  isBuiltIn;
6
6
  isValueType;
7
+ isNullable;
8
+ isClass;
9
+ isCollection;
7
10
  constructor(input) {
8
11
  this.name = input.name;
9
12
  this.namespace = input.namespace;
10
13
  this.isBuiltIn = input.isBuiltIn !== undefined ? input.isBuiltIn : input.namespace === "System";
11
14
  this.isValueType = input.isValueType !== undefined ? input.isValueType : false;
15
+ this.isNullable = input.isNullable !== undefined ? input.isNullable : false;
16
+ this.isClass = input.isClass !== undefined ? input.isClass : false;
17
+ this.isCollection = input.isCollection !== undefined ? input.isCollection : false;
12
18
  }
13
19
  isNamespaceInScope(scope, visited) {
14
20
  if (this.isBuiltIn)
15
21
  return true;
16
- if (scope === undefined)
17
- return false;
18
- if (!visited)
19
- visited = new Set();
20
- if (visited.has(scope))
21
- return false;
22
- visited.add(scope);
23
- switch (scope.kind) {
24
- case "namespace": {
25
- if (scope.namespace.startsWith(this.namespace))
22
+ return checkOrAddNamespaceToScope(this.namespace, scope, visited);
23
+ }
24
+ getTypeReference(scope) {
25
+ return this.isNamespaceInScope(scope) ? this.name : `${this.namespace}.${this.name}`;
26
+ }
27
+ equals(other) {
28
+ return this.name === other?.name && this.namespace === other?.namespace;
29
+ }
30
+ }
31
+ export function checkOrAddNamespaceToScope(ns, scope, visited) {
32
+ if (!ns)
33
+ return false;
34
+ if (scope === undefined)
35
+ return false;
36
+ if (!visited)
37
+ visited = new Set();
38
+ if (visited.has(scope))
39
+ return false;
40
+ visited.add(scope);
41
+ switch (scope.kind) {
42
+ case "namespace": {
43
+ if (scope.namespace.startsWith(ns))
44
+ return true;
45
+ return checkOrAddNamespaceToScope(ns, scope.parentScope, visited);
46
+ }
47
+ case "sourceFile": {
48
+ const fileNameSpace = scope.sourceFile.meta["ResolvedNamespace"];
49
+ if (fileNameSpace && fileNameSpace.startsWith(ns))
50
+ return true;
51
+ for (const entry of scope.sourceFile.imports.keys()) {
52
+ if (entry === ns) {
26
53
  return true;
27
- return this.isNamespaceInScope(scope.parentScope, visited);
28
- }
29
- case "sourceFile": {
30
- for (const entry of scope.sourceFile.imports.keys()) {
31
- if (entry === this.namespace) {
32
- return true;
33
- }
34
54
  }
35
- return this.isNamespaceInScope(scope.sourceFile.globalScope, visited);
36
55
  }
37
- default:
38
- return false;
56
+ const added = scope.sourceFile.meta["AddedScope"];
57
+ if (added === undefined) {
58
+ scope.sourceFile.imports.set(ns, [ns]);
59
+ scope.sourceFile.meta["AddedScope"] = ns;
60
+ return true;
61
+ }
62
+ return false;
39
63
  }
64
+ default:
65
+ return false;
66
+ }
67
+ }
68
+ export var CollectionType;
69
+ (function (CollectionType) {
70
+ CollectionType["ISet"] = "ISet";
71
+ CollectionType["ICollection"] = "ICollection";
72
+ CollectionType["IEnumerable"] = "IEnumerable";
73
+ CollectionType["Array"] = "[]";
74
+ })(CollectionType || (CollectionType = {}));
75
+ export function resolveCollectionType(option) {
76
+ switch (option) {
77
+ case "enumerable":
78
+ return CollectionType.IEnumerable;
79
+ case "array":
80
+ default:
81
+ return CollectionType.Array;
82
+ }
83
+ }
84
+ export class CSharpCollectionType extends CSharpType {
85
+ collectionType;
86
+ itemTypeName;
87
+ static implementationType = {
88
+ [CollectionType.ISet]: "HashSet",
89
+ [CollectionType.ICollection]: "List",
90
+ [CollectionType.IEnumerable]: "List",
91
+ [CollectionType.Array]: "[]",
92
+ };
93
+ constructor(csharpType, collectionType, itemTypeName) {
94
+ super(csharpType);
95
+ this.collectionType = collectionType;
96
+ this.itemTypeName = itemTypeName;
40
97
  }
41
98
  getTypeReference(scope) {
42
- return `${this.isNamespaceInScope(scope) ? "" : this.namespace + "."}${this.name}`;
99
+ if (this.isNamespaceInScope(scope)) {
100
+ return this.name;
101
+ }
102
+ return `${this.collectionType}<${this.namespace}.${this.itemTypeName}>`;
43
103
  }
44
- equals(other) {
45
- return this.name === other?.name && this.namespace === other?.namespace;
104
+ getImplementationType() {
105
+ switch (this.collectionType) {
106
+ case CollectionType.ISet:
107
+ case CollectionType.ICollection:
108
+ case CollectionType.IEnumerable:
109
+ return `new ${CSharpCollectionType.implementationType[this.collectionType]}<${this.itemTypeName}>()`;
110
+ default:
111
+ return `[]`;
112
+ }
46
113
  }
47
114
  }
48
115
  export class CSharpValue {
@@ -75,7 +142,7 @@ export class NumericValue extends CSharpValue {
75
142
  this.value = value;
76
143
  }
77
144
  emitValue(scope) {
78
- return `${this.value}` ?? "0";
145
+ return `${this.value ?? 0}`;
79
146
  }
80
147
  }
81
148
  export class BooleanValue extends CSharpValue {
@@ -85,7 +152,7 @@ export class BooleanValue extends CSharpValue {
85
152
  this.value = value;
86
153
  }
87
154
  emitValue(scope) {
88
- return `${this.value}` ?? false;
155
+ return `${this.value}`;
89
156
  }
90
157
  }
91
158
  export class NullValue extends CSharpValue {
@@ -208,15 +275,21 @@ export var NameCasingType;
208
275
  })(NameCasingType || (NameCasingType = {}));
209
276
  export class LibrarySourceFile {
210
277
  constructor(params) {
278
+ this.path = params.path || "generated/lib/";
211
279
  this.filename = params.filename;
212
- this.source = params.emitter.createSourceFile(`lib/${this.filename}`);
280
+ const source = params.emitter.createSourceFile(`${this.path}/${this.filename}`);
281
+ this.conditional = params.conditional || false;
213
282
  this.emitted = {
214
- path: this.source.path,
283
+ path: source.path,
215
284
  contents: params.getContents(),
216
285
  };
286
+ source.meta = { emitted: this.emitted, conditional: this.conditional };
287
+ this.source = source;
217
288
  }
289
+ conditional;
218
290
  filename;
219
291
  source;
220
292
  emitted;
293
+ path;
221
294
  }
222
295
  //# sourceMappingURL=interfaces.js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AAO,GAAG;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE;SAC/B,CAAC;QAEF,MAAM,CAAC,IAAI,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QACvE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IACD,WAAW,CAAU;IACrB,QAAQ,CAAS;IACjB,MAAM,CAAqB;IAC3B,OAAO,CAAoB;IAC3B,IAAI,CAAS;CACd"}
@@ -1,13 +1,33 @@
1
+ import { CollectionType } from "./interfaces.js";
1
2
  export interface CSharpServiceEmitterOptions {
2
3
  /**Skip formatting of output. Default is false (generated c-sharp files are formatted) */
3
4
  "skip-format"?: boolean;
4
5
  /** Choose which service artifacts to emit. Default is 'all'.*/
5
6
  "output-type"?: "models" | "all";
7
+ /** Emit mock implementations of business logic, setup code, and project files. Allows the service to respond to requests with mock responses.*/
8
+ "emit-mocks"?: "none" | "mocks-only" | "mocks-and-project-files";
9
+ /** Configure a Swagger UI endpoint in the development configuration. */
10
+ "use-swaggerui"?: boolean;
11
+ /** Use openapi at the given path for generating SwaggerUI endpoints. By default, this will be 'openapi/openapi.yaml' if the 'use-swaggerui' option is enabled. */
12
+ "openapi-path"?: string;
13
+ /** When generating mock files, overwrite any existing files with the same name. */
14
+ overwrite?: boolean;
15
+ /** The generated project name. */
16
+ "project-name"?: string;
17
+ /** The http port number to use when hosting the service locally */
18
+ "http-port"?: number;
19
+ /** The https port number to use when hosting the service locally */
20
+ "https-port"?: number;
21
+ /** Specifies the collection type to use: 'array' or 'enumerable'. The default is 'enumerable'." */
22
+ "collection-type"?: "array" | "enumerable";
6
23
  }
7
24
  export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
8
25
  "invalid-identifier": {
9
26
  readonly default: import("@typespec/compiler").CallableMessage<["identifier", "location"]>;
10
27
  };
28
+ "anonymous-model": {
29
+ readonly default: import("@typespec/compiler").CallableMessage<["emittedName"]>;
30
+ };
11
31
  "missing-type-parent": {
12
32
  readonly default: import("@typespec/compiler").CallableMessage<["type", "name"]>;
13
33
  };
@@ -20,11 +40,20 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
20
40
  "invalid-intrinsic": {
21
41
  readonly default: import("@typespec/compiler").CallableMessage<["typeName"]>;
22
42
  };
43
+ "invalid-interpolation": {
44
+ readonly default: import("@typespec/compiler").CallableMessage<[]>;
45
+ };
46
+ "get-request-body": {
47
+ readonly default: import("@typespec/compiler").CallableMessage<[]>;
48
+ };
23
49
  }, CSharpServiceEmitterOptions, never>;
24
- export declare const reportDiagnostic: <C extends "invalid-identifier" | "missing-type-parent" | "no-numeric" | "unrecognized-scalar" | "invalid-intrinsic", M extends keyof {
50
+ export declare const reportDiagnostic: <C extends "invalid-identifier" | "anonymous-model" | "missing-type-parent" | "no-numeric" | "unrecognized-scalar" | "invalid-intrinsic" | "invalid-interpolation" | "get-request-body", M extends keyof {
25
51
  "invalid-identifier": {
26
52
  readonly default: import("@typespec/compiler").CallableMessage<["identifier", "location"]>;
27
53
  };
54
+ "anonymous-model": {
55
+ readonly default: import("@typespec/compiler").CallableMessage<["emittedName"]>;
56
+ };
28
57
  "missing-type-parent": {
29
58
  readonly default: import("@typespec/compiler").CallableMessage<["type", "name"]>;
30
59
  };
@@ -37,10 +66,19 @@ export declare const reportDiagnostic: <C extends "invalid-identifier" | "missin
37
66
  "invalid-intrinsic": {
38
67
  readonly default: import("@typespec/compiler").CallableMessage<["typeName"]>;
39
68
  };
69
+ "invalid-interpolation": {
70
+ readonly default: import("@typespec/compiler").CallableMessage<[]>;
71
+ };
72
+ "get-request-body": {
73
+ readonly default: import("@typespec/compiler").CallableMessage<[]>;
74
+ };
40
75
  }[C]>(program: import("@typespec/compiler").Program, diag: import("@typespec/compiler").DiagnosticReport<{
41
76
  "invalid-identifier": {
42
77
  readonly default: import("@typespec/compiler").CallableMessage<["identifier", "location"]>;
43
78
  };
79
+ "anonymous-model": {
80
+ readonly default: import("@typespec/compiler").CallableMessage<["emittedName"]>;
81
+ };
44
82
  "missing-type-parent": {
45
83
  readonly default: import("@typespec/compiler").CallableMessage<["type", "name"]>;
46
84
  };
@@ -53,6 +91,21 @@ export declare const reportDiagnostic: <C extends "invalid-identifier" | "missin
53
91
  "invalid-intrinsic": {
54
92
  readonly default: import("@typespec/compiler").CallableMessage<["typeName"]>;
55
93
  };
94
+ "invalid-interpolation": {
95
+ readonly default: import("@typespec/compiler").CallableMessage<[]>;
96
+ };
97
+ "get-request-body": {
98
+ readonly default: import("@typespec/compiler").CallableMessage<[]>;
99
+ };
56
100
  }, C, M>) => void, createStateSymbol: (name: string) => symbol, getTracer: (program: import("@typespec/compiler").Program) => import("@typespec/compiler").Tracer;
57
101
  export type CSharpServiceLibrary = typeof $lib;
102
+ export declare class CSharpServiceOptions {
103
+ private static instance;
104
+ collectionType: CollectionType;
105
+ private constructor();
106
+ static getInstance(): CSharpServiceOptions;
107
+ initialize(options: {
108
+ "collection-type"?: string;
109
+ }): void;
110
+ }
58
111
  //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../../src/lib/lib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAyB,MAAM,iBAAiB,CAAC;AAExE,MAAM,WAAW,2BAA2B;IAC1C,yFAAyF;IACzF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gEAAgE;IAChE,aAAa,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACjC,gJAAgJ;IAChJ,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,yBAAyB,CAAC;IACjE,wEAAwE;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kKAAkK;IAClK,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,SAAS,CAAC,EAAE,OAAO,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