Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11,544 changes: 5,797 additions & 5,747 deletions samples/AnomalyDetector/tspCodeModel.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/AutoRest.CSharp/Common/Input/CodeModelConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private InputNamespace CreateNamespace(Dictionary<ServiceRequest, InputOperation

return new(name: _codeModel.Language.Default.Name,
clients: clients,
constants: [],
enums: _enumsCache.Values.ToArray(),
models: models,
apiVersions: GetApiVersions(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@ internal record InputNamespace
{
public string Name { get; init; }
public IReadOnlyList<string> ApiVersions { get; init; }
public IReadOnlyList<InputLiteralType> Constants { get; init; }
public IReadOnlyList<InputEnumType> Enums { get; init; }
public IReadOnlyList<InputModelType> Models { get; init; }
private IReadOnlyList<InputClient> Clients { get; init; } // we should not be using this because this only contains the top level clients
public InputAuth Auth { get; init; }
public IReadOnlyList<InputClient> AllClients { get; init; }

public InputNamespace(string name, IReadOnlyList<string> apiVersions, IReadOnlyList<InputEnumType> enums, IReadOnlyList<InputModelType> models, IReadOnlyList<InputClient> clients, InputAuth auth)
public InputNamespace(string name, IReadOnlyList<string> apiVersions, IReadOnlyList<InputLiteralType> constants, IReadOnlyList<InputEnumType> enums, IReadOnlyList<InputModelType> models, IReadOnlyList<InputClient> clients, InputAuth auth)
{
Name = name;
ApiVersions = apiVersions;
Constants = constants;
Enums = enums;
Models = models;
Clients = clients;
Auth = auth;
AllClients = EnumerateClients(clients);
}

public InputNamespace() : this(name: string.Empty, apiVersions: Array.Empty<string>(), enums: Array.Empty<InputEnumType>(), models: Array.Empty<InputModelType>(), clients: Array.Empty<InputClient>(), auth: new InputAuth()) { }
public InputNamespace() : this(name: string.Empty, apiVersions: Array.Empty<string>(), constants: Array.Empty<InputLiteralType>(), enums: Array.Empty<InputEnumType>(), models: Array.Empty<InputModelType>(), clients: Array.Empty<InputClient>(), auth: new InputAuth()) { }

private static IReadOnlyList<InputClient> EnumerateClients(IEnumerable<InputClient> clients)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ public override void Write(Utf8JsonWriter writer, InputNamespace value, JsonSeri
IReadOnlyList<InputEnumType>? enums = null;
IReadOnlyList<InputModelType>? models = null;
IReadOnlyList<InputClient>? clients = null;
IReadOnlyList<InputLiteralType>? constants = null;
InputAuth? auth = null;

while (reader.TokenType != JsonTokenType.EndObject)
{
var isKnownProperty = reader.TryReadString("name", ref name)
|| reader.TryReadComplexType("apiVersions", options, ref apiVersions)
|| reader.TryReadComplexType("constants", options, ref constants)
|| reader.TryReadComplexType("enums", options, ref enums)
|| reader.TryReadComplexType("models", options, ref models)
|| reader.TryReadComplexType("clients", options, ref clients)
Expand All @@ -55,6 +57,7 @@ public override void Write(Utf8JsonWriter writer, InputNamespace value, JsonSeri
return new InputNamespace(
name ?? throw new JsonException(),
apiVersions ?? [],
constants ?? [],
enums ?? [],
models ?? [],
clients ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ export function transformCodeModel(codeModel: CodeModel): CodeModel {
}
}
}
return {
...codeModel,
constants: undefined // TODO -- this is a workaround to reduce the amount of changes in our tspCodeModel.json file. We could remove it later
} as unknown as CodeModel;
return codeModel;
}

interface DecoratedType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public void ModelTypeCollectionProperties(string expectedModelCodes, string expe
},
null, new List<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.ModelCollectionProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { elementModelType, collectionModelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.ModelCollectionProperties.Models", [], [], [], [elementModelType, collectionModelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("ModelCollectionModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand All @@ -88,8 +87,7 @@ public void ModelType2DCollectionProperties(string expectedModelCodes, string ex
},
null, new List<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.ModelCollectionProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { elementModelType, collectionModelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.ModelCollectionProperties.Models", [], [], [], [elementModelType, collectionModelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("ModelCollectionModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public void RoundTripDictionaryProperties(string expectedModelCodes, string expe
var model = new InputModelType("RoundTripModel", "Cadl.TestServer.DictionaryProperties.Models", "public", null, null, "Round-trip model with dictionary properties", InputModelTypeUsage.Input | InputModelTypeUsage.Output,
DictionaryProperties, null, new List<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.DictionaryProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { model, ElementModelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.DictionaryProperties.Models", [], [], [], [model, ElementModelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("RoundTripModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand All @@ -29,8 +28,7 @@ public void InputDictionaryProperties(string expectedModelCodes, string expected
var model = new InputModelType("InputModel", "Cadl.TestServer.DictionaryProperties.Models", "public", null, null, "Input model with dictionary properties", InputModelTypeUsage.Input,
DictionaryProperties, null, new List<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.DictionaryProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { model, ElementModelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.DictionaryProperties.Models", [], [], [], [model, ElementModelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("InputModel", expectedModelCodes, expectedSerializationCodes, library);

Expand All @@ -42,8 +40,7 @@ public void OutputDictionaryProperties(string expectedModelCodes, string expecte
var model = new InputModelType("OutputModel", "Cadl.TestServer.DictionaryProperties.Models", "public", null, null, "Output model with dictionary properties", InputModelTypeUsage.Output,
DictionaryProperties, null, new List<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.DictionaryProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { model, ElementModelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.DictionaryProperties.Models", [], [], [], [model, ElementModelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("OutputModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public void RoundTripEnumProperties(string expectedModelCodes, string expectedSe
new InputModelProperty("Language", "Language", string.Empty, "Required string enum value.", ExtensibleEnumType, null, true, false, false)
},
null, new List<InputModelType>(), null, null, null, null);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.EnumPropertiesBasic", new List<string>(),
new List<InputEnumType> { FixedEnumType, ExtensibleEnumType }, new List<InputModelType> { modelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.EnumPropertiesBasic", [], [], [FixedEnumType, ExtensibleEnumType], [modelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("RoundTripModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand All @@ -55,8 +54,7 @@ public void InputEnumProperties(string expectedModelCodes, string expectedSerial
new InputModelProperty("Language", "Language", string.Empty, "Required string enum value.", ExtensibleEnumType, null, true, false, false)
},
null, new List<InputModelType>(), null, null, null, null);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.EnumPropertiesBasic", new List<string>(),
new List<InputEnumType> { FixedEnumType, ExtensibleEnumType }, new List<InputModelType> { modelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.EnumPropertiesBasic", [], [], [FixedEnumType, ExtensibleEnumType], [modelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("InputModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand All @@ -71,8 +69,7 @@ public void OutputEnumProperties(string expectedModelCodes, string expectedSeria
new InputModelProperty("Language", "Language", string.Empty, "Required string enum value.", ExtensibleEnumType, null, true, false, false)
},
null, new List<InputModelType>(), null, null, null, null);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.EnumPropertiesBasic", new List<string>(),
new List<InputEnumType> { FixedEnumType, ExtensibleEnumType }, new List<InputModelType> { modelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.EnumPropertiesBasic", [], [], [FixedEnumType, ExtensibleEnumType], [modelType], new List<InputClient>(), new InputAuth()), default).Build(true);

ValidateGeneratedCodes("OutputModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public void RoundTripModel(string expectedModelCodes, string expectedSerializati
},
null, new List<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("NestedModelsBasic.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { model, NestedRoundTripOnlyModelType, NestedRoundTripSharedModelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("NestedModelsBasic.Models", [], [], [], [model, NestedRoundTripOnlyModelType, NestedRoundTripSharedModelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("RoundTripModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand All @@ -40,8 +39,7 @@ public void InputModel(string expectedModelCodes, string expectedSerializationCo
},
null, new List<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("NestedModelsBasic.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { model, NestedInputOnlyModelType, NestedRoundTripSharedModelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("NestedModelsBasic.Models", [], [], [], [model, NestedInputOnlyModelType, NestedRoundTripSharedModelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("InputModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand All @@ -58,8 +56,7 @@ public void OutpuModel(string expectedModelCodes, string expectedSerializationCo
},
null, new List<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("NestedModelsBasic.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { model, NestedOutputOnlyModelType, NestedRoundTripSharedModelType }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("NestedModelsBasic.Models", [], [], [], [model, NestedOutputOnlyModelType, NestedRoundTripSharedModelType], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("OutputModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public void RoundTripModel(string expectedModelCodes, string expectedSerializati
var model = new InputModelType("RoundTripModel", "Cadl.TestServer.OptionalProperties.Models", "public", null, null, "Round-trip model with optional properties.", InputModelTypeUsage.Input | InputModelTypeUsage.Output,
OptionalProperties, null, Array.Empty<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.OptionalProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { ElementModelType, model }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.OptionalProperties.Models", [], [], [], [ElementModelType, model], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("RoundTripModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand All @@ -28,8 +27,7 @@ public void InputModel(string expectedModelCodes, string expectedSerializationCo
var model = new InputModelType("InputModel", "Cadl.TestServer.OptionalProperties.Models", "public", null, null, "Input model with optional properties.", InputModelTypeUsage.Input,
OptionalProperties, null, Array.Empty<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.OptionalProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { ElementModelType, model }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.OptionalProperties.Models", [], [], [], [ElementModelType, model], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("InputModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand All @@ -41,8 +39,7 @@ public void OutputModel(string expectedModelCodes, string expectedSerializationC
var model = new InputModelType("OutputModel", "Cadl.TestServer.OptionalProperties.Models", "public", null, null, "Output model with optional properties.", InputModelTypeUsage.Output,
OptionalProperties, null, Array.Empty<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.OptionalProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { ElementModelType, model }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.OptionalProperties.Models", [], [], [], [ElementModelType, model], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("OutputModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public void RoundTripModel(string expectedModelCodes, string expectedSerializati
var model = new InputModelType("RoundTripModel", "Cadl.TestServer.ReadonlyProperties.Models", "public", null, null, "Readonly model", InputModelTypeUsage.Input | InputModelTypeUsage.Output,
ReadOnlyProperties, null, Array.Empty<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.ReadonlyProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { ReadonlyModel, model }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.ReadonlyProperties.Models", [], [], [], [ReadonlyModel, model], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("RoundTripModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand All @@ -28,8 +27,7 @@ public void OutputModel(string expectedModelCodes, string expectedSerializationC
var model = new InputModelType("OutputModel", "Cadl.TestServer.ReadonlyProperties.Models", "public", null, null, "Readonly model", InputModelTypeUsage.Output,
ReadOnlyProperties, null, Array.Empty<InputModelType>(), null, null, null, null);

var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.ReadonlyProperties.Models", new List<string>(),
new List<InputEnumType>(), new List<InputModelType> { ReadonlyModel, model }, new List<InputClient>(), new InputAuth()), default).Build(true);
var library = new DpgOutputLibraryBuilder(new InputNamespace("Cadl.TestServer.ReadonlyProperties.Models", [], [], [], [ReadonlyModel, model], [], new InputAuth()), default).Build(true);

ValidateGeneratedCodes("OutputModel", expectedModelCodes, expectedSerializationCodes, library);
}
Expand Down
Loading