Skip to content

Commit 160f7d4

Browse files
upgrade cadl to 0.39 (#3046)
* upgrade cadl to 0.39 * update package-lock.json * remove the usage != None check for model generation * add a test case * update test * update test * don't generate Serailization class when model usage is none * update test * update emitter options for sample project --------- Co-authored-by: ArcturusZhang <[email protected]>
1 parent 54cc349 commit 160f7d4

Some content is hidden

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

47 files changed

+2271
-1927
lines changed

eng/Generate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ if (!($Exclude -contains "Samples"))
250250
$cadlMain = Join-Path $projectDirectory "main.cadl"
251251
$cadlClient = Join-Path $projectDirectory "client.cadl"
252252
$mainCadlFile = If (Test-Path "$cadlClient") { Resolve-Path "$cadlClient" } Else { Resolve-Path "$cadlMain"}
253-
Add-Cadl $projectName $projectDirectory $mainCadlFile "--option @azure-tools/cadl-csharp.generateConvenienceAPI=true --option @azure-tools/cadl-csharp.unreferenced-types-handling=keepAll"
253+
Add-Cadl $projectName $projectDirectory $mainCadlFile "--option @azure-tools/cadl-csharp.generateConvenienceAPI=true"
254254
}
255255
}
256256

package-lock.json

Lines changed: 1093 additions & 834 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/AnomalyDetector/Generated/Configuration.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/AnomalyDetector/Generated/Models/AnomalyDetectionModel.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,17 @@
66
#nullable disable
77

88
using System;
9-
using Azure.Core;
109

1110
namespace AnomalyDetector.Models
1211
{
1312
/// <summary> Response of getting a model. </summary>
1413
public partial class AnomalyDetectionModel
1514
{
1615
/// <summary> Initializes a new instance of AnomalyDetectionModel. </summary>
17-
/// <param name="modelId"> Model identifier. </param>
1816
/// <param name="createdTime"> Date and time (UTC) when the model was created. </param>
1917
/// <param name="lastUpdatedTime"> Date and time (UTC) when the model was last updated. </param>
20-
/// <exception cref="ArgumentNullException"> <paramref name="modelId"/> is null. </exception>
21-
internal AnomalyDetectionModel(string modelId, DateTimeOffset createdTime, DateTimeOffset lastUpdatedTime)
18+
internal AnomalyDetectionModel(DateTimeOffset createdTime, DateTimeOffset lastUpdatedTime)
2219
{
23-
Argument.AssertNotNull(modelId, nameof(modelId));
24-
25-
ModelId = modelId;
2620
CreatedTime = createdTime;
2721
LastUpdatedTime = lastUpdatedTime;
2822
}

samples/AnomalyDetector/Generated/Models/ModelList.Serialization.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

samples/AnomalyDetector/Generated/Models/ModelList.cs

Lines changed: 0 additions & 54 deletions
This file was deleted.

samples/AnomalyDetector/Generated/Models/MultivariateDetectionResult.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ namespace AnomalyDetector.Models
1616
public partial class MultivariateDetectionResult
1717
{
1818
/// <summary> Initializes a new instance of MultivariateDetectionResult. </summary>
19-
/// <param name="resultId"> Result identifier, which is used to fetch the results of an inference call. </param>
2019
/// <param name="summary"> Multivariate anomaly detection status. </param>
2120
/// <param name="results"> Detection result for each timestamp. </param>
22-
/// <exception cref="ArgumentNullException"> <paramref name="resultId"/>, <paramref name="summary"/> or <paramref name="results"/> is null. </exception>
23-
internal MultivariateDetectionResult(string resultId, MultivariateBatchDetectionResultSummary summary, IEnumerable<AnomalyState> results)
21+
/// <exception cref="ArgumentNullException"> <paramref name="summary"/> or <paramref name="results"/> is null. </exception>
22+
internal MultivariateDetectionResult(MultivariateBatchDetectionResultSummary summary, IEnumerable<AnomalyState> results)
2423
{
25-
Argument.AssertNotNull(resultId, nameof(resultId));
2624
Argument.AssertNotNull(summary, nameof(summary));
2725
Argument.AssertNotNull(results, nameof(results));
2826

29-
ResultId = resultId;
3027
Summary = summary;
3128
Results = results.ToList();
3229
}

samples/AnomalyDetector/Generated/cadl.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@
930930
"IsNullable": false
931931
},
932932
"IsRequired": true,
933-
"IsReadOnly": false,
933+
"IsReadOnly": true,
934934
"IsDiscriminator": false
935935
},
936936
{
@@ -1783,7 +1783,7 @@
17831783
"IsNullable": false
17841784
},
17851785
"IsRequired": true,
1786-
"IsReadOnly": false,
1786+
"IsReadOnly": true,
17871787
"IsDiscriminator": false
17881788
},
17891789
{

samples/AnomalyDetector/multivariate/models.cadl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ enum ModelStatus {
5151
model MultivariateDetectionResult {
5252
@doc("Result identifier, which is used to fetch the results of an inference call.")
5353
@key
54+
@visibility("read")
5455
@format("uuid")
5556
resultId: string;
5657

@@ -309,6 +310,7 @@ epoch.
309310
model AnomalyDetectionModel {
310311
@doc("Model identifier.")
311312
@key
313+
@visibility("read")
312314
@format("uuid")
313315
modelId: string;
314316

src/AutoRest.CSharp/Common/Generation/Writers/SerializationWriter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ public void WriteSerialization(CodeWriter writer, TypeProvider schema)
2929
switch (schema)
3030
{
3131
case SerializableObjectType objectSchema:
32-
WriteObjectSerialization(writer, objectSchema);
32+
if (objectSchema.IncludeSerializer || objectSchema.IncludeDeserializer)
33+
{
34+
WriteObjectSerialization(writer, objectSchema);
35+
}
3336
break;
3437
case EnumType { IsExtensible: false } sealedChoiceSchema:
3538
WriteEnumSerialization(writer, sealedChoiceSchema);

0 commit comments

Comments
 (0)