Skip to content

Commit 9361ea9

Browse files
fix the empty client issue (#7160)
There are some RPs that are "models only RP", which contains no operations but only models. Such as we have in azure: Azure.Messaging.EventGrid.SystemEvents. There was an update in TCGC 0.54.1, now no client is returned from TCGC's output. And long time ago, we made an update in our emitter to error out when there is no client in TCGC's output. When these two combined, we get errors when generating Azure.Messaging.EventGrid.SystemEvents. I think it is not quite reasonable that we give the user an error when there is no client - a generator should work fine if they just want to generate the models. Therefore this PR is changing that to a warning, and we still return a reasonable code model when there is no client.
1 parent 653bb73 commit 9361ea9

File tree

2 files changed

+0
-16
lines changed

2 files changed

+0
-16
lines changed

packages/http-client-csharp/emitter/src/lib/client-model-builder.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
import { UsageFlags } from "@azure-tools/typespec-client-generator-core";
5-
import { NoTarget } from "@typespec/compiler";
65
import { CSharpEmitterContext } from "../sdk-context.js";
76
import { CodeModel } from "../type/code-model.js";
87
import { fromSdkClients } from "./client-converter.js";
@@ -24,14 +23,6 @@ export function createModel(sdkContext: CSharpEmitterContext): CodeModel {
2423
const sdkApiVersionEnums = sdkPackage.enums.filter((e) => e.usage === UsageFlags.ApiVersionEnum);
2524

2625
const rootClients = sdkPackage.clients;
27-
if (rootClients.length === 0) {
28-
sdkContext.logger.reportDiagnostic({
29-
code: "no-root-client",
30-
format: {},
31-
target: NoTarget,
32-
});
33-
return {} as CodeModel;
34-
}
3526

3627
const rootApiVersions =
3728
sdkApiVersionEnums.length > 0

packages/http-client-csharp/emitter/src/lib/lib.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ const diags: { [code: string]: DiagnosticDefinition<DiagnosticMessages> } = {
4646
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"}.`,
4747
},
4848
},
49-
"no-root-client": {
50-
severity: "error",
51-
messages: {
52-
default:
53-
"Cannot generate CSharp SDK since no public root client is defined in typespec file.",
54-
},
55-
},
5649
"unsupported-auth": {
5750
severity: "warning",
5851
messages: {

0 commit comments

Comments
 (0)