Skip to content

Commit 18c39f9

Browse files
fix the bug that flags in our emitters become string (#5388)
1 parent a7f4420 commit 18c39f9

File tree

2 files changed

+122
-1
lines changed

2 files changed

+122
-1
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
export * from "./emitter.js";
4+
export { $onEmit } from "./emitter.js";
5+
export {
6+
AzureCSharpEmitterOptions,
7+
AzureCSharpEmitterOptionsSchema
8+
} from "./options.js";
9+
export { $lib } from "./lib.js";
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
import {
5+
createTypeSpecLibrary,
6+
DiagnosticDefinition,
7+
DiagnosticMessages,
8+
paramMessage
9+
} from "@typespec/compiler";
10+
import { AzureCSharpEmitterOptionsSchema } from "./options.js";
11+
12+
export type DiagnosticMessagesMap = {
13+
[K in keyof typeof diags]: (typeof diags)[K]["messages"];
14+
};
15+
16+
const diags: { [code: string]: DiagnosticDefinition<DiagnosticMessages> } = {
17+
"no-apiVersion": {
18+
severity: "error",
19+
messages: {
20+
default: paramMessage`No APIVersion Provider for service ${"service"}`
21+
}
22+
},
23+
"no-route": {
24+
severity: "error",
25+
messages: {
26+
default: paramMessage`No Route for service for service ${"service"}`
27+
}
28+
},
29+
"general-warning": {
30+
severity: "warning",
31+
messages: {
32+
default: paramMessage`${"message"}`
33+
}
34+
},
35+
"general-error": {
36+
severity: "error",
37+
messages: {
38+
default: paramMessage`${"message"}`
39+
}
40+
},
41+
"invalid-dotnet-sdk-dependency": {
42+
severity: "error",
43+
messages: {
44+
default: paramMessage`Invalid .NET SDK installed.`,
45+
missing: paramMessage`The dotnet command was not found in the PATH. Please install the .NET SDK version ${"dotnetMajorVersion"} or above. Guidance for installing the .NET SDK can be found at ${"downloadUrl"}.`,
46+
invalidVersion: paramMessage`The .NET SDK found is version ${"installedVersion"}. Please install the .NET SDK ${"dotnetMajorVersion"} or above and ensure there is no global.json in the file system requesting a lower version. Guidance for installing the .NET SDK can be found at ${"downloadUrl"}.`
47+
}
48+
},
49+
"unsupported-auth": {
50+
severity: "warning",
51+
messages: {
52+
default: paramMessage`${"message"}`,
53+
onlyUnsupportedAuthProvided: `No supported authentication methods were provided. No public client constructors will be generated. Please provide your own custom constructor for client instantiation.`
54+
}
55+
},
56+
"client-namespace-conflict": {
57+
severity: "warning",
58+
messages: {
59+
default: paramMessage`${"message"}`
60+
}
61+
},
62+
"unsupported-endpoint-url": {
63+
severity: "error",
64+
messages: {
65+
default: paramMessage`Unsupported server endpoint URL: ${"endpoint"}`
66+
}
67+
},
68+
"unsupported-sdk-type": {
69+
severity: "error",
70+
messages: {
71+
default: paramMessage`Unsupported SDK type: ${"sdkType"}.`
72+
}
73+
},
74+
"unsupported-default-value-type": {
75+
severity: "error",
76+
messages: {
77+
default: paramMessage`Unsupported default value type: ${"valueType"}.`
78+
}
79+
},
80+
"unsupported-cookie-parameter": {
81+
severity: "error",
82+
messages: {
83+
default: paramMessage`Cookie parameter is not supported: ${"parameterName"}, found in operation ${"path"}`
84+
}
85+
},
86+
"unsupported-patch-convenience-method": {
87+
severity: "warning",
88+
messages: {
89+
default: paramMessage`Convenience method is not supported for PATCH method, it will be turned off. Please set the '@convenientAPI' to false for operation ${"methodCrossLanguageDefinitionId"}.`
90+
}
91+
},
92+
"unsupported-service-method": {
93+
severity: "warning",
94+
messages: {
95+
default: paramMessage`Unsupported method kind: ${"methodKind"}.`
96+
}
97+
},
98+
"unsupported-continuation-location": {
99+
severity: "error",
100+
messages: {
101+
default: paramMessage`Unsupported continuation location for operation ${"crossLanguageDefinitionId"}.`
102+
}
103+
}
104+
};
105+
106+
/**
107+
* The TypeSpec library for the C# HTTP client generator.
108+
* @beta
109+
*/
110+
export const $lib = createTypeSpecLibrary({
111+
name: "@azure-tools/typespec-csharp",
112+
diagnostics: diags,
113+
emitter: {
114+
options: AzureCSharpEmitterOptionsSchema
115+
}
116+
});

0 commit comments

Comments
 (0)