Skip to content

Commit 0169675

Browse files
adopt the emitter changes on namespace (#5224)
* format * it is not working - it turns out we have to keep this namespace configuration * update version * regen * fix ci * fix the compilation issue in emitter * fix format * bump a version and see what would happen in regen * regen * update to official version
1 parent 247f697 commit 0169675

File tree

119 files changed

+1784
-1819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1784
-1819
lines changed

package-lock.json

+7-1,712
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/AnomalyDetector/tspCodeModel.json

+38
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"decorators": []
8888
}
8989
],
90+
"clientNamespace": "AnomalyDetector.Multivariate",
9091
"doc": "The batch detection status.",
9192
"isFixed": true,
9293
"isFlags": false,
@@ -143,6 +144,7 @@
143144
"decorators": []
144145
}
145146
],
147+
"clientNamespace": "AnomalyDetector.Multivariate",
146148
"doc": "Data schema of input data source: OneTable or MultiTable. The default DataSchema is OneTable.",
147149
"isFixed": false,
148150
"isFlags": false,
@@ -197,6 +199,7 @@
197199
"decorators": []
198200
}
199201
],
202+
"clientNamespace": "AnomalyDetector.Multivariate",
200203
"doc": "The alignment mode.",
201204
"isFixed": true,
202205
"isFlags": false,
@@ -302,6 +305,7 @@
302305
"decorators": []
303306
}
304307
],
308+
"clientNamespace": "AnomalyDetector.Multivariate",
305309
"doc": "An optional field, indicating how missing values will be filled. One of Previous, Subsequent, Linear, Zero, Fixed.",
306310
"isFixed": false,
307311
"isFlags": false,
@@ -390,6 +394,7 @@
390394
"decorators": []
391395
}
392396
],
397+
"clientNamespace": "AnomalyDetector.Multivariate",
393398
"doc": "the model status.",
394399
"isFixed": true,
395400
"isFlags": false,
@@ -563,6 +568,7 @@
563568
"decorators": []
564569
}
565570
],
571+
"clientNamespace": "AnomalyDetector.Univariate",
566572
"doc": "the time granularity of the data points.",
567573
"isFixed": true,
568574
"isFlags": false,
@@ -685,6 +691,7 @@
685691
"decorators": []
686692
}
687693
],
694+
"clientNamespace": "AnomalyDetector.Univariate",
688695
"doc": "The impute mode.",
689696
"isFixed": false,
690697
"isFlags": false,
@@ -892,6 +899,7 @@
892899
"decorators": []
893900
}
894901
],
902+
"clientNamespace": "AnomalyDetector.Univariate",
895903
"isFixed": true,
896904
"isFlags": false,
897905
"usage": "Json,Exception",
@@ -928,6 +936,7 @@
928936
"decorators": []
929937
}
930938
],
939+
"clientNamespace": "AnomalyDetector",
931940
"isFixed": true,
932941
"isFlags": false,
933942
"usage": "Input,ApiVersionEnum",
@@ -939,6 +948,7 @@
939948
"$id": "108",
940949
"kind": "model",
941950
"name": "MultivariateDetectionResult",
951+
"clientNamespace": "AnomalyDetector.Multivariate",
942952
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateDetectionResult",
943953
"usage": "Output,Json",
944954
"doc": "Detection results for the given resultId.",
@@ -988,6 +998,7 @@
988998
"$id": "115",
989999
"kind": "model",
9901000
"name": "MultivariateBatchDetectionResultSummary",
1001+
"clientNamespace": "AnomalyDetector.Multivariate",
9911002
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateBatchDetectionResultSummary",
9921003
"usage": "Output,Json",
9931004
"doc": "Multivariate anomaly detection status.",
@@ -1030,6 +1041,7 @@
10301041
"$id": "121",
10311042
"kind": "model",
10321043
"name": "ErrorResponse",
1044+
"clientNamespace": "AnomalyDetector.Multivariate",
10331045
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ErrorResponse",
10341046
"usage": "Output,Error,Json,Exception",
10351047
"doc": "ErrorResponse contains code and message that shows the error information.",
@@ -1122,6 +1134,7 @@
11221134
"$id": "134",
11231135
"kind": "model",
11241136
"name": "VariableState",
1137+
"clientNamespace": "AnomalyDetector.Multivariate",
11251138
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.VariableState",
11261139
"usage": "Input,Output,Json",
11271140
"doc": "Variable Status.",
@@ -1307,6 +1320,7 @@
13071320
"$id": "160",
13081321
"kind": "model",
13091322
"name": "MultivariateBatchDetectionOptions",
1323+
"clientNamespace": "AnomalyDetector.Multivariate",
13101324
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateBatchDetectionOptions",
13111325
"usage": "Input,Output,Json",
13121326
"doc": "Detection request for batch inference. This is an asynchronous inference which\nwill need another API to get detection results.",
@@ -1482,6 +1496,7 @@
14821496
"$id": "185",
14831497
"kind": "model",
14841498
"name": "AnomalyState",
1499+
"clientNamespace": "AnomalyDetector.Multivariate",
14851500
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AnomalyState",
14861501
"usage": "Output,Json",
14871502
"doc": "Anomaly status and information.",
@@ -1532,6 +1547,7 @@
15321547
"$id": "192",
15331548
"kind": "model",
15341549
"name": "AnomalyValue",
1550+
"clientNamespace": "AnomalyDetector.Multivariate",
15351551
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AnomalyValue",
15361552
"usage": "Output,Json",
15371553
"doc": "Detailed information of the anomalous timestamp.",
@@ -1632,6 +1648,7 @@
16321648
"$id": "207",
16331649
"kind": "model",
16341650
"name": "AnomalyInterpretation",
1651+
"clientNamespace": "AnomalyDetector.Multivariate",
16351652
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AnomalyInterpretation",
16361653
"usage": "Output,Json",
16371654
"doc": "Interpretation of the anomalous timestamp.",
@@ -1701,6 +1718,7 @@
17011718
"$id": "217",
17021719
"kind": "model",
17031720
"name": "CorrelationChanges",
1721+
"clientNamespace": "AnomalyDetector.Multivariate",
17041722
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.CorrelationChanges",
17051723
"usage": "Output,Json",
17061724
"doc": "Correlation changes among the anomalous variables",
@@ -1870,6 +1888,7 @@
18701888
"$id": "235",
18711889
"kind": "model",
18721890
"name": "ModelInfo",
1891+
"clientNamespace": "AnomalyDetector.Multivariate",
18731892
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ModelInfo",
18741893
"usage": "Input,Output,Json",
18751894
"doc": "Training result of a model including its status, errors and diagnostics\ninformation.",
@@ -2059,6 +2078,7 @@
20592078
"$id": "262",
20602079
"kind": "model",
20612080
"name": "AlignPolicy",
2081+
"clientNamespace": "AnomalyDetector.Multivariate",
20622082
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AlignPolicy",
20632083
"usage": "Input,Output,Json",
20642084
"doc": "An optional field, indicating the manner to align multiple variables.",
@@ -2216,6 +2236,7 @@
22162236
"$id": "283",
22172237
"kind": "model",
22182238
"name": "DiagnosticsInfo",
2239+
"clientNamespace": "AnomalyDetector.Multivariate",
22192240
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.DiagnosticsInfo",
22202241
"usage": "Input,Output,Json",
22212242
"doc": "Diagnostics information to help inspect the states of model or variable.",
@@ -2231,6 +2252,7 @@
22312252
"$id": "285",
22322253
"kind": "model",
22332254
"name": "ModelState",
2255+
"clientNamespace": "AnomalyDetector.Multivariate",
22342256
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ModelState",
22352257
"usage": "Input,Output,Json",
22362258
"doc": "Model status.",
@@ -2449,6 +2471,7 @@
24492471
"$id": "314",
24502472
"kind": "model",
24512473
"name": "AnomalyDetectionModel",
2474+
"clientNamespace": "AnomalyDetector.Multivariate",
24522475
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.AnomalyDetectionModel",
24532476
"usage": "Output,Json",
24542477
"doc": "Response of getting a model.",
@@ -2587,6 +2610,7 @@
25872610
"$id": "333",
25882611
"kind": "model",
25892612
"name": "ModelList",
2613+
"clientNamespace": "AnomalyDetector.Multivariate",
25902614
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ModelList",
25912615
"usage": "Output,Json",
25922616
"doc": "Response of listing models.",
@@ -2709,6 +2733,7 @@
27092733
"$id": "350",
27102734
"kind": "model",
27112735
"name": "MultivariateLastDetectionOptions",
2736+
"clientNamespace": "AnomalyDetector.Multivariate",
27122737
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateLastDetectionOptions",
27132738
"usage": "Input,Json",
27142739
"doc": "Request of last detection.",
@@ -2728,6 +2753,7 @@
27282753
"$id": "353",
27292754
"kind": "model",
27302755
"name": "VariableValues",
2756+
"clientNamespace": "AnomalyDetector.Multivariate",
27312757
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.VariableValues",
27322758
"usage": "Input,Json",
27332759
"doc": "Variable values.",
@@ -2883,6 +2909,7 @@
28832909
"$id": "374",
28842910
"kind": "model",
28852911
"name": "MultivariateLastDetectionResult",
2912+
"clientNamespace": "AnomalyDetector.Multivariate",
28862913
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.MultivariateLastDetectionResult",
28872914
"usage": "Output,Json",
28882915
"doc": "Results of last detection.",
@@ -2954,6 +2981,7 @@
29542981
"$id": "383",
29552982
"kind": "model",
29562983
"name": "UnivariateDetectionOptions",
2984+
"clientNamespace": "AnomalyDetector.Univariate",
29572985
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateDetectionOptions",
29582986
"usage": "Input,Json",
29592987
"doc": "The request of entire or last anomaly detection.",
@@ -2973,6 +3001,7 @@
29733001
"$id": "386",
29743002
"kind": "model",
29753003
"name": "TimeSeriesPoint",
3004+
"clientNamespace": "AnomalyDetector.Univariate",
29763005
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.TimeSeriesPoint",
29773006
"usage": "Input,Json",
29783007
"doc": "The definition of input timeseries points.",
@@ -3249,6 +3278,7 @@
32493278
"$id": "424",
32503279
"kind": "model",
32513280
"name": "UnivariateEntireDetectionResult",
3281+
"clientNamespace": "AnomalyDetector.Univariate",
32523282
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateEntireDetectionResult",
32533283
"usage": "Output,Json",
32543284
"doc": "The response of entire anomaly detection.",
@@ -3525,6 +3555,7 @@
35253555
"$id": "464",
35263556
"kind": "model",
35273557
"name": "AnomalyDetectorError",
3558+
"clientNamespace": "AnomalyDetector.Univariate",
35283559
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.AnomalyDetectorError",
35293560
"usage": "Error,Json,Exception",
35303561
"doc": "Error information returned by the API.",
@@ -3586,6 +3617,7 @@
35863617
"$id": "472",
35873618
"kind": "model",
35883619
"name": "UnivariateLastDetectionResult",
3620+
"clientNamespace": "AnomalyDetector.Univariate",
35893621
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateLastDetectionResult",
35903622
"usage": "Output,Json",
35913623
"doc": "The response of last anomaly detection.",
@@ -3840,6 +3872,7 @@
38403872
"$id": "509",
38413873
"kind": "model",
38423874
"name": "UnivariateChangePointDetectionOptions",
3875+
"clientNamespace": "AnomalyDetector.Univariate",
38433876
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateChangePointDetectionOptions",
38443877
"usage": "Input,Json",
38453878
"doc": "The request of change point detection.",
@@ -4012,6 +4045,7 @@
40124045
"$id": "533",
40134046
"kind": "model",
40144047
"name": "UnivariateChangePointDetectionResult",
4048+
"clientNamespace": "AnomalyDetector.Univariate",
40154049
"crossLanguageDefinitionId": "AnomalyDetector.Univariate.UnivariateChangePointDetectionResult",
40164050
"usage": "Output,Json",
40174051
"doc": "The response of change point detection.",
@@ -4118,6 +4152,7 @@
41184152
"$id": "548",
41194153
"kind": "model",
41204154
"name": "ResponseError",
4155+
"clientNamespace": "AnomalyDetector.Multivariate",
41214156
"crossLanguageDefinitionId": "AnomalyDetector.Multivariate.ResponseError",
41224157
"usage": "Error",
41234158
"doc": "Error response",
@@ -4176,6 +4211,7 @@
41764211
{
41774212
"$id": "555",
41784213
"Name": "AnomalyDetectorClient",
4214+
"ClientNamespace": "AnomalyDetector",
41794215
"Doc": "The Anomaly Detector API detects anomalies automatically in time series data.\nIt supports two kinds of mode, one is for stateless using, another is for\nstateful using. In stateless mode, there are three functionalities. Entire\nDetect is for detecting the whole series with model trained by the time series,\nLast Detect is detecting last point with model trained by points before.\nChangePoint Detect is for detecting trend changes in time series. In stateful\nmode, user can store time series, the stored time series will be used for\ndetection anomalies. Under this mode, user can still use the above three\nfunctionalities by only giving a time range without preparing time series in\nclient side. Besides the above three functionalities, stateful model also\nprovide group based detection and labeling service. By leveraging labeling\nservice user can provide labels for each detection result, these labels will be\nused for retuning or regenerating detection models. Inconsistency detection is\na kind of group based detection, this detection will find inconsistency ones in\na set of time series. By using anomaly detector service, business customers can\ndiscover incidents and establish a logic flow for root cause analysis.",
41804216
"Operations": [],
41814217
"Protocol": {
@@ -4237,6 +4273,7 @@
42374273
{
42384274
"$id": "562",
42394275
"Name": "Univariate",
4276+
"ClientNamespace": "AnomalyDetector.Univariate",
42404277
"Operations": [
42414278
{
42424279
"$id": "563",
@@ -21101,6 +21138,7 @@
2110121138
{
2110221139
"$id": "2922",
2110321140
"Name": "Multivariate",
21141+
"ClientNamespace": "AnomalyDetector.Multivariate",
2110421142
"Operations": [
2110521143
{
2110621144
"$id": "2923",

src/AutoRest.CSharp/LowLevel/Output/LowLevelClient.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public LowLevelClient(string name, string ns, string description, string library
6464
{
6565
_libraryName = libraryName;
6666
_typeFactory = typeFactory;
67-
DefaultName = name;
67+
DefaultName = GetClientName(name);
6868
Description = description;
6969
IsSubClient = parentClient != null;
7070
ParentClient = parentClient;
@@ -78,6 +78,16 @@ public LowLevelClient(string name, string ns, string description, string library
7878
SubClients = Array.Empty<LowLevelClient>();
7979
}
8080

81+
private static string GetClientName(string name)
82+
{
83+
if (Configuration.ModelNamespace && name == "Models")
84+
{
85+
// TODO -- we should report a warning diagnostic here indicating that we are changing something in the input.
86+
return "ModelsOps"; // Avoid conflict with the Models namespace
87+
}
88+
return name;
89+
}
90+
8191
private IReadOnlyList<Parameter>? _parameters;
8292
public IReadOnlyList<Parameter> Parameters => _parameters ??= new RestClientBuilder(_clientParameters, _operations, _typeFactory).GetOrderedParametersByRequired();
8393

src/TypeSpec.Extension/Emitter.Csharp/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
],
3636
"dependencies": {
3737
"@autorest/csharp": "3.0.0-beta.20240625.4",
38-
"@typespec/http-client-csharp": "0.1.9-alpha.20250205.2"
38+
"@typespec/http-client-csharp": "0.1.9-alpha.20250206.2"
3939
},
4040
"peerDependencies": {
4141
"@azure-tools/typespec-azure-core": ">=0.50.0 <1.0.0",

src/TypeSpec.Extension/Emitter.Csharp/src/emitter.ts

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export async function $onEmit(context: EmitContext<AzureNetEmitterOptions>) {
126126

127127
configurations["enable-internal-raw-data"] =
128128
options["enable-internal-raw-data"];
129+
configurations["model-namespace"] = options["model-namespace"];
129130
const examplesDir =
130131
options["examples-dir"] ?? options["examples-directory"];
131132
if (examplesDir) {

src/TypeSpec.Extension/Emitter.Csharp/src/options.ts

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { dllFilePath } from "@autorest/csharp";
99

1010
export interface AzureNetEmitterOptions extends NetEmitterOptions {
1111
csharpGeneratorPath?: string;
12+
"model-namespace"?: boolean;
1213
"enable-internal-raw-data"?: boolean;
1314
"single-top-level-client"?: boolean;
1415
"existing-project-folder"?: string;
@@ -40,6 +41,10 @@ export const AzureNetEmitterOptionsSchema: JSONSchemaType<AzureNetEmitterOptions
4041
type: "boolean",
4142
default: false
4243
},
44+
"model-namespace": {
45+
type: "boolean",
46+
nullable: true
47+
},
4348
"single-top-level-client": { type: "boolean", nullable: true },
4449
"existing-project-folder": { type: "string", nullable: true },
4550
"keep-non-overloadable-protocol-signature": {
@@ -112,6 +117,7 @@ export function resolveAzureEmitterOptions(
112117
"enable-internal-raw-data":
113118
context.options["enable-internal-raw-data"] ??
114119
defaultAzureEmitterOptions["enable-internal-raw-data"],
120+
"model-namespace": context.options["model-namespace"],
115121
"models-to-treat-empty-string-as-null":
116122
context.options["models-to-treat-empty-string-as-null"] ??
117123
defaultAzureEmitterOptions["models-to-treat-empty-string-as-null"],

test/CadlRanchProjects/authentication/api-key/tspCodeModel.json

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"$id": "2",
99
"kind": "model",
1010
"name": "InvalidAuth",
11+
"clientNamespace": "Authentication.ApiKey",
1112
"crossLanguageDefinitionId": "Authentication.ApiKey.InvalidAuth",
1213
"usage": "Error,Json,Exception",
1314
"decorators": [],
@@ -45,6 +46,7 @@
4546
{
4647
"$id": "7",
4748
"Name": "ApiKeyClient",
49+
"ClientNamespace": "Authentication.ApiKey",
4850
"Doc": "Illustrates clients generated with ApiKey authentication.",
4951
"Operations": [
5052
{

0 commit comments

Comments
 (0)