From 11d6f4950649bbc68507a02abe5ce91e55c94fe7 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:27:43 -0800 Subject: [PATCH] Adopt versioning Cadl-Ranch specs (#5273) Fixes https://github.com/microsoft/typespec/issues/3965 Filed https://github.com/Azure/cadl-ranch/issues/779 as versioning is implemented in tsp compiler. --------- Co-authored-by: Jorge Rangel <102122018+jorgerangel-msft@users.noreply.github.com> --- .../eng/scripts/Generate.ps1 | 12 +- .../eng/scripts/Generation.psm1 | 50 +- .../eng/scripts/Get-CadlRanch-Coverage.ps1 | 8 + .../eng/scripts/Test-CadlRanch.ps1 | 16 +- .../src/InputTypes/InputParameter.cs | 6 +- .../src/Properties/launchSettings.json | 60 ++ .../Added/V1/VersioningAddedV1Tests.cs | 56 + .../Added/V2/VersioningAddedV2Tests.cs | 91 ++ .../V1/VersioningMadeOptionalV1Tests.cs | 22 + .../V2/VersioningMadeOptionalV2Tests.cs | 33 + .../Removed/V1/VersioningRemovedV1Tests.cs | 43 + .../Removed/V2/VersioningRemovedV2Tests.cs | 81 ++ .../VersioningRemovedV2PreviewTests.cs | 22 + .../V1/VersioningRenamedFromV1Tests.cs | 49 + .../V2/VersioningRenamedFromV2Tests.cs | 73 ++ .../VersioningReturnTypeChangedFromV2Tests.cs | 20 + .../V2/VersioningTypeChangedFromV2Tests.cs | 23 + .../versioning/added/v1/Configuration.json | 6 + .../added/v1/Versioning.Added.V1.sln | 48 + .../added/v1/src/Generated/AddedClient.cs | 32 + .../v1/src/Generated/AddedClientOptions.cs | 21 + .../added/v1/src/Generated/Models/EnumV1.cs | 12 + .../Generated/Models/ModelV1.Serialization.cs | 36 + .../added/v1/src/Generated/Models/ModelV1.cs | 23 + .../VersioningAddedV1ModelFactory.cs | 11 + .../added/v1/src/Versioning.Added.V1.csproj | 16 + .../versioning/added/v1/tspCodeModel.json | 292 ++++++ .../versioning/added/v2/Configuration.json | 6 + .../added/v2/Versioning.Added.V2.sln | 48 + .../added/v2/src/Generated/AddedClient.cs | 42 + .../v2/src/Generated/AddedClientOptions.cs | 23 + .../added/v2/src/Generated/InterfaceV2.cs | 27 + .../added/v2/src/Generated/Models/EnumV1.cs | 14 + .../added/v2/src/Generated/Models/EnumV2.cs | 12 + .../Generated/Models/ModelV1.Serialization.cs | 36 + .../added/v2/src/Generated/Models/ModelV1.cs | 31 + .../Generated/Models/ModelV2.Serialization.cs | 36 + .../added/v2/src/Generated/Models/ModelV2.cs | 31 + .../VersioningAddedV2ModelFactory.cs | 15 + .../added/v2/src/Versioning.Added.V2.csproj | 16 + .../versioning/added/v2/tspCodeModel.json | 774 ++++++++++++++ .../madeOptional/v1/Configuration.json | 6 + .../v1/Versioning.MadeOptional.V1.sln | 48 + .../v1/src/Generated/MadeOptionalClient.cs | 32 + .../Generated/MadeOptionalClientOptions.cs | 21 + .../Models/TestModel.Serialization.cs | 36 + .../v1/src/Generated/Models/TestModel.cs | 23 + .../VersioningMadeOptionalV1ModelFactory.cs | 11 + .../v1/src/Versioning.MadeOptional.V1.csproj | 16 + .../madeOptional/v1/tspCodeModel.json | 281 +++++ .../madeOptional/v2/Configuration.json | 6 + .../v2/Versioning.MadeOptional.V2.sln | 48 + .../v2/src/Generated/MadeOptionalClient.cs | 32 + .../Generated/MadeOptionalClientOptions.cs | 23 + .../Models/TestModel.Serialization.cs | 36 + .../v2/src/Generated/Models/TestModel.cs | 23 + .../VersioningMadeOptionalV2ModelFactory.cs | 11 + .../v2/src/Versioning.MadeOptional.V2.csproj | 16 + .../madeOptional/v2/tspCodeModel.json | 300 ++++++ .../versioning/removed/v1/Configuration.json | 6 + .../removed/v1/Versioning.Removed.V1.sln | 48 + .../removed/v1/src/Generated/InterfaceV1.cs | 27 + .../removed/v1/src/Generated/Models/EnumV1.cs | 12 + .../removed/v1/src/Generated/Models/EnumV2.cs | 14 + .../removed/v1/src/Generated/Models/EnumV3.cs | 14 + .../Generated/Models/ModelV1.Serialization.cs | 36 + .../v1/src/Generated/Models/ModelV1.cs | 31 + .../Generated/Models/ModelV2.Serialization.cs | 36 + .../v1/src/Generated/Models/ModelV2.cs | 37 + .../Generated/Models/ModelV3.Serialization.cs | 36 + .../v1/src/Generated/Models/ModelV3.cs | 23 + .../removed/v1/src/Generated/RemovedClient.cs | 50 + .../v1/src/Generated/RemovedClientOptions.cs | 21 + .../VersioningRemovedV1ModelFactory.cs | 17 + .../v1/src/Versioning.Removed.V1.csproj | 16 + .../versioning/removed/v1/tspCodeModel.json | 990 ++++++++++++++++++ .../versioning/removed/v2/Configuration.json | 6 + .../removed/v2/Versioning.Removed.V2.sln | 48 + .../removed/v2/src/Generated/Models/EnumV2.cs | 12 + .../removed/v2/src/Generated/Models/EnumV3.cs | 14 + .../Generated/Models/ModelV2.Serialization.cs | 36 + .../v2/src/Generated/Models/ModelV2.cs | 31 + .../Generated/Models/ModelV3.Serialization.cs | 36 + .../v2/src/Generated/Models/ModelV3.cs | 23 + .../removed/v2/src/Generated/RemovedClient.cs | 40 + .../v2/src/Generated/RemovedClientOptions.cs | 25 + .../VersioningRemovedV2ModelFactory.cs | 15 + .../v2/src/Versioning.Removed.V2.csproj | 16 + .../versioning/removed/v2/tspCodeModel.json | 571 ++++++++++ .../removed/v2Preview/Configuration.json | 6 + .../Versioning.Removed.V2Preview.sln | 48 + .../v2Preview/src/Generated/InterfaceV1.cs | 27 + .../v2Preview/src/Generated/Models/EnumV1.cs | 12 + .../v2Preview/src/Generated/Models/EnumV2.cs | 14 + .../Generated/Models/ModelV1.Serialization.cs | 36 + .../v2Preview/src/Generated/Models/ModelV1.cs | 31 + .../Generated/Models/ModelV2.Serialization.cs | 36 + .../v2Preview/src/Generated/Models/ModelV2.cs | 37 + .../Generated/Models/ModelV3.Serialization.cs | 36 + .../v2Preview/src/Generated/Models/ModelV3.cs | 17 + .../v2Preview/src/Generated/RemovedClient.cs | 50 + .../src/Generated/RemovedClientOptions.cs | 23 + .../VersioningRemovedV2PreviewModelFactory.cs | 17 + .../src/Versioning.Removed.V2Preview.csproj | 16 + .../removed/v2Preview/tspCodeModel.json | 941 +++++++++++++++++ .../renamedFrom/v1/Configuration.json | 6 + .../v1/Versioning.RenamedFrom.V1.sln | 48 + .../v1/src/Generated/Models/OldEnum.cs | 12 + .../Models/OldModel.Serialization.cs | 36 + .../v1/src/Generated/Models/OldModel.cs | 31 + .../v1/src/Generated/OldInterface.cs | 27 + .../v1/src/Generated/RenamedFromClient.cs | 34 + .../src/Generated/RenamedFromClientOptions.cs | 21 + .../VersioningRenamedFromV1ModelFactory.cs | 13 + .../v1/src/Versioning.RenamedFrom.V1.csproj | 16 + .../renamedFrom/v1/tspCodeModel.json | 515 +++++++++ .../renamedFrom/v2/Configuration.json | 6 + .../v2/Versioning.RenamedFrom.V2.sln | 48 + .../v2/src/Generated/Models/NewEnum.cs | 12 + .../Models/NewModel.Serialization.cs | 36 + .../v2/src/Generated/Models/NewModel.cs | 31 + .../v2/src/Generated/NewInterface.cs | 27 + .../v2/src/Generated/RenamedFromClient.cs | 34 + .../src/Generated/RenamedFromClientOptions.cs | 23 + .../VersioningRenamedFromV2ModelFactory.cs | 13 + .../v2/src/Versioning.RenamedFrom.V2.csproj | 16 + .../renamedFrom/v2/tspCodeModel.json | 534 ++++++++++ .../v1/Configuration.json | 6 + .../Versioning.ReturnTypeChangedFrom.V1.sln | 48 + .../Generated/ReturnTypeChangedFromClient.cs | 31 + .../ReturnTypeChangedFromClientOptions.cs | 21 + ...Versioning.ReturnTypeChangedFrom.V1.csproj | 16 + .../v1/tspCodeModel.json | 219 ++++ .../v2/Configuration.json | 6 + .../Versioning.ReturnTypeChangedFrom.V2.sln | 48 + .../Generated/ReturnTypeChangedFromClient.cs | 31 + .../ReturnTypeChangedFromClientOptions.cs | 23 + ...Versioning.ReturnTypeChangedFrom.V2.csproj | 16 + .../v2/tspCodeModel.json | 238 +++++ .../typeChangedFrom/v1/Configuration.json | 6 + .../v1/Versioning.TypeChangedFrom.V1.sln | 48 + .../Models/TestModel.Serialization.cs | 36 + .../v1/src/Generated/Models/TestModel.cs | 23 + .../v1/src/Generated/TypeChangedFromClient.cs | 32 + .../Generated/TypeChangedFromClientOptions.cs | 21 + ...VersioningTypeChangedFromV1ModelFactory.cs | 11 + .../src/Versioning.TypeChangedFrom.V1.csproj | 16 + .../typeChangedFrom/v1/tspCodeModel.json | 281 +++++ .../typeChangedFrom/v2/Configuration.json | 6 + .../v2/Versioning.TypeChangedFrom.V2.sln | 48 + .../Models/TestModel.Serialization.cs | 36 + .../v2/src/Generated/Models/TestModel.cs | 23 + .../v2/src/Generated/TypeChangedFromClient.cs | 32 + .../Generated/TypeChangedFromClientOptions.cs | 23 + ...VersioningTypeChangedFromV2ModelFactory.cs | 11 + .../src/Versioning.TypeChangedFrom.V2.csproj | 16 + .../typeChangedFrom/v2/tspCodeModel.json | 300 ++++++ 157 files changed, 10076 insertions(+), 11 deletions(-) create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Added/V1/VersioningAddedV1Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Added/V2/VersioningAddedV2Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/MadeOptional/V1/VersioningMadeOptionalV1Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/MadeOptional/V2/VersioningMadeOptionalV2Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V1/VersioningRemovedV1Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V2/VersioningRemovedV2Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V2Preview/VersioningRemovedV2PreviewTests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/RenamedFrom/V1/VersioningRenamedFromV1Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/RenamedFrom/V2/VersioningRenamedFromV2Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/ReturnTypeChangedFrom/V2/VersioningReturnTypeChangedFromV2Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/TypeChangedFrom/V2/VersioningTypeChangedFromV2Tests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/Versioning.Added.V1.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/AddedClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/AddedClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/EnumV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/ModelV1.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/ModelV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/VersioningAddedV1ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Versioning.Added.V1.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/Versioning.Added.V2.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/AddedClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/AddedClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/InterfaceV2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/EnumV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/EnumV2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV1.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV2.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/VersioningAddedV2ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Versioning.Added.V2.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/Versioning.MadeOptional.V1.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/MadeOptionalClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/MadeOptionalClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/Models/TestModel.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/Models/TestModel.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/VersioningMadeOptionalV1ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Versioning.MadeOptional.V1.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/Versioning.MadeOptional.V2.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/MadeOptionalClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/MadeOptionalClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/Models/TestModel.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/Models/TestModel.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/VersioningMadeOptionalV2ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Versioning.MadeOptional.V2.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/Versioning.Removed.V1.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/InterfaceV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV3.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV1.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV2.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV3.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV3.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/RemovedClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/RemovedClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/VersioningRemovedV1ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Versioning.Removed.V1.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/Versioning.Removed.V2.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/EnumV2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/EnumV3.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV2.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV3.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV3.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/RemovedClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/RemovedClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/VersioningRemovedV2ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Versioning.Removed.V2.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/Versioning.Removed.V2Preview.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/InterfaceV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/EnumV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/EnumV2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV1.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV2.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV3.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV3.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/RemovedClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/RemovedClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/VersioningRemovedV2PreviewModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Versioning.Removed.V2Preview.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/Versioning.RenamedFrom.V1.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldEnum.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldModel.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldModel.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/OldInterface.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/RenamedFromClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/RenamedFromClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/VersioningRenamedFromV1ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Versioning.RenamedFrom.V1.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/Versioning.RenamedFrom.V2.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewEnum.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewModel.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewModel.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/NewInterface.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/RenamedFromClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/RenamedFromClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/VersioningRenamedFromV2ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Versioning.RenamedFrom.V2.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/Versioning.ReturnTypeChangedFrom.V1.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Generated/ReturnTypeChangedFromClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Generated/ReturnTypeChangedFromClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Versioning.ReturnTypeChangedFrom.V1.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/Versioning.ReturnTypeChangedFrom.V2.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Generated/ReturnTypeChangedFromClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Generated/ReturnTypeChangedFromClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Versioning.ReturnTypeChangedFrom.V2.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/Versioning.TypeChangedFrom.V1.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/Models/TestModel.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/Models/TestModel.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/TypeChangedFromClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/TypeChangedFromClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/VersioningTypeChangedFromV1ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Versioning.TypeChangedFrom.V1.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/tspCodeModel.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/Versioning.TypeChangedFrom.V2.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/Models/TestModel.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/Models/TestModel.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/TypeChangedFromClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/TypeChangedFromClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/VersioningTypeChangedFromV2ModelFactory.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Versioning.TypeChangedFrom.V2.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/tspCodeModel.json diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index 6dd27b46fc..ee44432ff6 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -79,10 +79,6 @@ foreach ($directory in $directories) { continue } - if ($folders.Contains("versioning")) { - continue # TODO: adopt versioning cadl ranch specs https://github.com/microsoft/typespec/issues/3965 - } - if ($failingSpecs.Contains($subPath)) { Write-Host "Skipping $subPath" -ForegroundColor Yellow continue @@ -97,11 +93,19 @@ foreach ($directory in $directories) { if (-not (Test-Path $generationDir)) { New-Item -ItemType Directory -Path $generationDir | Out-Null } + + if ($folders.Contains("versioning")) { + Generate-Versioning $directory.FullName $generationDir -generateStub $stubbed + $cadlRanchLaunchProjects.Add($($folders -join "-") + "-v1", $("TestProjects/CadlRanch/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v1") + $cadlRanchLaunchProjects.Add($($folders -join "-") + "-v2", $("TestProjects/CadlRanch/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v2") + continue + } $cadlRanchLaunchProjects.Add(($folders -join "-"), ("TestProjects/CadlRanch/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))")) if ($LaunchOnly) { continue } + Write-Host "Generating $subPath" -ForegroundColor Cyan Invoke (Get-TspCommand $specFile $generationDir $stubbed) diff --git a/packages/http-client-csharp/eng/scripts/Generation.psm1 b/packages/http-client-csharp/eng/scripts/Generation.psm1 index cb4cc9403d..a2c6af5274 100644 --- a/packages/http-client-csharp/eng/scripts/Generation.psm1 +++ b/packages/http-client-csharp/eng/scripts/Generation.psm1 @@ -25,7 +25,8 @@ function Get-TspCommand { [string]$specFile, [string]$generationDir, [bool]$generateStub = $false, - [string]$namespaceOverride = $null + [string]$namespaceOverride = $null, + [string]$apiVersion = $null ) $command = "npx tsp compile $specFile" $command += " --trace @typespec/http-client-csharp" @@ -43,6 +44,10 @@ function Get-TspCommand { if ($namespaceOverride) { $command += " --option @typespec/http-client-csharp.namespace=$namespaceOverride" } + + if ($apiVersion) { + $command += " --option @typespec/http-client-csharp.api-version=$apiVersion" + } return $command } @@ -101,9 +106,52 @@ function Generate-Srv-Driven { } } +function Generate-Versioning { + param ( + [string]$specFilePath, + [string]$outputDir, + [bool]$generateStub = $false, + [bool]$createOutputDirIfNotExist = $true + ) + + $v1Dir = $(Join-Path $outputDir "v1") + if ($createOutputDirIfNotExist -and -not (Test-Path $v1Dir)) { + New-Item -ItemType Directory -Path $v1Dir | Out-Null + } + + $v2Dir = $(Join-Path $outputDir "v2") + if ($createOutputDirIfNotExist -and -not (Test-Path $v2Dir)) { + New-Item -ItemType Directory -Path $v2Dir | Out-Null + } + $outputFolders = $outputDir.Split([System.IO.Path]::DirectorySeparatorChar) + ## get the last two directories of the output directory and add V1/V2 to disambiguate the namespaces + $namespaceRoot = $(($outputFolders[-2..-1] | ` + ForEach-Object { $_.Substring(0,1).ToUpper() + $_.Substring(1) }) -join ".") + $v1NamespaceOverride = $namespaceRoot + ".V1" + $v2NamespaceOverride = $namespaceRoot + ".V2" + + Invoke (Get-TspCommand $specFilePath $v1Dir -generateStub $generateStub -apiVersion "v1" -namespaceOverride $v1NamespaceOverride) + Invoke (Get-TspCommand $specFilePath $v2Dir -generateStub $generateStub -apiVersion "v2" -namespaceOverride $v2NamespaceOverride) + + if ($outputFolders.Contains("removed")) { + $v2PreviewDir = $(Join-Path $outputDir "v2Preview") + if ($createOutputDirIfNotExist -and -not (Test-Path $v2PreviewDir)) { + New-Item -ItemType Directory -Path $v2PreviewDir | Out-Null + } + $v2PreviewNamespaceOverride = $namespaceRoot + ".V2Preview" + Invoke (Get-TspCommand $specFilePath $v2PreviewDir -generateStub $generateStub -apiVersion "v2preview" -namespaceOverride $v2PreviewNamespaceOverride) + } + + # exit if the generation failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } +} + Export-ModuleMember -Function "Invoke" Export-ModuleMember -Function "Get-TspCommand" Export-ModuleMember -Function "Refresh-Build" Export-ModuleMember -Function "Compare-Paths" Export-ModuleMember -Function "Generate-Srv-Driven" +Export-ModuleMember -Function "Generate-Versioning" diff --git a/packages/http-client-csharp/eng/scripts/Get-CadlRanch-Coverage.ps1 b/packages/http-client-csharp/eng/scripts/Get-CadlRanch-Coverage.ps1 index d658580088..da844ced98 100644 --- a/packages/http-client-csharp/eng/scripts/Get-CadlRanch-Coverage.ps1 +++ b/packages/http-client-csharp/eng/scripts/Get-CadlRanch-Coverage.ps1 @@ -37,6 +37,14 @@ foreach ($directory in $directories) { if (-not (Test-Path $specFile)) { $specFile = Join-Path $specsDirectory $subPath "main.tsp" } + + if ($subPath.Contains("versioning")) { + if ($subPath.Contains("v1")) { + # this will generate v1 and v2 so we only need to call it once for one of the versions + Generate-Versioning ($(Join-Path $specsDirectory $subPath) | Split-Path) $($outputDir | Split-Path) -createOutputDirIfNotExist $false + } + continue + } $command = Get-TspCommand $specFile $outputDir Invoke $command diff --git a/packages/http-client-csharp/eng/scripts/Test-CadlRanch.ps1 b/packages/http-client-csharp/eng/scripts/Test-CadlRanch.ps1 index 378bab6793..65266e5ac8 100644 --- a/packages/http-client-csharp/eng/scripts/Test-CadlRanch.ps1 +++ b/packages/http-client-csharp/eng/scripts/Test-CadlRanch.ps1 @@ -59,10 +59,19 @@ foreach ($directory in $directories) { $specFile = Join-Path $specsDirectory $subPath "client.tsp" if (-not (Test-Path $specFile)) { $specFile = Join-Path $specsDirectory $subPath "main.tsp" + } + + if ($subPath.Contains("versioning")) { + if ($subPath.Contains("v1")) { + # this will generate v1 and v2 so we only need to call it once for one of the versions + Generate-Versioning ($(Join-Path $specsDirectory $subPath) | Split-Path) $($outputDir | Split-Path) -createOutputDirIfNotExist $false + } } - - $command = Get-TspCommand $specFile $outputDir - Invoke $command + else { + $command = Get-TspCommand $specFile $outputDir + Invoke $command + } + # exit if the generation failed if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE @@ -73,7 +82,6 @@ foreach ($directory in $directories) { Generate-Srv-Driven $(Join-Path $specsDirectory $subPath) $outputDir -createOutputDirIfNotExist $false } - Write-Host "Testing $subPath" -ForegroundColor Cyan $command = "dotnet test $cadlRanchCsproj --filter `"FullyQualifiedName~$testFilter`"" Invoke $command diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs index 305bf310b5..5c15b2eab1 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputParameter.cs @@ -7,6 +7,8 @@ namespace Microsoft.Generator.CSharp.Input { public sealed class InputParameter { + private readonly bool _isApiVersion; + public InputParameter( string name, string nameInRequest, @@ -33,7 +35,7 @@ public InputParameter( DefaultValue = defaultValue; Kind = kind; IsRequired = isRequired; - IsApiVersion = isApiVersion; + _isApiVersion = isApiVersion; IsResourceParameter = isResourceParameter; IsContentType = isContentType; IsEndpoint = isEndpoint; @@ -51,7 +53,7 @@ public InputParameter( public InputConstant? DefaultValue { get; } public InputOperationParameterKind Kind { get; } public bool IsRequired { get; } - public bool IsApiVersion { get; } + public bool IsApiVersion => _isApiVersion || Type is InputEnumType enumType && enumType.Usage.HasFlag(InputModelTypeUsage.ApiVersionEnum); public bool IsResourceParameter { get; } public bool IsContentType { get; } public bool IsEndpoint { get; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Properties/launchSettings.json b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Properties/launchSettings.json index a813937b29..a8e2843798 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Properties/launchSettings.json +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Properties/launchSettings.json @@ -260,6 +260,66 @@ "commandName": "Executable", "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" }, + "http-versioning-added-v1": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/added/v1 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-added-v2": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/added/v2 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-madeOptional-v1": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/madeOptional/v1 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-madeOptional-v2": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/madeOptional/v2 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-removed-v1": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/removed/v1 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-removed-v2": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/removed/v2 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-renamedFrom-v1": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/renamedFrom/v1 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-renamedFrom-v2": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/renamedFrom/v2 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-returnTypeChangedFrom-v1": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-returnTypeChangedFrom-v2": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-typeChangedFrom-v1": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, + "http-versioning-typeChangedFrom-v2": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2 -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, "Unbranded-TypeSpec": { "commandLineArgs": "$(SolutionDir)/TestProjects/Local/Unbranded-TypeSpec -p ClientModelPlugin", "commandName": "Executable", diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Added/V1/VersioningAddedV1Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Added/V1/VersioningAddedV1Tests.cs new file mode 100644 index 0000000000..785e980779 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Added/V1/VersioningAddedV1Tests.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using NUnit.Framework; +using System; +using System.Linq; +using Versioning.Added.V1; +using Versioning.Added.V1.Models; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.Added.V1 +{ + public class VersioningAddedV1Tests : CadlRanchTestBase + { + [CadlRanchTest] + public void TestAddedMembersV1Client() + { + /* verify ModelV1. */ + var properties = typeof(ModelV1).GetProperties(); + Assert.IsNotNull(properties); + Assert.AreEqual(2, properties.Length); + /* verify property UnionProp added in V2 is not present.*/ + Assert.IsNull(typeof(ModelV1).GetProperty("UnionProp")); + + /* verify EnumV1. */ + Assert.True(typeof(EnumV1).IsEnum); + var enumValues = typeof(EnumV1).GetEnumNames(); + Assert.IsNotNull(enumValues); + Assert.AreEqual(1, enumValues.Length); + /* verify added enum value EnumMemberV2. */ + Assert.IsFalse(enumValues.Contains("EnumMemberV2")); + + /* check existence of the added model ModelV2. */ + Assert.IsNull(Type.GetType("Versioning.Added.V1.Models.ModelV2")); + + /* check existence of the added enum EnumV2. */ + Assert.IsNull(Type.GetType("Versioning.Added.V1.Models.EnumV2")); + + /* check the added parameter. */ + var methods = typeof(AddedClient).GetMethods().Where(m => m.Name == "V1" || m.Name == "V1Async"); + Assert.IsNotNull(methods); + Assert.AreEqual(4, methods.Count()); + var methodsArray = methods.ToArray(); + foreach (var method in methodsArray) + { + Assert.IsFalse(method.GetParameters().Any(p => p.Name == "headerV2")); + } + + /* check the existence of added method in V2. */ + var addedMethods = typeof(AddedClient).GetMethods().Where(m => m.Name == "V2" || m.Name == "V2Async"); + Assert.IsEmpty(addedMethods); + + /* check the existence of added interface in V2. */ + Assert.IsNull(Type.GetType("Versioning.Added.V1.InterfaceV2")); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Added/V2/VersioningAddedV2Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Added/V2/VersioningAddedV2Tests.cs new file mode 100644 index 0000000000..ace5b75b5d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Added/V2/VersioningAddedV2Tests.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading.Tasks; +using NUnit.Framework; +using System; +using System.Linq; +using Versioning.Added.V2; +using Versioning.Added.V2.Models; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.Added.V2 +{ + public class VersioningAddedV2Tests : CadlRanchTestBase + { + [CadlRanchTest] + public void TestAddedMembersV2Client() + { + /* verify ModelV1. */ + var properties = typeof(ModelV1).GetProperties(); + Assert.IsNotNull(properties); + Assert.AreEqual(3, properties.Length); + /* verify added property UnionProp in V2.*/ + Assert.IsNotNull(typeof(ModelV1).GetProperty("UnionProp")); + + /* verify EnumV1. */ + Assert.True(typeof(EnumV1).IsEnum); + var enumValues = typeof(EnumV1).GetEnumNames(); + Assert.IsNotNull(enumValues); + Assert.AreEqual(2, enumValues.Length); + /* verify added enum value EnumMemberV2. */ + Assert.IsTrue(enumValues.Contains("EnumMemberV2")); + + /* check existence of the added model ModelV2. */ + Assert.IsNotNull(Type.GetType("Versioning.Added.V2.Models.ModelV2")); + + /* check existence of the added enum EnumV2. */ + Assert.IsNotNull(Type.GetType("Versioning.Added.V2.Models.EnumV2")); + + /* check the added parameter. */ + var methods = typeof(AddedClient).GetMethods().Where(m => m.Name == "V1" || m.Name == "V1Async"); + Assert.IsNotNull(methods); + Assert.AreEqual(4, methods.Count()); + var methodsArray = methods.ToArray(); + foreach (var method in methodsArray) + { + Assert.IsTrue(method.GetParameters().Any(p => p.Name == "headerV2")); + } + + /* check the existence of added method in V2. */ + var addedMethods = typeof(AddedClient).GetMethods().Where(m => m.Name == "V2" || m.Name == "V2Async"); + Assert.IsNotNull(addedMethods); + Assert.AreEqual(4, addedMethods.Count()); + + /* check the existence of added interface in V2. */ + Assert.IsNotNull(Type.GetType("Versioning.Added.V2.InterfaceV2")); + } + + [CadlRanchTest] + public Task Versioning_Added_v1() => Test(async (host) => + { + ModelV1 modelV1 = new ModelV1("foo", EnumV1.EnumMemberV2, BinaryData.FromObjectAsJson(10)); + var response = await new AddedClient(host).V1Async("bar", modelV1); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("foo", response.Value.Prop); + Assert.AreEqual(EnumV1.EnumMemberV2, response.Value.EnumProp); + Assert.AreEqual(10, response.Value.UnionProp.ToObjectFromJson()); + }); + + [CadlRanchTest] + public Task Versioning_Added_v2() => Test(async (host) => + { + ModelV2 modelV2 = new ModelV2("foo", EnumV2.EnumMember, BinaryData.FromObjectAsJson("bar")); + var response = await new AddedClient(host).V2Async(modelV2); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("foo", response.Value.Prop); + Assert.AreEqual(EnumV2.EnumMember, response.Value.EnumProp); + Assert.AreEqual("bar", response.Value.UnionProp.ToObjectFromJson()); + }); + + [CadlRanchTest] + public Task Versioning_Added_InterfaceV2() => Test(async (host) => + { + ModelV2 modelV2 = new ModelV2("foo", EnumV2.EnumMember, BinaryData.FromObjectAsJson("bar")); + var response = await new AddedClient(host).GetInterfaceV2Client().V2InInterfaceAsync(modelV2); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("foo", response.Value.Prop); + Assert.AreEqual(EnumV2.EnumMember, response.Value.EnumProp); + Assert.AreEqual("bar", response.Value.UnionProp.ToObjectFromJson()); + }); + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/MadeOptional/V1/VersioningMadeOptionalV1Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/MadeOptional/V1/VersioningMadeOptionalV1Tests.cs new file mode 100644 index 0000000000..2f60e93400 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/MadeOptional/V1/VersioningMadeOptionalV1Tests.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using NUnit.Framework; +using System.Linq; +using Versioning.MadeOptional.V1.Models; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.MadeOptional.V1 +{ + public class VersioningMadeOptionalV1Tests : CadlRanchTestBase + { + [CadlRanchTest] + public void CheckMadeOptionalMembers() + { + var constructors = typeof(TestModel).GetConstructors(); + Assert.IsNotNull(constructors); + Assert.AreEqual(1, constructors.Length); + /* property will not in public constructor signature. */ + Assert.IsTrue(constructors[0].GetParameters().Any(p => p.Name == "changedProp")); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/MadeOptional/V2/VersioningMadeOptionalV2Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/MadeOptional/V2/VersioningMadeOptionalV2Tests.cs new file mode 100644 index 0000000000..239b07fcd1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/MadeOptional/V2/VersioningMadeOptionalV2Tests.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using NUnit.Framework; +using System.Linq; +using System.Threading.Tasks; +using Versioning.MadeOptional.V2; +using Versioning.MadeOptional.V2.Models; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.MadeOptional.V2 +{ + public class VersioningMadeOptionalV2Tests : CadlRanchTestBase + { + [CadlRanchTest] + public void CheckMadeOptionalMembers() + { + var constructors = typeof(TestModel).GetConstructors(); + Assert.IsNotNull(constructors); + Assert.AreEqual(1, constructors.Length); + /* optional property will not show in public constructor signature. */ + Assert.False(constructors[0].GetParameters().Any(p => p.Name == "changedProp")); + } + + [CadlRanchTest] + public Task Versioning_MadeOptional_Test() => Test(async (host) => + { + TestModel body = new TestModel("foo"); + var response = await new MadeOptionalClient(host).TestAsync(body); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("foo", response.Value.Prop); + }); + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V1/VersioningRemovedV1Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V1/VersioningRemovedV1Tests.cs new file mode 100644 index 0000000000..3fdf09cc9e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V1/VersioningRemovedV1Tests.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Linq; +using NUnit.Framework; +using Versioning.Removed.V1; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.Removed.V1 +{ + public class VersioningRemovedV1Tests : CadlRanchTestBase + { + [CadlRanchTest] + public void TestRemovedMembers() + { + /* check existence of the removed model ModelV1. */ + Assert.IsNotNull(Type.GetType("Versioning.Removed.V1.Models.ModelV1")); + + /* check existence of the removed enum EnumV1. */ + Assert.IsNotNull(Type.GetType("Versioning.Removed.V1.Models.EnumV1")); + + /* check existence of removed method V1 */ + var removedMethods = typeof(RemovedClient).GetMethods().Where(m => m.Name == "V1" || m.Name == "V1Async"); + Assert.AreEqual(4, removedMethods.Count()); + + /* check existence of removed parameter. */ + var v2Methods = typeof(RemovedClient).GetMethods().Where(m => m.Name == "V2" || m.Name == "V2Async"); + Assert.IsNotNull(v2Methods); + Assert.AreEqual(4, v2Methods.Count()); + foreach (var method in v2Methods) + { + Assert.IsTrue(method.GetParameters().Any(p => p.Name == "param")); + } + + /* check existence of removed interface. */ + Assert.IsNotNull(Type.GetType("Versioning.Removed.V1.InterfaceV1")); + + // Only initial versions is defined + var enumType = typeof(RemovedClientOptions.ServiceVersion); + Assert.AreEqual(new string[] { "V1" }, enumType.GetEnumNames()); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V2/VersioningRemovedV2Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V2/VersioningRemovedV2Tests.cs new file mode 100644 index 0000000000..49b6031e46 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V2/VersioningRemovedV2Tests.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Linq; +using System.Threading.Tasks; +using NUnit.Framework; +using Versioning.Removed.V2; +using Versioning.Removed.V2.Models; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.Removed.V2 +{ + public class VersioningRemovedV2Tests : CadlRanchTestBase + { + [CadlRanchTest] + public void TestRemovedMembers() + { + /* check existence of the removed model ModelV1. */ + Assert.IsNull(Type.GetType("Versioning.Removed.V2.Models.ModelV1")); + + /* check existence of the removed enum EnumV1. */ + Assert.IsNull(Type.GetType("Versioning.Removed.V2.Models.EnumV1")); + + /* verify ModelV2. */ + var properties = typeof(ModelV2).GetProperties(); + Assert.IsNotNull(properties); + Assert.AreEqual(3, properties.Length); + /* verify removed property RemovedProp in V2.*/ + Assert.IsNull(typeof(ModelV2).GetProperty("RemovedProp")); + + /* verify EnumV2 */ + Assert.IsTrue(typeof(EnumV2).IsEnum); + var enumValues = typeof(EnumV2).GetEnumNames(); + Assert.IsNotNull(enumValues); + Assert.AreEqual(1, enumValues.Length); + /* verify added enum value EnumMemberV1. */ + Assert.IsFalse(enumValues.Contains("EnumMemberV1")); + + /* check existence of removed method V1 */ + var removedMethods = typeof(RemovedClient).GetMethods().Where(m => m.Name == "V1" || m.Name == "V1Async"); + Assert.AreEqual(0, removedMethods.Count()); + + /* check existence of removed parameter. */ + var v2Methods = typeof(RemovedClient).GetMethods().Where(m => m.Name == "V2" || m.Name == "V2Async"); + Assert.IsNotNull(v2Methods); + Assert.AreEqual(4, v2Methods.Count()); + foreach (var method in v2Methods) + { + Assert.False(method.GetParameters().Any(p => p.Name == "param")); + } + + /* check existence of removed interface. */ + Assert.IsNull(Type.GetType("Versioning.Removed.V2.InterfaceV1")); + + // All 3 versions are defined + var enumType = typeof(RemovedClientOptions.ServiceVersion); + Assert.AreEqual(new string[] { "V1", "V2preview", "V2" }, enumType.GetEnumNames()); + } + + [CadlRanchTest] + public Task Versioning_Removed_v2() => Test(async (host) => + { + ModelV2 modelV2 = new ModelV2("foo", EnumV2.EnumMemberV2, BinaryData.FromObjectAsJson("bar")); + var response = await new RemovedClient(host).V2Async(modelV2); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("foo", response.Value.Prop); + Assert.AreEqual(EnumV2.EnumMemberV2, response.Value.EnumProp); + Assert.AreEqual("bar", response.Value.UnionProp.ToObjectFromJson()); + }); + + [CadlRanchTest] + public Task Versioning_Removed_V3Model() => Test(async (host) => + { + var model = new ModelV3("123", EnumV3.EnumMemberV1); + var response = await new RemovedClient(host).ModelV3Async(model); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("123", response.Value.Id); + Assert.AreEqual(EnumV3.EnumMemberV1, response.Value.EnumProp); + }); + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V2Preview/VersioningRemovedV2PreviewTests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V2Preview/VersioningRemovedV2PreviewTests.cs new file mode 100644 index 0000000000..21b0b1ede6 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/Removed/V2Preview/VersioningRemovedV2PreviewTests.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading.Tasks; +using NUnit.Framework; +using Versioning.Removed.V2Preview; +using Versioning.Removed.V2Preview.Models; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.Removed.V2Preview +{ + public class VersioningRemovedV2PreviewTests : CadlRanchTestBase + { + [CadlRanchTest] + public Task Versioning_Removed_V3Model() => Test(async (host) => + { + var model = new ModelV3("123"); + var response = await new RemovedClient(host).ModelV3Async(model); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("123", response.Value.Id); + }); + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/RenamedFrom/V1/VersioningRenamedFromV1Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/RenamedFrom/V1/VersioningRenamedFromV1Tests.cs new file mode 100644 index 0000000000..2b17334cf4 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/RenamedFrom/V1/VersioningRenamedFromV1Tests.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using NUnit.Framework; +using System; +using System.Linq; +using Versioning.RenamedFrom.V2; +using Versioning.RenamedFrom.V2.Models; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.RenamedFrom.V1 +{ + public class VersioningRenamedFromTests : CadlRanchTestBase + { + [CadlRanchTest] + public void TestRenamedMembers() + { + Assert.IsNotNull(Type.GetType("Versioning.RenamedFrom.V1.Models.OldModel")); + Assert.IsNull(Type.GetType("Versioning.RenamedFrom.V1.Models.NewModel")); + + /* check the renamed property of model */ + var properties = typeof(NewModel).GetProperties(); + Assert.IsNotNull(properties); + Assert.AreEqual(3, properties.Length); + Assert.IsNull(typeof(NewModel).GetProperty("OldProp")); + Assert.IsNotNull(typeof(NewModel).GetProperty("NewProp")); + + /* check the renamed enum from `OldEnum` to `NewEnum` */ + Assert.IsNotNull(Type.GetType("Versioning.RenamedFrom.V1.Models.OldEnum")); + Assert.IsNull(Type.GetType("Versioning.RenamedFrom.V1.Models.NewEnum")); + + /* check the renamed enum value */ + var enumValues = typeof(NewEnum).GetEnumNames(); + Assert.IsNotNull(enumValues); + Assert.AreEqual(1, enumValues.Length); + Assert.IsFalse(enumValues.Contains("OldEnumMember")); + Assert.IsTrue(enumValues.Contains("NewEnumMember")); + + /* check the renamed operation */ + var oldMethods = typeof(RenamedFromClient).GetMethods().Where(m => m.Name == "OldOp" || m.Name == "OldOpAsync"); + Assert.AreEqual(0, oldMethods.Count()); + var newMethods = typeof(RenamedFromClient).GetMethods().Where(m => m.Name == "NewOp" || m.Name == "NewOpAsync"); + Assert.AreEqual(4, newMethods.Count()); + + /* check the renamed interface */ + Assert.IsNotNull(Type.GetType("Versioning.RenamedFrom.V1.OldInterface")); + Assert.IsNull(Type.GetType("Versioning.RenamedFrom.V1.NewInterface")); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/RenamedFrom/V2/VersioningRenamedFromV2Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/RenamedFrom/V2/VersioningRenamedFromV2Tests.cs new file mode 100644 index 0000000000..f5fe18224f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/RenamedFrom/V2/VersioningRenamedFromV2Tests.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; +using Versioning.RenamedFrom.V2; +using Versioning.RenamedFrom.V2.Models; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.RenamedFrom.V2 +{ + public class VersioningRenamedFromTests : CadlRanchTestBase + { + [CadlRanchTest] + public void TestRenamedMembers() + { + /* check the renamed model from `OldModel` to `NewModel` */ + Assert.IsNull(Type.GetType("Versioning.RenamedFrom.V2.Models.OldModel")); + Assert.IsNotNull(Type.GetType("Versioning.RenamedFrom.V2.Models.NewModel")); + + /* check the renamed property of model */ + var properties = typeof(NewModel).GetProperties(); + Assert.IsNotNull(properties); + Assert.AreEqual(3, properties.Length); + Assert.IsNull(typeof(NewModel).GetProperty("OldProp")); + Assert.IsNotNull(typeof(NewModel).GetProperty("NewProp")); + + /* check the renamed enum from `OldEnum` to `NewEnum` */ + Assert.IsNull(Type.GetType("Versioning.RenamedFrom.V2.Models.OldEnum")); + Assert.IsNotNull(Type.GetType("Versioning.RenamedFrom.V2.Models.NewEnum")); + + /* check the renamed enum value */ + var enumValues = typeof(NewEnum).GetEnumNames(); + Assert.IsNotNull(enumValues); + Assert.AreEqual(1, enumValues.Length); + Assert.IsFalse(enumValues.Contains("OldEnumMember")); + Assert.IsTrue(enumValues.Contains("NewEnumMember")); + + /* check the renamed operation */ + var oldMethods = typeof(RenamedFromClient).GetMethods().Where(m => m.Name == "OldOp" || m.Name == "OldOpAsync"); + Assert.AreEqual(0, oldMethods.Count()); + var newMethods = typeof(RenamedFromClient).GetMethods().Where(m => m.Name == "NewOp" || m.Name == "NewOpAsync"); + Assert.AreEqual(4, newMethods.Count()); + + /* check the renamed interface */ + Assert.IsNull(Type.GetType("Versioning.RenamedFrom.V2.OldInterface")); + Assert.IsNotNull(Type.GetType("Versioning.RenamedFrom.V2.NewInterface")); + } + + [CadlRanchTest] + public Task Versioning_RenamedFrom_NewOp() => Test(async (host) => + { + NewModel body = new NewModel("foo", NewEnum.NewEnumMember, BinaryData.FromObjectAsJson(10)); + var response = await new RenamedFromClient(host).NewOpAsync("bar", body); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("foo", response.Value.NewProp); + Assert.AreEqual(NewEnum.NewEnumMember, response.Value.EnumProp); + Assert.AreEqual(10, response.Value.UnionProp.ToObjectFromJson()); + }); + + [CadlRanchTest] + public Task Versioning_RenamedFrom_NewInterface() => Test(async (host) => + { + NewModel body = new NewModel("foo", NewEnum.NewEnumMember, BinaryData.FromObjectAsJson(10)); + var response = await new RenamedFromClient(host).GetNewInterfaceClient().NewOpInNewInterfaceAsync(body); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("foo", response.Value.NewProp); + Assert.AreEqual(NewEnum.NewEnumMember, response.Value.EnumProp); + Assert.AreEqual(10, response.Value.UnionProp.ToObjectFromJson()); + }); + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/ReturnTypeChangedFrom/V2/VersioningReturnTypeChangedFromV2Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/ReturnTypeChangedFrom/V2/VersioningReturnTypeChangedFromV2Tests.cs new file mode 100644 index 0000000000..01a077d443 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/ReturnTypeChangedFrom/V2/VersioningReturnTypeChangedFromV2Tests.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading.Tasks; +using NUnit.Framework; +using Versioning.ReturnTypeChangedFrom.V2; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.ReturnTypeChangedFrom.V2 +{ + public class VersioningReturnTypeChangedFromTests : CadlRanchTestBase + { + [CadlRanchTest] + public Task Versioning_ReturnTypeChangedFrom_Test() => Test(async (host) => + { + var response = await new ReturnTypeChangedFromClient(host).TestAsync("test"); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("test", response.Value); + }); + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/TypeChangedFrom/V2/VersioningTypeChangedFromV2Tests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/TypeChangedFrom/V2/VersioningTypeChangedFromV2Tests.cs new file mode 100644 index 0000000000..aa25c3194f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Versioning/TypeChangedFrom/V2/VersioningTypeChangedFromV2Tests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using NUnit.Framework; +using System.Threading.Tasks; +using Versioning.TypeChangedFrom.V2; +using Versioning.TypeChangedFrom.V2.Models; + +namespace TestProjects.CadlRanch.Tests.Http.Versioning.TypeChangedFrom.V2 +{ + public class VersioningTypeChangedFromTests : CadlRanchTestBase + { + [CadlRanchTest] + public Task Versioning_TypeChangedFrom_Test() => Test(async (host) => + { + TestModel body = new TestModel("foo", "bar"); + var response = await new TypeChangedFromClient(host).TestAsync("baz", body); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("foo", response.Value.Prop); + Assert.AreEqual("bar", response.Value.ChangedProp); + }); + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/Configuration.json new file mode 100644 index 0000000000..a1b0c89fac --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.Added.V1", + "library-name": "Versioning.Added.V1", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/Versioning.Added.V1.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/Versioning.Added.V1.sln new file mode 100644 index 0000000000..ef116e1588 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/Versioning.Added.V1.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.Added.V1", "src\Versioning.Added.V1.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/AddedClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/AddedClient.cs new file mode 100644 index 0000000000..4f3e4e8833 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/AddedClient.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.Added.V1.Models; + +namespace Versioning.Added.V1 +{ + public partial class AddedClient + { + protected AddedClient() => throw null; + + public AddedClient(Uri endpoint) : this(endpoint, new AddedClientOptions()) => throw null; + + public AddedClient(Uri endpoint, AddedClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult V1(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V1Async(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V1(ModelV1 body) => throw null; + + public virtual Task> V1Async(ModelV1 body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/AddedClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/AddedClientOptions.cs new file mode 100644 index 0000000000..dfa740aaeb --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/AddedClientOptions.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.Added.V1 +{ + public partial class AddedClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V1; + + public AddedClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/EnumV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/EnumV1.cs new file mode 100644 index 0000000000..05170f3d40 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/EnumV1.cs @@ -0,0 +1,12 @@ +// + +#nullable disable + +namespace Versioning.Added.V1.Models +{ + public enum EnumV1 + { + /// EnumMemberV1. + EnumMemberV1 + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/ModelV1.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/ModelV1.Serialization.cs new file mode 100644 index 0000000000..436a07dffa --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/ModelV1.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Added.V1.Models +{ + public partial class ModelV1 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV1 modelV1) => throw null; + + public static explicit operator ModelV1(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/ModelV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/ModelV1.cs new file mode 100644 index 0000000000..6137596f1f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/Models/ModelV1.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +namespace Versioning.Added.V1.Models +{ + public partial class ModelV1 + { + public ModelV1(string prop, EnumV1 enumProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public EnumV1 EnumProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/VersioningAddedV1ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/VersioningAddedV1ModelFactory.cs new file mode 100644 index 0000000000..5ab472a490 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Generated/VersioningAddedV1ModelFactory.cs @@ -0,0 +1,11 @@ +// + +#nullable disable + +namespace Versioning.Added.V1.Models +{ + public static partial class VersioningAddedV1ModelFactory + { + public static ModelV1 ModelV1(string prop = default, EnumV1 enumProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Versioning.Added.V1.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Versioning.Added.V1.csproj new file mode 100644 index 0000000000..bd7ea27e44 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/src/Versioning.Added.V1.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.Added.V1 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.Added.V1 + 1.0.0-beta.1 + Versioning.Added.V1 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/tspCodeModel.json new file mode 100644 index 0000000000..f973fbb958 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v1/tspCodeModel.json @@ -0,0 +1,292 @@ +{ + "$id": "1", + "Name": "Versioning.Added", + "ApiVersions": [ + "v1" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "EnumV1", + "crossLanguageDefinitionId": "Versioning.Added.EnumV1", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "enumMemberV1", + "value": "enumMemberV1", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "6", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.Added.Versions", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "8", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "9", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "description": "The version v1.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "10", + "kind": "model", + "name": "ModelV1", + "crossLanguageDefinitionId": "Versioning.Added.ModelV1", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "11", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "12", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Added.ModelV1.prop" + }, + { + "$id": "13", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "2" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Added.ModelV1.enumProp" + } + ] + } + ], + "Clients": [ + { + "$id": "14", + "Name": "AddedClient", + "Description": "Test for the `@added` decorator.", + "Operations": [ + { + "$id": "15", + "Name": "v1", + "ResourceName": "Added", + "Accessibility": "public", + "Parameters": [ + { + "$id": "16", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "17", + "kind": "constant", + "valueType": { + "$id": "18", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "19", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "20", + "kind": "constant", + "valueType": { + "$id": "21", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "22", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "10" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "23", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "10" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/added/api-version:{version}", + "Path": "/v1", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Added.v1", + "Decorators": [] + } + ], + "Protocol": { + "$id": "24" + }, + "Parameters": [ + { + "$id": "25", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "26", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "27", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "6" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/Configuration.json new file mode 100644 index 0000000000..02bab3c404 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.Added.V2", + "library-name": "Versioning.Added.V2", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/Versioning.Added.V2.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/Versioning.Added.V2.sln new file mode 100644 index 0000000000..29b239e010 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/Versioning.Added.V2.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.Added.V2", "src\Versioning.Added.V2.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/AddedClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/AddedClient.cs new file mode 100644 index 0000000000..c14b77224f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/AddedClient.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.Added.V2.Models; + +namespace Versioning.Added.V2 +{ + public partial class AddedClient + { + protected AddedClient() => throw null; + + public AddedClient(Uri endpoint) : this(endpoint, new AddedClientOptions()) => throw null; + + public AddedClient(Uri endpoint, AddedClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult V1(string headerV2, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V1Async(string headerV2, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V1(string headerV2, ModelV1 body) => throw null; + + public virtual Task> V1Async(string headerV2, ModelV1 body, CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult V2(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V2Async(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V2(ModelV2 body) => throw null; + + public virtual Task> V2Async(ModelV2 body, CancellationToken cancellationToken = default) => throw null; + + public virtual InterfaceV2 GetInterfaceV2Client() => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/AddedClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/AddedClientOptions.cs new file mode 100644 index 0000000000..8687c4616d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/AddedClientOptions.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.Added.V2 +{ + public partial class AddedClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2; + + public AddedClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1, + /// The version v2. + V2 = 2 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/InterfaceV2.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/InterfaceV2.cs new file mode 100644 index 0000000000..a3e3e2561f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/InterfaceV2.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.Added.V2.Models; + +namespace Versioning.Added.V2 +{ + public partial class InterfaceV2 + { + protected InterfaceV2() => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult V2InInterface(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V2InInterfaceAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V2InInterface(ModelV2 body) => throw null; + + public virtual Task> V2InInterfaceAsync(ModelV2 body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/EnumV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/EnumV1.cs new file mode 100644 index 0000000000..2d412c58dc --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/EnumV1.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +namespace Versioning.Added.V2.Models +{ + public enum EnumV1 + { + /// EnumMemberV1. + EnumMemberV1, + /// EnumMemberV2. + EnumMemberV2 + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/EnumV2.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/EnumV2.cs new file mode 100644 index 0000000000..3d8cc2c153 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/EnumV2.cs @@ -0,0 +1,12 @@ +// + +#nullable disable + +namespace Versioning.Added.V2.Models +{ + public enum EnumV2 + { + /// EnumMember. + EnumMember + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV1.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV1.Serialization.cs new file mode 100644 index 0000000000..0fe0495bf1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV1.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Added.V2.Models +{ + public partial class ModelV1 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV1 modelV1) => throw null; + + public static explicit operator ModelV1(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV1.cs new file mode 100644 index 0000000000..7cf4187c0d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV1.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Added.V2.Models +{ + public partial class ModelV1 + { + public ModelV1(string prop, EnumV1 enumProp, BinaryData unionProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public EnumV1 EnumProp + { + get => throw null; + set => throw null; + } + + public BinaryData UnionProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV2.Serialization.cs new file mode 100644 index 0000000000..cbebd413c6 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV2.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Added.V2.Models +{ + public partial class ModelV2 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV2 modelV2) => throw null; + + public static explicit operator ModelV2(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV2.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV2.cs new file mode 100644 index 0000000000..dfc2566608 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/Models/ModelV2.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Added.V2.Models +{ + public partial class ModelV2 + { + public ModelV2(string prop, EnumV2 enumProp, BinaryData unionProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public EnumV2 EnumProp + { + get => throw null; + set => throw null; + } + + public BinaryData UnionProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/VersioningAddedV2ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/VersioningAddedV2ModelFactory.cs new file mode 100644 index 0000000000..5bc2843e9b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Generated/VersioningAddedV2ModelFactory.cs @@ -0,0 +1,15 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Added.V2.Models +{ + public static partial class VersioningAddedV2ModelFactory + { + public static ModelV1 ModelV1(string prop = default, EnumV1 enumProp = default, BinaryData unionProp = default) => throw null; + + public static ModelV2 ModelV2(string prop = default, EnumV2 enumProp = default, BinaryData unionProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Versioning.Added.V2.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Versioning.Added.V2.csproj new file mode 100644 index 0000000000..752c8f4f58 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/src/Versioning.Added.V2.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.Added.V2 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.Added.V2 + 1.0.0-beta.1 + Versioning.Added.V2 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/tspCodeModel.json new file mode 100644 index 0000000000..b97fdf50a0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/added/v2/tspCodeModel.json @@ -0,0 +1,774 @@ +{ + "$id": "1", + "Name": "Versioning.Added", + "ApiVersions": [ + "v1", + "v2" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "EnumV1", + "crossLanguageDefinitionId": "Versioning.Added.EnumV1", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "enumMemberV1", + "value": "enumMemberV1", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "decorators": [] + }, + { + "$id": "6", + "kind": "enumvalue", + "name": "enumMemberV2", + "value": "enumMemberV2", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "8", + "kind": "enum", + "name": "EnumV2", + "crossLanguageDefinitionId": "Versioning.Added.EnumV2", + "valueType": { + "$id": "9", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "10", + "kind": "enumvalue", + "name": "enumMember", + "value": "enumMember", + "valueType": { + "$id": "11", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "8" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "12", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.Added.Versions", + "valueType": { + "$id": "13", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "14", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "15", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "12" + }, + "description": "The version v1.", + "decorators": [] + }, + { + "$id": "16", + "kind": "enumvalue", + "name": "v2", + "value": "v2", + "valueType": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "12" + }, + "description": "The version v2.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "18", + "kind": "model", + "name": "ModelV1", + "crossLanguageDefinitionId": "Versioning.Added.ModelV1", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "19", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "20", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Added.ModelV1.prop" + }, + { + "$id": "21", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "2" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Added.ModelV1.enumProp" + }, + { + "$id": "22", + "kind": "property", + "name": "unionProp", + "serializedName": "unionProp", + "type": { + "$id": "23", + "kind": "union", + "name": "UnionV1", + "variantTypes": [ + { + "$id": "24", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + { + "$id": "25", + "kind": "int32", + "name": "V2Scalar", + "crossLanguageDefinitionId": "Versioning.Added.V2Scalar", + "baseType": { + "$id": "26", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "decorators": [] + } + ], + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Added.ModelV1.unionProp" + } + ] + }, + { + "$id": "27", + "kind": "model", + "name": "ModelV2", + "crossLanguageDefinitionId": "Versioning.Added.ModelV2", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "28", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "29", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Added.ModelV2.prop" + }, + { + "$id": "30", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "8" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Added.ModelV2.enumProp" + }, + { + "$id": "31", + "kind": "property", + "name": "unionProp", + "serializedName": "unionProp", + "type": { + "$id": "32", + "kind": "union", + "name": "UnionV2", + "variantTypes": [ + { + "$id": "33", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + { + "$id": "34", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + ], + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Added.ModelV2.unionProp" + } + ] + } + ], + "Clients": [ + { + "$id": "35", + "Name": "AddedClient", + "Description": "Test for the `@added` decorator.", + "Operations": [ + { + "$id": "36", + "Name": "v1", + "ResourceName": "Added", + "Accessibility": "public", + "Parameters": [ + { + "$id": "37", + "Name": "headerV2", + "NameInRequest": "header-v2", + "Type": { + "$id": "38", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "39", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "40", + "kind": "constant", + "valueType": { + "$id": "41", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "42", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "43", + "kind": "constant", + "valueType": { + "$id": "44", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "45", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "18" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "46", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "18" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/added/api-version:{version}", + "Path": "/v1", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Added.v1", + "Decorators": [] + }, + { + "$id": "47", + "Name": "v2", + "ResourceName": "Added", + "Accessibility": "public", + "Parameters": [ + { + "$id": "48", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "49", + "kind": "constant", + "valueType": { + "$id": "50", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "51", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "52", + "kind": "constant", + "valueType": { + "$id": "53", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "54", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "27" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "55", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "27" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/added/api-version:{version}", + "Path": "/v2", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Added.v2", + "Decorators": [] + } + ], + "Protocol": { + "$id": "56" + }, + "Parameters": [ + { + "$id": "57", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "58", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "59", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "12" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + }, + { + "$id": "60", + "Name": "InterfaceV2", + "Operations": [ + { + "$id": "61", + "Name": "v2InInterface", + "ResourceName": "InterfaceV2", + "Accessibility": "public", + "Parameters": [ + { + "$id": "62", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "63", + "kind": "constant", + "valueType": { + "$id": "64", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "65", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "66", + "kind": "constant", + "valueType": { + "$id": "67", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "68", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "27" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "69", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "27" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/added/api-version:{version}", + "Path": "/interface-v2/v2", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Added.InterfaceV2.v2InInterface", + "Decorators": [] + } + ], + "Protocol": { + "$id": "70" + }, + "Parent": "AddedClient", + "Parameters": [ + { + "$id": "71", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "72", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "73", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "12" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/Configuration.json new file mode 100644 index 0000000000..940644eeea --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.MadeOptional.V1", + "library-name": "Versioning.MadeOptional.V1", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/Versioning.MadeOptional.V1.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/Versioning.MadeOptional.V1.sln new file mode 100644 index 0000000000..51b46dbce2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/Versioning.MadeOptional.V1.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.MadeOptional.V1", "src\Versioning.MadeOptional.V1.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/MadeOptionalClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/MadeOptionalClient.cs new file mode 100644 index 0000000000..01ca1bac05 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/MadeOptionalClient.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.MadeOptional.V1.Models; + +namespace Versioning.MadeOptional.V1 +{ + public partial class MadeOptionalClient + { + protected MadeOptionalClient() => throw null; + + public MadeOptionalClient(Uri endpoint) : this(endpoint, new MadeOptionalClientOptions()) => throw null; + + public MadeOptionalClient(Uri endpoint, MadeOptionalClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult Test(string @param, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task TestAsync(string @param, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult Test(string @param, TestModel body) => throw null; + + public virtual Task> TestAsync(string @param, TestModel body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/MadeOptionalClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/MadeOptionalClientOptions.cs new file mode 100644 index 0000000000..b8c4012f7a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/MadeOptionalClientOptions.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.MadeOptional.V1 +{ + public partial class MadeOptionalClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V1; + + public MadeOptionalClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/Models/TestModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/Models/TestModel.Serialization.cs new file mode 100644 index 0000000000..a9bb4866bb --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/Models/TestModel.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.MadeOptional.V1.Models +{ + public partial class TestModel : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + TestModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual TestModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + TestModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual TestModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(TestModel testModel) => throw null; + + public static explicit operator TestModel(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/Models/TestModel.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/Models/TestModel.cs new file mode 100644 index 0000000000..75198e8071 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/Models/TestModel.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +namespace Versioning.MadeOptional.V1.Models +{ + public partial class TestModel + { + public TestModel(string prop, string changedProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public string ChangedProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/VersioningMadeOptionalV1ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/VersioningMadeOptionalV1ModelFactory.cs new file mode 100644 index 0000000000..d0949041b0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Generated/VersioningMadeOptionalV1ModelFactory.cs @@ -0,0 +1,11 @@ +// + +#nullable disable + +namespace Versioning.MadeOptional.V1.Models +{ + public static partial class VersioningMadeOptionalV1ModelFactory + { + public static TestModel TestModel(string prop = default, string changedProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Versioning.MadeOptional.V1.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Versioning.MadeOptional.V1.csproj new file mode 100644 index 0000000000..e5b4b44f37 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/src/Versioning.MadeOptional.V1.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.MadeOptional.V1 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.MadeOptional.V1 + 1.0.0-beta.1 + Versioning.MadeOptional.V1 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/tspCodeModel.json new file mode 100644 index 0000000000..1a5ce90ce9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v1/tspCodeModel.json @@ -0,0 +1,281 @@ +{ + "$id": "1", + "Name": "Versioning.MadeOptional", + "ApiVersions": [ + "v1" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.MadeOptional.Versions", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "description": "The version v1.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "6", + "kind": "model", + "name": "TestModel", + "crossLanguageDefinitionId": "Versioning.MadeOptional.TestModel", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "7", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "8", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.MadeOptional.TestModel.prop" + }, + { + "$id": "9", + "kind": "property", + "name": "changedProp", + "serializedName": "changedProp", + "type": { + "$id": "10", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.MadeOptional.TestModel.changedProp" + } + ] + } + ], + "Clients": [ + { + "$id": "11", + "Name": "MadeOptionalClient", + "Description": "Test for the `@madeOptional` decorator.", + "Operations": [ + { + "$id": "12", + "Name": "test", + "ResourceName": "MadeOptional", + "Accessibility": "public", + "Parameters": [ + { + "$id": "13", + "Name": "param", + "NameInRequest": "param", + "Type": { + "$id": "14", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "15", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "16", + "kind": "constant", + "valueType": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "18", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "19", + "kind": "constant", + "valueType": { + "$id": "20", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "21", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "6" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "22", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "6" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/made-optional/api-version:{version}", + "Path": "/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.MadeOptional.test", + "Decorators": [] + } + ], + "Protocol": { + "$id": "23" + }, + "Parameters": [ + { + "$id": "24", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "25", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "26", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "2" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/Configuration.json new file mode 100644 index 0000000000..50d535b8e3 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.MadeOptional.V2", + "library-name": "Versioning.MadeOptional.V2", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/Versioning.MadeOptional.V2.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/Versioning.MadeOptional.V2.sln new file mode 100644 index 0000000000..66d445ad82 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/Versioning.MadeOptional.V2.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.MadeOptional.V2", "src\Versioning.MadeOptional.V2.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/MadeOptionalClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/MadeOptionalClient.cs new file mode 100644 index 0000000000..0e1845360c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/MadeOptionalClient.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.MadeOptional.V2.Models; + +namespace Versioning.MadeOptional.V2 +{ + public partial class MadeOptionalClient + { + protected MadeOptionalClient() => throw null; + + public MadeOptionalClient(Uri endpoint) : this(endpoint, new MadeOptionalClientOptions()) => throw null; + + public MadeOptionalClient(Uri endpoint, MadeOptionalClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult Test(BinaryContent content, string @param = null, RequestOptions options = null) => throw null; + + public virtual Task TestAsync(BinaryContent content, string @param = null, RequestOptions options = null) => throw null; + + public virtual ClientResult Test(TestModel body, string @param = null) => throw null; + + public virtual Task> TestAsync(TestModel body, string @param = null, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/MadeOptionalClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/MadeOptionalClientOptions.cs new file mode 100644 index 0000000000..0a43641656 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/MadeOptionalClientOptions.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.MadeOptional.V2 +{ + public partial class MadeOptionalClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2; + + public MadeOptionalClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1, + /// The version v2. + V2 = 2 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/Models/TestModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/Models/TestModel.Serialization.cs new file mode 100644 index 0000000000..9700a3d60a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/Models/TestModel.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.MadeOptional.V2.Models +{ + public partial class TestModel : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + TestModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual TestModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + TestModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual TestModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(TestModel testModel) => throw null; + + public static explicit operator TestModel(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/Models/TestModel.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/Models/TestModel.cs new file mode 100644 index 0000000000..f9cd13dcef --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/Models/TestModel.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +namespace Versioning.MadeOptional.V2.Models +{ + public partial class TestModel + { + public TestModel(string prop) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public string ChangedProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/VersioningMadeOptionalV2ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/VersioningMadeOptionalV2ModelFactory.cs new file mode 100644 index 0000000000..402201f28b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Generated/VersioningMadeOptionalV2ModelFactory.cs @@ -0,0 +1,11 @@ +// + +#nullable disable + +namespace Versioning.MadeOptional.V2.Models +{ + public static partial class VersioningMadeOptionalV2ModelFactory + { + public static TestModel TestModel(string prop = default, string changedProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Versioning.MadeOptional.V2.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Versioning.MadeOptional.V2.csproj new file mode 100644 index 0000000000..30c5889eda --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/src/Versioning.MadeOptional.V2.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.MadeOptional.V2 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.MadeOptional.V2 + 1.0.0-beta.1 + Versioning.MadeOptional.V2 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/tspCodeModel.json new file mode 100644 index 0000000000..90207ea958 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/madeOptional/v2/tspCodeModel.json @@ -0,0 +1,300 @@ +{ + "$id": "1", + "Name": "Versioning.MadeOptional", + "ApiVersions": [ + "v1", + "v2" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.MadeOptional.Versions", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "description": "The version v1.", + "decorators": [] + }, + { + "$id": "6", + "kind": "enumvalue", + "name": "v2", + "value": "v2", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "description": "The version v2.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "8", + "kind": "model", + "name": "TestModel", + "crossLanguageDefinitionId": "Versioning.MadeOptional.TestModel", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "9", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "10", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.MadeOptional.TestModel.prop" + }, + { + "$id": "11", + "kind": "property", + "name": "changedProp", + "serializedName": "changedProp", + "type": { + "$id": "12", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.MadeOptional.TestModel.changedProp" + } + ] + } + ], + "Clients": [ + { + "$id": "13", + "Name": "MadeOptionalClient", + "Description": "Test for the `@madeOptional` decorator.", + "Operations": [ + { + "$id": "14", + "Name": "test", + "ResourceName": "MadeOptional", + "Accessibility": "public", + "Parameters": [ + { + "$id": "15", + "Name": "param", + "NameInRequest": "param", + "Type": { + "$id": "16", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "17", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "18", + "kind": "constant", + "valueType": { + "$id": "19", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "20", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "21", + "kind": "constant", + "valueType": { + "$id": "22", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "23", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "8" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "24", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "8" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/made-optional/api-version:{version}", + "Path": "/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.MadeOptional.test", + "Decorators": [] + } + ], + "Protocol": { + "$id": "25" + }, + "Parameters": [ + { + "$id": "26", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "27", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "28", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "2" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/Configuration.json new file mode 100644 index 0000000000..f2d631d285 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.Removed.V1", + "library-name": "Versioning.Removed.V1", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/Versioning.Removed.V1.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/Versioning.Removed.V1.sln new file mode 100644 index 0000000000..b8e71b9ecf --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/Versioning.Removed.V1.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.Removed.V1", "src\Versioning.Removed.V1.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/InterfaceV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/InterfaceV1.cs new file mode 100644 index 0000000000..1b690de1d7 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/InterfaceV1.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.Removed.V1.Models; + +namespace Versioning.Removed.V1 +{ + public partial class InterfaceV1 + { + protected InterfaceV1() => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult V1InInterface(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V1InInterfaceAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V1InInterface(ModelV1 body) => throw null; + + public virtual Task> V1InInterfaceAsync(ModelV1 body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV1.cs new file mode 100644 index 0000000000..45d0b8bab4 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV1.cs @@ -0,0 +1,12 @@ +// + +#nullable disable + +namespace Versioning.Removed.V1.Models +{ + public enum EnumV1 + { + /// EnumMember. + EnumMember + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV2.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV2.cs new file mode 100644 index 0000000000..b94ada2865 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV2.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +namespace Versioning.Removed.V1.Models +{ + public enum EnumV2 + { + /// EnumMemberV1. + EnumMemberV1, + /// EnumMemberV2. + EnumMemberV2 + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV3.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV3.cs new file mode 100644 index 0000000000..9ad41447df --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/EnumV3.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +namespace Versioning.Removed.V1.Models +{ + public enum EnumV3 + { + /// EnumMemberV1. + EnumMemberV1, + /// EnumMemberV2Preview. + EnumMemberV2Preview + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV1.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV1.Serialization.cs new file mode 100644 index 0000000000..73ac5f911c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV1.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Removed.V1.Models +{ + public partial class ModelV1 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV1 modelV1) => throw null; + + public static explicit operator ModelV1(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV1.cs new file mode 100644 index 0000000000..306c82a546 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV1.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Removed.V1.Models +{ + public partial class ModelV1 + { + public ModelV1(string prop, EnumV1 enumProp, BinaryData unionProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public EnumV1 EnumProp + { + get => throw null; + set => throw null; + } + + public BinaryData UnionProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV2.Serialization.cs new file mode 100644 index 0000000000..b7f4ded0af --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV2.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Removed.V1.Models +{ + public partial class ModelV2 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV2 modelV2) => throw null; + + public static explicit operator ModelV2(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV2.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV2.cs new file mode 100644 index 0000000000..f2e845b378 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV2.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Removed.V1.Models +{ + public partial class ModelV2 + { + public ModelV2(string prop, string removedProp, EnumV2 enumProp, BinaryData unionProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public string RemovedProp + { + get => throw null; + set => throw null; + } + + public EnumV2 EnumProp + { + get => throw null; + set => throw null; + } + + public BinaryData UnionProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV3.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV3.Serialization.cs new file mode 100644 index 0000000000..5afd00fe9c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV3.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Removed.V1.Models +{ + public partial class ModelV3 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV3 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV3 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV3 modelV3) => throw null; + + public static explicit operator ModelV3(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV3.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV3.cs new file mode 100644 index 0000000000..e876028af3 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/Models/ModelV3.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +namespace Versioning.Removed.V1.Models +{ + public partial class ModelV3 + { + public ModelV3(string id, EnumV3 enumProp) => throw null; + + public string Id + { + get => throw null; + set => throw null; + } + + public EnumV3 EnumProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/RemovedClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/RemovedClient.cs new file mode 100644 index 0000000000..916f45fd30 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/RemovedClient.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.Removed.V1.Models; + +namespace Versioning.Removed.V1 +{ + public partial class RemovedClient + { + protected RemovedClient() => throw null; + + public RemovedClient(Uri endpoint) : this(endpoint, new RemovedClientOptions()) => throw null; + + public RemovedClient(Uri endpoint, RemovedClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult V1(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V1Async(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V1(ModelV1 body) => throw null; + + public virtual Task> V1Async(ModelV1 body, CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult V2(string @param, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V2Async(string @param, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V2(string @param, ModelV2 body) => throw null; + + public virtual Task> V2Async(string @param, ModelV2 body, CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult ModelV3(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task ModelV3Async(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult ModelV3(ModelV3 body) => throw null; + + public virtual Task> ModelV3Async(ModelV3 body, CancellationToken cancellationToken = default) => throw null; + + public virtual InterfaceV1 GetInterfaceV1Client() => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/RemovedClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/RemovedClientOptions.cs new file mode 100644 index 0000000000..cab73b02fc --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/RemovedClientOptions.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.Removed.V1 +{ + public partial class RemovedClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V1; + + public RemovedClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The original version v1. + V1 = 1 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/VersioningRemovedV1ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/VersioningRemovedV1ModelFactory.cs new file mode 100644 index 0000000000..379538bf7d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Generated/VersioningRemovedV1ModelFactory.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Removed.V1.Models +{ + public static partial class VersioningRemovedV1ModelFactory + { + public static ModelV1 ModelV1(string prop = default, EnumV1 enumProp = default, BinaryData unionProp = default) => throw null; + + public static ModelV2 ModelV2(string prop = default, string removedProp = default, EnumV2 enumProp = default, BinaryData unionProp = default) => throw null; + + public static ModelV3 ModelV3(string id = default, EnumV3 enumProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Versioning.Removed.V1.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Versioning.Removed.V1.csproj new file mode 100644 index 0000000000..325a8ef7e1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/src/Versioning.Removed.V1.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.Removed.V1 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.Removed.V1 + 1.0.0-beta.1 + Versioning.Removed.V1 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/tspCodeModel.json new file mode 100644 index 0000000000..3f046e33d4 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v1/tspCodeModel.json @@ -0,0 +1,990 @@ +{ + "$id": "1", + "Name": "Versioning.Removed", + "ApiVersions": [ + "v1" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "EnumV1", + "crossLanguageDefinitionId": "Versioning.Removed.EnumV1", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "enumMember", + "value": "enumMember", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "6", + "kind": "enum", + "name": "EnumV2", + "crossLanguageDefinitionId": "Versioning.Removed.EnumV2", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "8", + "kind": "enumvalue", + "name": "enumMemberV1", + "value": "enumMemberV1", + "valueType": { + "$id": "9", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "decorators": [] + }, + { + "$id": "10", + "kind": "enumvalue", + "name": "enumMemberV2", + "value": "enumMemberV2", + "valueType": { + "$id": "11", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "12", + "kind": "enum", + "name": "EnumV3", + "crossLanguageDefinitionId": "Versioning.Removed.EnumV3", + "valueType": { + "$id": "13", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "14", + "kind": "enumvalue", + "name": "enumMemberV1", + "value": "enumMemberV1", + "valueType": { + "$id": "15", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "12" + }, + "decorators": [] + }, + { + "$id": "16", + "kind": "enumvalue", + "name": "enumMemberV2Preview", + "value": "enumMemberV2Preview", + "valueType": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "12" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "18", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.Removed.Versions", + "valueType": { + "$id": "19", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "20", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "21", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "18" + }, + "description": "The original version v1.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "22", + "kind": "model", + "name": "ModelV1", + "crossLanguageDefinitionId": "Versioning.Removed.ModelV1", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "23", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "24", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV1.prop" + }, + { + "$id": "25", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "2" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV1.enumProp" + }, + { + "$id": "26", + "kind": "property", + "name": "unionProp", + "serializedName": "unionProp", + "type": { + "$id": "27", + "kind": "union", + "name": "UnionV1", + "variantTypes": [ + { + "$id": "28", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + { + "$id": "29", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + ], + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV1.unionProp" + } + ] + }, + { + "$id": "30", + "kind": "model", + "name": "ModelV2", + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "31", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "32", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.prop" + }, + { + "$id": "33", + "kind": "property", + "name": "removedProp", + "serializedName": "removedProp", + "type": { + "$id": "34", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.removedProp" + }, + { + "$id": "35", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "6" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.enumProp" + }, + { + "$id": "36", + "kind": "property", + "name": "unionProp", + "serializedName": "unionProp", + "type": { + "$id": "37", + "kind": "union", + "name": "UnionV2", + "variantTypes": [ + { + "$id": "38", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + { + "$id": "39", + "kind": "float32", + "name": "float32", + "crossLanguageDefinitionId": "TypeSpec.float32", + "decorators": [] + }, + { + "$id": "40", + "kind": "int32", + "name": "V1Scalar", + "crossLanguageDefinitionId": "Versioning.Removed.V1Scalar", + "baseType": { + "$id": "41", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "decorators": [] + } + ], + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.unionProp" + } + ] + }, + { + "$id": "42", + "kind": "model", + "name": "ModelV3", + "crossLanguageDefinitionId": "Versioning.Removed.ModelV3", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "43", + "kind": "property", + "name": "id", + "serializedName": "id", + "type": { + "$id": "44", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV3.id" + }, + { + "$id": "45", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "12" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV3.enumProp" + } + ] + } + ], + "Clients": [ + { + "$id": "46", + "Name": "RemovedClient", + "Description": "Test for the `@removed` decorator.", + "Operations": [ + { + "$id": "47", + "Name": "v1", + "ResourceName": "Removed", + "Description": "This operation should not be generated with latest version's signature.", + "Accessibility": "public", + "Parameters": [ + { + "$id": "48", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "49", + "kind": "constant", + "valueType": { + "$id": "50", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "51", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "52", + "kind": "constant", + "valueType": { + "$id": "53", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "54", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "22" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "55", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "22" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/v1", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.v1", + "Decorators": [] + }, + { + "$id": "56", + "Name": "v2", + "ResourceName": "Removed", + "Accessibility": "public", + "Parameters": [ + { + "$id": "57", + "Name": "param", + "NameInRequest": "param", + "Type": { + "$id": "58", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "59", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "60", + "kind": "constant", + "valueType": { + "$id": "61", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "62", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "63", + "kind": "constant", + "valueType": { + "$id": "64", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "65", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "30" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "66", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "30" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/v2", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.v2", + "Decorators": [] + }, + { + "$id": "67", + "Name": "modelV3", + "ResourceName": "Removed", + "Description": "This operation will pass different paths and different request bodies based on different versions.", + "Accessibility": "public", + "Parameters": [ + { + "$id": "68", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "69", + "kind": "constant", + "valueType": { + "$id": "70", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "71", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "72", + "kind": "constant", + "valueType": { + "$id": "73", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "74", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "42" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "75", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "42" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/v3", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.modelV3", + "Decorators": [] + } + ], + "Protocol": { + "$id": "76" + }, + "Parameters": [ + { + "$id": "77", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "78", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "79", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1', 'v2preview' or 'v2' in client.", + "Type": { + "$ref": "18" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + }, + { + "$id": "80", + "Name": "InterfaceV1", + "Description": "This operation group should not be generated with latest version.", + "Operations": [ + { + "$id": "81", + "Name": "v1InInterface", + "ResourceName": "InterfaceV1", + "Accessibility": "public", + "Parameters": [ + { + "$id": "82", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "83", + "kind": "constant", + "valueType": { + "$id": "84", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "85", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "86", + "kind": "constant", + "valueType": { + "$id": "87", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "88", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "22" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "89", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "22" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/interface-v1/v1", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.InterfaceV1.v1InInterface", + "Decorators": [] + } + ], + "Protocol": { + "$id": "90" + }, + "Parent": "RemovedClient", + "Parameters": [ + { + "$id": "91", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "92", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "93", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1', 'v2preview' or 'v2' in client.", + "Type": { + "$ref": "18" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/Configuration.json new file mode 100644 index 0000000000..6262e57e7e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.Removed.V2", + "library-name": "Versioning.Removed.V2", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/Versioning.Removed.V2.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/Versioning.Removed.V2.sln new file mode 100644 index 0000000000..2734f785ca --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/Versioning.Removed.V2.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.Removed.V2", "src\Versioning.Removed.V2.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/EnumV2.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/EnumV2.cs new file mode 100644 index 0000000000..9eef86c9ec --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/EnumV2.cs @@ -0,0 +1,12 @@ +// + +#nullable disable + +namespace Versioning.Removed.V2.Models +{ + public enum EnumV2 + { + /// EnumMemberV2. + EnumMemberV2 + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/EnumV3.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/EnumV3.cs new file mode 100644 index 0000000000..2817ca87e2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/EnumV3.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +namespace Versioning.Removed.V2.Models +{ + public enum EnumV3 + { + /// EnumMemberV1. + EnumMemberV1, + /// EnumMemberV2Preview. + EnumMemberV2Preview + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV2.Serialization.cs new file mode 100644 index 0000000000..190a3007b4 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV2.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Removed.V2.Models +{ + public partial class ModelV2 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV2 modelV2) => throw null; + + public static explicit operator ModelV2(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV2.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV2.cs new file mode 100644 index 0000000000..2e463ef968 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV2.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Removed.V2.Models +{ + public partial class ModelV2 + { + public ModelV2(string prop, EnumV2 enumProp, BinaryData unionProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public EnumV2 EnumProp + { + get => throw null; + set => throw null; + } + + public BinaryData UnionProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV3.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV3.Serialization.cs new file mode 100644 index 0000000000..7ac06e47ac --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV3.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Removed.V2.Models +{ + public partial class ModelV3 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV3 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV3 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV3 modelV3) => throw null; + + public static explicit operator ModelV3(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV3.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV3.cs new file mode 100644 index 0000000000..048d197acb --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/Models/ModelV3.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +namespace Versioning.Removed.V2.Models +{ + public partial class ModelV3 + { + public ModelV3(string id, EnumV3 enumProp) => throw null; + + public string Id + { + get => throw null; + set => throw null; + } + + public EnumV3 EnumProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/RemovedClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/RemovedClient.cs new file mode 100644 index 0000000000..f959fcc9d9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/RemovedClient.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.Removed.V2.Models; + +namespace Versioning.Removed.V2 +{ + public partial class RemovedClient + { + protected RemovedClient() => throw null; + + public RemovedClient(Uri endpoint) : this(endpoint, new RemovedClientOptions()) => throw null; + + public RemovedClient(Uri endpoint, RemovedClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult V2(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V2Async(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V2(ModelV2 body) => throw null; + + public virtual Task> V2Async(ModelV2 body, CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult ModelV3(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task ModelV3Async(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult ModelV3(ModelV3 body) => throw null; + + public virtual Task> ModelV3Async(ModelV3 body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/RemovedClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/RemovedClientOptions.cs new file mode 100644 index 0000000000..ec1c5bffc3 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/RemovedClientOptions.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.Removed.V2 +{ + public partial class RemovedClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2; + + public RemovedClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The original version v1. + V1 = 1, + /// The V2 Preview version. + V2preview = 2, + /// The latest version v2. + V2 = 3 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/VersioningRemovedV2ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/VersioningRemovedV2ModelFactory.cs new file mode 100644 index 0000000000..9eeb009773 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Generated/VersioningRemovedV2ModelFactory.cs @@ -0,0 +1,15 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Removed.V2.Models +{ + public static partial class VersioningRemovedV2ModelFactory + { + public static ModelV2 ModelV2(string prop = default, EnumV2 enumProp = default, BinaryData unionProp = default) => throw null; + + public static ModelV3 ModelV3(string id = default, EnumV3 enumProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Versioning.Removed.V2.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Versioning.Removed.V2.csproj new file mode 100644 index 0000000000..035de495cc --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/src/Versioning.Removed.V2.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.Removed.V2 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.Removed.V2 + 1.0.0-beta.1 + Versioning.Removed.V2 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/tspCodeModel.json new file mode 100644 index 0000000000..bd20f18e41 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2/tspCodeModel.json @@ -0,0 +1,571 @@ +{ + "$id": "1", + "Name": "Versioning.Removed", + "ApiVersions": [ + "v1", + "v2preview", + "v2" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "EnumV2", + "crossLanguageDefinitionId": "Versioning.Removed.EnumV2", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "enumMemberV2", + "value": "enumMemberV2", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "6", + "kind": "enum", + "name": "EnumV3", + "crossLanguageDefinitionId": "Versioning.Removed.EnumV3", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "8", + "kind": "enumvalue", + "name": "enumMemberV1", + "value": "enumMemberV1", + "valueType": { + "$id": "9", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "decorators": [] + }, + { + "$id": "10", + "kind": "enumvalue", + "name": "enumMemberV2Preview", + "value": "enumMemberV2Preview", + "valueType": { + "$id": "11", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "12", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.Removed.Versions", + "valueType": { + "$id": "13", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "14", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "15", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "12" + }, + "description": "The original version v1.", + "decorators": [] + }, + { + "$id": "16", + "kind": "enumvalue", + "name": "v2preview", + "value": "v2preview", + "valueType": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "12" + }, + "description": "The V2 Preview version.", + "decorators": [] + }, + { + "$id": "18", + "kind": "enumvalue", + "name": "v2", + "value": "v2", + "valueType": { + "$id": "19", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "12" + }, + "description": "The latest version v2.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "20", + "kind": "model", + "name": "ModelV2", + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "21", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "22", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.prop" + }, + { + "$id": "23", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "2" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.enumProp" + }, + { + "$id": "24", + "kind": "property", + "name": "unionProp", + "serializedName": "unionProp", + "type": { + "$id": "25", + "kind": "union", + "name": "UnionV2", + "variantTypes": [ + { + "$id": "26", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + { + "$id": "27", + "kind": "float32", + "name": "float32", + "crossLanguageDefinitionId": "TypeSpec.float32", + "decorators": [] + } + ], + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.unionProp" + } + ] + }, + { + "$id": "28", + "kind": "model", + "name": "ModelV3", + "crossLanguageDefinitionId": "Versioning.Removed.ModelV3", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "29", + "kind": "property", + "name": "id", + "serializedName": "id", + "type": { + "$id": "30", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV3.id" + }, + { + "$id": "31", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "6" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV3.enumProp" + } + ] + } + ], + "Clients": [ + { + "$id": "32", + "Name": "RemovedClient", + "Description": "Test for the `@removed` decorator.", + "Operations": [ + { + "$id": "33", + "Name": "v2", + "ResourceName": "Removed", + "Accessibility": "public", + "Parameters": [ + { + "$id": "34", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "35", + "kind": "constant", + "valueType": { + "$id": "36", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "37", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "38", + "kind": "constant", + "valueType": { + "$id": "39", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "40", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "20" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "41", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "20" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/v2", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.v2", + "Decorators": [] + }, + { + "$id": "42", + "Name": "modelV3", + "ResourceName": "Removed", + "Description": "This operation will pass different paths and different request bodies based on different versions.", + "Accessibility": "public", + "Parameters": [ + { + "$id": "43", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "44", + "kind": "constant", + "valueType": { + "$id": "45", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "46", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "47", + "kind": "constant", + "valueType": { + "$id": "48", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "49", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "28" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "50", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "28" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/v3", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.modelV3", + "Decorators": [] + } + ], + "Protocol": { + "$id": "51" + }, + "Parameters": [ + { + "$id": "52", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "53", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "54", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1', 'v2preview' or 'v2' in client.", + "Type": { + "$ref": "12" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/Configuration.json new file mode 100644 index 0000000000..5fe52d68db --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.Removed.V2Preview", + "library-name": "Versioning.Removed.V2Preview", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/Versioning.Removed.V2Preview.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/Versioning.Removed.V2Preview.sln new file mode 100644 index 0000000000..1fbf99a0e2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/Versioning.Removed.V2Preview.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.Removed.V2Preview", "src\Versioning.Removed.V2Preview.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/InterfaceV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/InterfaceV1.cs new file mode 100644 index 0000000000..37ff67ae66 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/InterfaceV1.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.Removed.V2Preview.Models; + +namespace Versioning.Removed.V2Preview +{ + public partial class InterfaceV1 + { + protected InterfaceV1() => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult V1InInterface(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V1InInterfaceAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V1InInterface(ModelV1 body) => throw null; + + public virtual Task> V1InInterfaceAsync(ModelV1 body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/EnumV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/EnumV1.cs new file mode 100644 index 0000000000..625f364b53 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/EnumV1.cs @@ -0,0 +1,12 @@ +// + +#nullable disable + +namespace Versioning.Removed.V2Preview.Models +{ + public enum EnumV1 + { + /// EnumMember. + EnumMember + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/EnumV2.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/EnumV2.cs new file mode 100644 index 0000000000..01e528b7e2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/EnumV2.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +namespace Versioning.Removed.V2Preview.Models +{ + public enum EnumV2 + { + /// EnumMemberV1. + EnumMemberV1, + /// EnumMemberV2. + EnumMemberV2 + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV1.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV1.Serialization.cs new file mode 100644 index 0000000000..5aebb54060 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV1.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Removed.V2Preview.Models +{ + public partial class ModelV1 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV1 modelV1) => throw null; + + public static explicit operator ModelV1(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV1.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV1.cs new file mode 100644 index 0000000000..1f217d8ee7 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV1.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Removed.V2Preview.Models +{ + public partial class ModelV1 + { + public ModelV1(string prop, EnumV1 enumProp, BinaryData unionProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public EnumV1 EnumProp + { + get => throw null; + set => throw null; + } + + public BinaryData UnionProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV2.Serialization.cs new file mode 100644 index 0000000000..323f8225f1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV2.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Removed.V2Preview.Models +{ + public partial class ModelV2 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV2 modelV2) => throw null; + + public static explicit operator ModelV2(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV2.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV2.cs new file mode 100644 index 0000000000..f1927fa0b9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV2.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Removed.V2Preview.Models +{ + public partial class ModelV2 + { + public ModelV2(string prop, string removedProp, EnumV2 enumProp, BinaryData unionProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public string RemovedProp + { + get => throw null; + set => throw null; + } + + public EnumV2 EnumProp + { + get => throw null; + set => throw null; + } + + public BinaryData UnionProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV3.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV3.Serialization.cs new file mode 100644 index 0000000000..de9f33ae5f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV3.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.Removed.V2Preview.Models +{ + public partial class ModelV3 : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + ModelV3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV3 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + ModelV3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual ModelV3 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(ModelV3 modelV3) => throw null; + + public static explicit operator ModelV3(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV3.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV3.cs new file mode 100644 index 0000000000..cd06f24f03 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/Models/ModelV3.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +namespace Versioning.Removed.V2Preview.Models +{ + public partial class ModelV3 + { + public ModelV3(string id) => throw null; + + public string Id + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/RemovedClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/RemovedClient.cs new file mode 100644 index 0000000000..aec443226b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/RemovedClient.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.Removed.V2Preview.Models; + +namespace Versioning.Removed.V2Preview +{ + public partial class RemovedClient + { + protected RemovedClient() => throw null; + + public RemovedClient(Uri endpoint) : this(endpoint, new RemovedClientOptions()) => throw null; + + public RemovedClient(Uri endpoint, RemovedClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult V1(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V1Async(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V1(ModelV1 body) => throw null; + + public virtual Task> V1Async(ModelV1 body, CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult V2(string @param, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task V2Async(string @param, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult V2(string @param, ModelV2 body) => throw null; + + public virtual Task> V2Async(string @param, ModelV2 body, CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult ModelV3(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task ModelV3Async(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult ModelV3(ModelV3 body) => throw null; + + public virtual Task> ModelV3Async(ModelV3 body, CancellationToken cancellationToken = default) => throw null; + + public virtual InterfaceV1 GetInterfaceV1Client() => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/RemovedClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/RemovedClientOptions.cs new file mode 100644 index 0000000000..0988f7e442 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/RemovedClientOptions.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.Removed.V2Preview +{ + public partial class RemovedClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2preview; + + public RemovedClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The original version v1. + V1 = 1, + /// The V2 Preview version. + V2preview = 2 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/VersioningRemovedV2PreviewModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/VersioningRemovedV2PreviewModelFactory.cs new file mode 100644 index 0000000000..a22d365b09 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Generated/VersioningRemovedV2PreviewModelFactory.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +using System; + +namespace Versioning.Removed.V2Preview.Models +{ + public static partial class VersioningRemovedV2PreviewModelFactory + { + public static ModelV1 ModelV1(string prop = default, EnumV1 enumProp = default, BinaryData unionProp = default) => throw null; + + public static ModelV2 ModelV2(string prop = default, string removedProp = default, EnumV2 enumProp = default, BinaryData unionProp = default) => throw null; + + public static ModelV3 ModelV3(string id = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Versioning.Removed.V2Preview.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Versioning.Removed.V2Preview.csproj new file mode 100644 index 0000000000..47d436fc11 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/src/Versioning.Removed.V2Preview.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.Removed.V2Preview client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.Removed.V2Preview + 1.0.0-beta.1 + Versioning.Removed.V2Preview + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/tspCodeModel.json new file mode 100644 index 0000000000..2a9efd0fd9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/removed/v2Preview/tspCodeModel.json @@ -0,0 +1,941 @@ +{ + "$id": "1", + "Name": "Versioning.Removed", + "ApiVersions": [ + "v1", + "v2preview" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "EnumV1", + "crossLanguageDefinitionId": "Versioning.Removed.EnumV1", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "enumMember", + "value": "enumMember", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "6", + "kind": "enum", + "name": "EnumV2", + "crossLanguageDefinitionId": "Versioning.Removed.EnumV2", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "8", + "kind": "enumvalue", + "name": "enumMemberV1", + "value": "enumMemberV1", + "valueType": { + "$id": "9", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "decorators": [] + }, + { + "$id": "10", + "kind": "enumvalue", + "name": "enumMemberV2", + "value": "enumMemberV2", + "valueType": { + "$id": "11", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "12", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.Removed.Versions", + "valueType": { + "$id": "13", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "14", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "15", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "12" + }, + "description": "The original version v1.", + "decorators": [] + }, + { + "$id": "16", + "kind": "enumvalue", + "name": "v2preview", + "value": "v2preview", + "valueType": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "12" + }, + "description": "The V2 Preview version.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "18", + "kind": "model", + "name": "ModelV1", + "crossLanguageDefinitionId": "Versioning.Removed.ModelV1", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "19", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "20", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV1.prop" + }, + { + "$id": "21", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "2" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV1.enumProp" + }, + { + "$id": "22", + "kind": "property", + "name": "unionProp", + "serializedName": "unionProp", + "type": { + "$id": "23", + "kind": "union", + "name": "UnionV1", + "variantTypes": [ + { + "$id": "24", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + { + "$id": "25", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + ], + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV1.unionProp" + } + ] + }, + { + "$id": "26", + "kind": "model", + "name": "ModelV2", + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "27", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "28", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.prop" + }, + { + "$id": "29", + "kind": "property", + "name": "removedProp", + "serializedName": "removedProp", + "type": { + "$id": "30", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.removedProp" + }, + { + "$id": "31", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "6" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.enumProp" + }, + { + "$id": "32", + "kind": "property", + "name": "unionProp", + "serializedName": "unionProp", + "type": { + "$id": "33", + "kind": "union", + "name": "UnionV2", + "variantTypes": [ + { + "$id": "34", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + { + "$id": "35", + "kind": "float32", + "name": "float32", + "crossLanguageDefinitionId": "TypeSpec.float32", + "decorators": [] + }, + { + "$id": "36", + "kind": "int32", + "name": "V1Scalar", + "crossLanguageDefinitionId": "Versioning.Removed.V1Scalar", + "baseType": { + "$id": "37", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "decorators": [] + } + ], + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV2.unionProp" + } + ] + }, + { + "$id": "38", + "kind": "model", + "name": "ModelV3", + "crossLanguageDefinitionId": "Versioning.Removed.ModelV3", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "39", + "kind": "property", + "name": "id", + "serializedName": "id", + "type": { + "$id": "40", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.Removed.ModelV3.id" + } + ] + } + ], + "Clients": [ + { + "$id": "41", + "Name": "RemovedClient", + "Description": "Test for the `@removed` decorator.", + "Operations": [ + { + "$id": "42", + "Name": "v1", + "ResourceName": "Removed", + "Description": "This operation should not be generated with latest version's signature.", + "Accessibility": "public", + "Parameters": [ + { + "$id": "43", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "44", + "kind": "constant", + "valueType": { + "$id": "45", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "46", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "47", + "kind": "constant", + "valueType": { + "$id": "48", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "49", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "18" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "50", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "18" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/v1", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.v1", + "Decorators": [] + }, + { + "$id": "51", + "Name": "v2", + "ResourceName": "Removed", + "Accessibility": "public", + "Parameters": [ + { + "$id": "52", + "Name": "param", + "NameInRequest": "param", + "Type": { + "$id": "53", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "54", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "55", + "kind": "constant", + "valueType": { + "$id": "56", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "57", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "58", + "kind": "constant", + "valueType": { + "$id": "59", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "60", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "26" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "61", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "26" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/v2", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.v2", + "Decorators": [] + }, + { + "$id": "62", + "Name": "modelV3", + "ResourceName": "Removed", + "Description": "This operation will pass different paths and different request bodies based on different versions.", + "Accessibility": "public", + "Parameters": [ + { + "$id": "63", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "64", + "kind": "constant", + "valueType": { + "$id": "65", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "66", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "67", + "kind": "constant", + "valueType": { + "$id": "68", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "69", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "38" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "70", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "38" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/v3", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.modelV3", + "Decorators": [] + } + ], + "Protocol": { + "$id": "71" + }, + "Parameters": [ + { + "$id": "72", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "73", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "74", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1', 'v2preview' or 'v2' in client.", + "Type": { + "$ref": "12" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + }, + { + "$id": "75", + "Name": "InterfaceV1", + "Description": "This operation group should not be generated with latest version.", + "Operations": [ + { + "$id": "76", + "Name": "v1InInterface", + "ResourceName": "InterfaceV1", + "Accessibility": "public", + "Parameters": [ + { + "$id": "77", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "78", + "kind": "constant", + "valueType": { + "$id": "79", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "80", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "81", + "kind": "constant", + "valueType": { + "$id": "82", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "83", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "18" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "84", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "18" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/removed/api-version:{version}", + "Path": "/interface-v1/v1", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.Removed.InterfaceV1.v1InInterface", + "Decorators": [] + } + ], + "Protocol": { + "$id": "85" + }, + "Parent": "RemovedClient", + "Parameters": [ + { + "$id": "86", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "87", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "88", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1', 'v2preview' or 'v2' in client.", + "Type": { + "$ref": "12" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/Configuration.json new file mode 100644 index 0000000000..4b8e725a4c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.RenamedFrom.V1", + "library-name": "Versioning.RenamedFrom.V1", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/Versioning.RenamedFrom.V1.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/Versioning.RenamedFrom.V1.sln new file mode 100644 index 0000000000..17685e8901 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/Versioning.RenamedFrom.V1.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.RenamedFrom.V1", "src\Versioning.RenamedFrom.V1.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldEnum.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldEnum.cs new file mode 100644 index 0000000000..7aa1dd1e4f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldEnum.cs @@ -0,0 +1,12 @@ +// + +#nullable disable + +namespace Versioning.RenamedFrom.V1.Models +{ + public enum OldEnum + { + /// OldEnumMember. + OldEnumMember + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldModel.Serialization.cs new file mode 100644 index 0000000000..2700fdf5a1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldModel.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.RenamedFrom.V1.Models +{ + public partial class OldModel : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + OldModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual OldModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + OldModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual OldModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(OldModel oldModel) => throw null; + + public static explicit operator OldModel(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldModel.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldModel.cs new file mode 100644 index 0000000000..f897691e26 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/Models/OldModel.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; + +namespace Versioning.RenamedFrom.V1.Models +{ + public partial class OldModel + { + public OldModel(string oldProp, OldEnum enumProp, BinaryData unionProp) => throw null; + + public string OldProp + { + get => throw null; + set => throw null; + } + + public OldEnum EnumProp + { + get => throw null; + set => throw null; + } + + public BinaryData UnionProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/OldInterface.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/OldInterface.cs new file mode 100644 index 0000000000..25c04f8125 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/OldInterface.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.RenamedFrom.V1.Models; + +namespace Versioning.RenamedFrom.V1 +{ + public partial class OldInterface + { + protected OldInterface() => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult NewOpInNewInterface(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task NewOpInNewInterfaceAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult NewOpInNewInterface(OldModel body) => throw null; + + public virtual Task> NewOpInNewInterfaceAsync(OldModel body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/RenamedFromClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/RenamedFromClient.cs new file mode 100644 index 0000000000..a6024326c4 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/RenamedFromClient.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.RenamedFrom.V1.Models; + +namespace Versioning.RenamedFrom.V1 +{ + public partial class RenamedFromClient + { + protected RenamedFromClient() => throw null; + + public RenamedFromClient(Uri endpoint) : this(endpoint, new RenamedFromClientOptions()) => throw null; + + public RenamedFromClient(Uri endpoint, RenamedFromClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult OldOp(string oldQuery, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task OldOpAsync(string oldQuery, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult OldOp(string oldQuery, OldModel body) => throw null; + + public virtual Task> OldOpAsync(string oldQuery, OldModel body, CancellationToken cancellationToken = default) => throw null; + + public virtual OldInterface GetOldInterfaceClient() => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/RenamedFromClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/RenamedFromClientOptions.cs new file mode 100644 index 0000000000..82aade9d37 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/RenamedFromClientOptions.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.RenamedFrom.V1 +{ + public partial class RenamedFromClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V1; + + public RenamedFromClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/VersioningRenamedFromV1ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/VersioningRenamedFromV1ModelFactory.cs new file mode 100644 index 0000000000..38cf8bb6bb --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Generated/VersioningRenamedFromV1ModelFactory.cs @@ -0,0 +1,13 @@ +// + +#nullable disable + +using System; + +namespace Versioning.RenamedFrom.V1.Models +{ + public static partial class VersioningRenamedFromV1ModelFactory + { + public static OldModel OldModel(string oldProp = default, OldEnum enumProp = default, BinaryData unionProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Versioning.RenamedFrom.V1.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Versioning.RenamedFrom.V1.csproj new file mode 100644 index 0000000000..416c1b7769 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/src/Versioning.RenamedFrom.V1.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.RenamedFrom.V1 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.RenamedFrom.V1 + 1.0.0-beta.1 + Versioning.RenamedFrom.V1 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/tspCodeModel.json new file mode 100644 index 0000000000..e9411d9300 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v1/tspCodeModel.json @@ -0,0 +1,515 @@ +{ + "$id": "1", + "Name": "Versioning.RenamedFrom", + "ApiVersions": [ + "v1" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "OldEnum", + "crossLanguageDefinitionId": "Versioning.RenamedFrom.OldEnum", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "oldEnumMember", + "value": "oldEnumMember", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "6", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.RenamedFrom.Versions", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "8", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "9", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "description": "The version v1.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "10", + "kind": "model", + "name": "OldModel", + "crossLanguageDefinitionId": "Versioning.RenamedFrom.OldModel", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "11", + "kind": "property", + "name": "oldProp", + "serializedName": "oldProp", + "type": { + "$id": "12", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.RenamedFrom.OldModel.oldProp" + }, + { + "$id": "13", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "2" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.RenamedFrom.OldModel.enumProp" + }, + { + "$id": "14", + "kind": "property", + "name": "unionProp", + "serializedName": "unionProp", + "type": { + "$id": "15", + "kind": "union", + "name": "OldUnion", + "variantTypes": [ + { + "$id": "16", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + { + "$id": "17", + "kind": "int32", + "name": "OldScalar", + "crossLanguageDefinitionId": "Versioning.RenamedFrom.OldScalar", + "baseType": { + "$id": "18", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "decorators": [] + } + ], + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.RenamedFrom.OldModel.unionProp" + } + ] + } + ], + "Clients": [ + { + "$id": "19", + "Name": "RenamedFromClient", + "Description": "Test for the `@renamedFrom` decorator.", + "Operations": [ + { + "$id": "20", + "Name": "oldOp", + "ResourceName": "RenamedFrom", + "Accessibility": "public", + "Parameters": [ + { + "$id": "21", + "Name": "oldQuery", + "NameInRequest": "newQuery", + "Type": { + "$id": "22", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "23", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "24", + "kind": "constant", + "valueType": { + "$id": "25", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "26", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "27", + "kind": "constant", + "valueType": { + "$id": "28", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "29", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "10" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "30", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "10" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/renamed-from/api-version:{version}", + "Path": "/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.RenamedFrom.oldOp", + "Decorators": [] + } + ], + "Protocol": { + "$id": "31" + }, + "Parameters": [ + { + "$id": "32", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "33", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "34", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "6" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + }, + { + "$id": "35", + "Name": "OldInterface", + "Operations": [ + { + "$id": "36", + "Name": "newOpInNewInterface", + "ResourceName": "OldInterface", + "Accessibility": "public", + "Parameters": [ + { + "$id": "37", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "38", + "kind": "constant", + "valueType": { + "$id": "39", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "40", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "41", + "kind": "constant", + "valueType": { + "$id": "42", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "43", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "10" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "44", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "10" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/renamed-from/api-version:{version}", + "Path": "/interface/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.RenamedFrom.OldInterface.newOpInNewInterface", + "Decorators": [] + } + ], + "Protocol": { + "$id": "45" + }, + "Parent": "RenamedFromClient", + "Parameters": [ + { + "$id": "46", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "47", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "48", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "6" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/Configuration.json new file mode 100644 index 0000000000..fef56b3247 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.RenamedFrom.V2", + "library-name": "Versioning.RenamedFrom.V2", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/Versioning.RenamedFrom.V2.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/Versioning.RenamedFrom.V2.sln new file mode 100644 index 0000000000..6a0dc6ef3c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/Versioning.RenamedFrom.V2.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.RenamedFrom.V2", "src\Versioning.RenamedFrom.V2.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewEnum.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewEnum.cs new file mode 100644 index 0000000000..da46a6b113 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewEnum.cs @@ -0,0 +1,12 @@ +// + +#nullable disable + +namespace Versioning.RenamedFrom.V2.Models +{ + public enum NewEnum + { + /// NewEnumMember. + NewEnumMember + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewModel.Serialization.cs new file mode 100644 index 0000000000..0187a881fe --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewModel.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.RenamedFrom.V2.Models +{ + public partial class NewModel : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + NewModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual NewModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + NewModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual NewModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(NewModel newModel) => throw null; + + public static explicit operator NewModel(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewModel.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewModel.cs new file mode 100644 index 0000000000..4c430c9229 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/Models/NewModel.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; + +namespace Versioning.RenamedFrom.V2.Models +{ + public partial class NewModel + { + public NewModel(string newProp, NewEnum enumProp, BinaryData unionProp) => throw null; + + public string NewProp + { + get => throw null; + set => throw null; + } + + public NewEnum EnumProp + { + get => throw null; + set => throw null; + } + + public BinaryData UnionProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/NewInterface.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/NewInterface.cs new file mode 100644 index 0000000000..ff671a89f8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/NewInterface.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.RenamedFrom.V2.Models; + +namespace Versioning.RenamedFrom.V2 +{ + public partial class NewInterface + { + protected NewInterface() => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult NewOpInNewInterface(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task NewOpInNewInterfaceAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult NewOpInNewInterface(NewModel body) => throw null; + + public virtual Task> NewOpInNewInterfaceAsync(NewModel body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/RenamedFromClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/RenamedFromClient.cs new file mode 100644 index 0000000000..795ef372f6 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/RenamedFromClient.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.RenamedFrom.V2.Models; + +namespace Versioning.RenamedFrom.V2 +{ + public partial class RenamedFromClient + { + protected RenamedFromClient() => throw null; + + public RenamedFromClient(Uri endpoint) : this(endpoint, new RenamedFromClientOptions()) => throw null; + + public RenamedFromClient(Uri endpoint, RenamedFromClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult NewOp(string newQuery, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task NewOpAsync(string newQuery, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult NewOp(string newQuery, NewModel body) => throw null; + + public virtual Task> NewOpAsync(string newQuery, NewModel body, CancellationToken cancellationToken = default) => throw null; + + public virtual NewInterface GetNewInterfaceClient() => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/RenamedFromClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/RenamedFromClientOptions.cs new file mode 100644 index 0000000000..f666e966cb --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/RenamedFromClientOptions.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.RenamedFrom.V2 +{ + public partial class RenamedFromClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2; + + public RenamedFromClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1, + /// The version v2. + V2 = 2 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/VersioningRenamedFromV2ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/VersioningRenamedFromV2ModelFactory.cs new file mode 100644 index 0000000000..78a40258b2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Generated/VersioningRenamedFromV2ModelFactory.cs @@ -0,0 +1,13 @@ +// + +#nullable disable + +using System; + +namespace Versioning.RenamedFrom.V2.Models +{ + public static partial class VersioningRenamedFromV2ModelFactory + { + public static NewModel NewModel(string newProp = default, NewEnum enumProp = default, BinaryData unionProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Versioning.RenamedFrom.V2.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Versioning.RenamedFrom.V2.csproj new file mode 100644 index 0000000000..9e1bb09f6e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/src/Versioning.RenamedFrom.V2.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.RenamedFrom.V2 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.RenamedFrom.V2 + 1.0.0-beta.1 + Versioning.RenamedFrom.V2 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/tspCodeModel.json new file mode 100644 index 0000000000..95d7023057 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/renamedFrom/v2/tspCodeModel.json @@ -0,0 +1,534 @@ +{ + "$id": "1", + "Name": "Versioning.RenamedFrom", + "ApiVersions": [ + "v1", + "v2" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "NewEnum", + "crossLanguageDefinitionId": "Versioning.RenamedFrom.NewEnum", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "newEnumMember", + "value": "newEnumMember", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "decorators": [] + } + ], + "isFixed": true, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "6", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.RenamedFrom.Versions", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "8", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "9", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "description": "The version v1.", + "decorators": [] + }, + { + "$id": "10", + "kind": "enumvalue", + "name": "v2", + "value": "v2", + "valueType": { + "$id": "11", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "6" + }, + "description": "The version v2.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "12", + "kind": "model", + "name": "NewModel", + "crossLanguageDefinitionId": "Versioning.RenamedFrom.NewModel", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "13", + "kind": "property", + "name": "newProp", + "serializedName": "newProp", + "type": { + "$id": "14", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.RenamedFrom.NewModel.newProp" + }, + { + "$id": "15", + "kind": "property", + "name": "enumProp", + "serializedName": "enumProp", + "type": { + "$ref": "2" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.RenamedFrom.NewModel.enumProp" + }, + { + "$id": "16", + "kind": "property", + "name": "unionProp", + "serializedName": "unionProp", + "type": { + "$id": "17", + "kind": "union", + "name": "NewUnion", + "variantTypes": [ + { + "$id": "18", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + { + "$id": "19", + "kind": "int32", + "name": "NewScalar", + "crossLanguageDefinitionId": "Versioning.RenamedFrom.NewScalar", + "baseType": { + "$id": "20", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "decorators": [] + } + ], + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.RenamedFrom.NewModel.unionProp" + } + ] + } + ], + "Clients": [ + { + "$id": "21", + "Name": "RenamedFromClient", + "Description": "Test for the `@renamedFrom` decorator.", + "Operations": [ + { + "$id": "22", + "Name": "newOp", + "ResourceName": "RenamedFrom", + "Accessibility": "public", + "Parameters": [ + { + "$id": "23", + "Name": "newQuery", + "NameInRequest": "newQuery", + "Type": { + "$id": "24", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "25", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "26", + "kind": "constant", + "valueType": { + "$id": "27", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "28", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "29", + "kind": "constant", + "valueType": { + "$id": "30", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "31", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "12" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "32", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "12" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/renamed-from/api-version:{version}", + "Path": "/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.RenamedFrom.newOp", + "Decorators": [] + } + ], + "Protocol": { + "$id": "33" + }, + "Parameters": [ + { + "$id": "34", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "35", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "36", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "6" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + }, + { + "$id": "37", + "Name": "NewInterface", + "Operations": [ + { + "$id": "38", + "Name": "newOpInNewInterface", + "ResourceName": "NewInterface", + "Accessibility": "public", + "Parameters": [ + { + "$id": "39", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "40", + "kind": "constant", + "valueType": { + "$id": "41", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "42", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "43", + "kind": "constant", + "valueType": { + "$id": "44", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "45", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "12" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "46", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "12" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/renamed-from/api-version:{version}", + "Path": "/interface/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.RenamedFrom.NewInterface.newOpInNewInterface", + "Decorators": [] + } + ], + "Protocol": { + "$id": "47" + }, + "Parent": "RenamedFromClient", + "Parameters": [ + { + "$id": "48", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "49", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "50", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "6" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/Configuration.json new file mode 100644 index 0000000000..54a7c0ff83 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.ReturnTypeChangedFrom.V1", + "library-name": "Versioning.ReturnTypeChangedFrom.V1", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/Versioning.ReturnTypeChangedFrom.V1.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/Versioning.ReturnTypeChangedFrom.V1.sln new file mode 100644 index 0000000000..b908d244e8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/Versioning.ReturnTypeChangedFrom.V1.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.ReturnTypeChangedFrom.V1", "src\Versioning.ReturnTypeChangedFrom.V1.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Generated/ReturnTypeChangedFromClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Generated/ReturnTypeChangedFromClient.cs new file mode 100644 index 0000000000..9b9291ec28 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Generated/ReturnTypeChangedFromClient.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Versioning.ReturnTypeChangedFrom.V1 +{ + public partial class ReturnTypeChangedFromClient + { + protected ReturnTypeChangedFromClient() => throw null; + + public ReturnTypeChangedFromClient(Uri endpoint) : this(endpoint, new ReturnTypeChangedFromClientOptions()) => throw null; + + public ReturnTypeChangedFromClient(Uri endpoint, ReturnTypeChangedFromClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult Test(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task TestAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult Test(string body) => throw null; + + public virtual Task> TestAsync(string body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Generated/ReturnTypeChangedFromClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Generated/ReturnTypeChangedFromClientOptions.cs new file mode 100644 index 0000000000..99f5fb8d6e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Generated/ReturnTypeChangedFromClientOptions.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.ReturnTypeChangedFrom.V1 +{ + public partial class ReturnTypeChangedFromClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V1; + + public ReturnTypeChangedFromClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Versioning.ReturnTypeChangedFrom.V1.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Versioning.ReturnTypeChangedFrom.V1.csproj new file mode 100644 index 0000000000..ed95167e9e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/src/Versioning.ReturnTypeChangedFrom.V1.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.ReturnTypeChangedFrom.V1 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.ReturnTypeChangedFrom.V1 + 1.0.0-beta.1 + Versioning.ReturnTypeChangedFrom.V1 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/tspCodeModel.json new file mode 100644 index 0000000000..61dcea416a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v1/tspCodeModel.json @@ -0,0 +1,219 @@ +{ + "$id": "1", + "Name": "Versioning.ReturnTypeChangedFrom", + "ApiVersions": [ + "v1" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.ReturnTypeChangedFrom.Versions", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "description": "The version v1.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [], + "Clients": [ + { + "$id": "6", + "Name": "ReturnTypeChangedFromClient", + "Description": "Test for the `@returnTypeChangedFrom` decorator.", + "Operations": [ + { + "$id": "7", + "Name": "test", + "ResourceName": "ReturnTypeChangedFrom", + "Accessibility": "public", + "Parameters": [ + { + "$id": "8", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "9", + "kind": "constant", + "valueType": { + "$id": "10", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "11", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "12", + "kind": "constant", + "valueType": { + "$id": "13", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "14", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$id": "15", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "16", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$id": "17", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Text", + "Uri": "{endpoint}/versioning/return-type-changed-from/api-version:{version}", + "Path": "/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.ReturnTypeChangedFrom.test", + "Decorators": [] + } + ], + "Protocol": { + "$id": "18" + }, + "Parameters": [ + { + "$id": "19", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "20", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "21", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "2" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/Configuration.json new file mode 100644 index 0000000000..1801b0a8a5 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.ReturnTypeChangedFrom.V2", + "library-name": "Versioning.ReturnTypeChangedFrom.V2", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/Versioning.ReturnTypeChangedFrom.V2.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/Versioning.ReturnTypeChangedFrom.V2.sln new file mode 100644 index 0000000000..2a5767f4e3 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/Versioning.ReturnTypeChangedFrom.V2.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.ReturnTypeChangedFrom.V2", "src\Versioning.ReturnTypeChangedFrom.V2.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Generated/ReturnTypeChangedFromClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Generated/ReturnTypeChangedFromClient.cs new file mode 100644 index 0000000000..6210793c43 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Generated/ReturnTypeChangedFromClient.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Versioning.ReturnTypeChangedFrom.V2 +{ + public partial class ReturnTypeChangedFromClient + { + protected ReturnTypeChangedFromClient() => throw null; + + public ReturnTypeChangedFromClient(Uri endpoint) : this(endpoint, new ReturnTypeChangedFromClientOptions()) => throw null; + + public ReturnTypeChangedFromClient(Uri endpoint, ReturnTypeChangedFromClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult Test(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task TestAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult Test(string body) => throw null; + + public virtual Task> TestAsync(string body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Generated/ReturnTypeChangedFromClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Generated/ReturnTypeChangedFromClientOptions.cs new file mode 100644 index 0000000000..800d45414c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Generated/ReturnTypeChangedFromClientOptions.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.ReturnTypeChangedFrom.V2 +{ + public partial class ReturnTypeChangedFromClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2; + + public ReturnTypeChangedFromClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1, + /// The version v2. + V2 = 2 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Versioning.ReturnTypeChangedFrom.V2.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Versioning.ReturnTypeChangedFrom.V2.csproj new file mode 100644 index 0000000000..19102843c9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/src/Versioning.ReturnTypeChangedFrom.V2.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.ReturnTypeChangedFrom.V2 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.ReturnTypeChangedFrom.V2 + 1.0.0-beta.1 + Versioning.ReturnTypeChangedFrom.V2 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/tspCodeModel.json new file mode 100644 index 0000000000..4e307e361d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/returnTypeChangedFrom/v2/tspCodeModel.json @@ -0,0 +1,238 @@ +{ + "$id": "1", + "Name": "Versioning.ReturnTypeChangedFrom", + "ApiVersions": [ + "v1", + "v2" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.ReturnTypeChangedFrom.Versions", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "description": "The version v1.", + "decorators": [] + }, + { + "$id": "6", + "kind": "enumvalue", + "name": "v2", + "value": "v2", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "description": "The version v2.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [], + "Clients": [ + { + "$id": "8", + "Name": "ReturnTypeChangedFromClient", + "Description": "Test for the `@returnTypeChangedFrom` decorator.", + "Operations": [ + { + "$id": "9", + "Name": "test", + "ResourceName": "ReturnTypeChangedFrom", + "Accessibility": "public", + "Parameters": [ + { + "$id": "10", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "11", + "kind": "constant", + "valueType": { + "$id": "12", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "13", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "14", + "kind": "constant", + "valueType": { + "$id": "15", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "16", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "18", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$id": "19", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Text", + "Uri": "{endpoint}/versioning/return-type-changed-from/api-version:{version}", + "Path": "/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.ReturnTypeChangedFrom.test", + "Decorators": [] + } + ], + "Protocol": { + "$id": "20" + }, + "Parameters": [ + { + "$id": "21", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "22", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "23", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "2" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/Configuration.json new file mode 100644 index 0000000000..43edb1a33e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.TypeChangedFrom.V1", + "library-name": "Versioning.TypeChangedFrom.V1", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/Versioning.TypeChangedFrom.V1.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/Versioning.TypeChangedFrom.V1.sln new file mode 100644 index 0000000000..767110f9be --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/Versioning.TypeChangedFrom.V1.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.TypeChangedFrom.V1", "src\Versioning.TypeChangedFrom.V1.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/Models/TestModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/Models/TestModel.Serialization.cs new file mode 100644 index 0000000000..885d18dcb4 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/Models/TestModel.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.TypeChangedFrom.V1.Models +{ + public partial class TestModel : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + TestModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual TestModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + TestModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual TestModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(TestModel testModel) => throw null; + + public static explicit operator TestModel(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/Models/TestModel.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/Models/TestModel.cs new file mode 100644 index 0000000000..1f103a30b8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/Models/TestModel.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +namespace Versioning.TypeChangedFrom.V1.Models +{ + public partial class TestModel + { + public TestModel(string prop, int changedProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public int ChangedProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/TypeChangedFromClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/TypeChangedFromClient.cs new file mode 100644 index 0000000000..9fe1dab017 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/TypeChangedFromClient.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.TypeChangedFrom.V1.Models; + +namespace Versioning.TypeChangedFrom.V1 +{ + public partial class TypeChangedFromClient + { + protected TypeChangedFromClient() => throw null; + + public TypeChangedFromClient(Uri endpoint) : this(endpoint, new TypeChangedFromClientOptions()) => throw null; + + public TypeChangedFromClient(Uri endpoint, TypeChangedFromClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult Test(BinaryContent content, int @param, RequestOptions options = null) => throw null; + + public virtual Task TestAsync(BinaryContent content, int @param, RequestOptions options = null) => throw null; + + public virtual ClientResult Test(TestModel body, int @param) => throw null; + + public virtual Task> TestAsync(TestModel body, int @param, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/TypeChangedFromClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/TypeChangedFromClientOptions.cs new file mode 100644 index 0000000000..517b7fd75a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/TypeChangedFromClientOptions.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.TypeChangedFrom.V1 +{ + public partial class TypeChangedFromClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V1; + + public TypeChangedFromClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/VersioningTypeChangedFromV1ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/VersioningTypeChangedFromV1ModelFactory.cs new file mode 100644 index 0000000000..791f334b85 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Generated/VersioningTypeChangedFromV1ModelFactory.cs @@ -0,0 +1,11 @@ +// + +#nullable disable + +namespace Versioning.TypeChangedFrom.V1.Models +{ + public static partial class VersioningTypeChangedFromV1ModelFactory + { + public static TestModel TestModel(string prop = default, int changedProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Versioning.TypeChangedFrom.V1.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Versioning.TypeChangedFrom.V1.csproj new file mode 100644 index 0000000000..b2a9feb3d0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/src/Versioning.TypeChangedFrom.V1.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.TypeChangedFrom.V1 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.TypeChangedFrom.V1 + 1.0.0-beta.1 + Versioning.TypeChangedFrom.V1 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/tspCodeModel.json new file mode 100644 index 0000000000..d127fe74bf --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v1/tspCodeModel.json @@ -0,0 +1,281 @@ +{ + "$id": "1", + "Name": "Versioning.TypeChangedFrom", + "ApiVersions": [ + "v1" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.TypeChangedFrom.Versions", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "description": "The version v1.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "6", + "kind": "model", + "name": "TestModel", + "crossLanguageDefinitionId": "Versioning.TypeChangedFrom.TestModel", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "7", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "8", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.TypeChangedFrom.TestModel.prop" + }, + { + "$id": "9", + "kind": "property", + "name": "changedProp", + "serializedName": "changedProp", + "type": { + "$id": "10", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.TypeChangedFrom.TestModel.changedProp" + } + ] + } + ], + "Clients": [ + { + "$id": "11", + "Name": "TypeChangedFromClient", + "Description": "Test for the `@typeChangedFrom` decorator.", + "Operations": [ + { + "$id": "12", + "Name": "test", + "ResourceName": "TypeChangedFrom", + "Accessibility": "public", + "Parameters": [ + { + "$id": "13", + "Name": "param", + "NameInRequest": "param", + "Type": { + "$id": "14", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "15", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "16", + "kind": "constant", + "valueType": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "18", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "19", + "kind": "constant", + "valueType": { + "$id": "20", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "21", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "6" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "22", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "6" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/type-changed-from/api-version:{version}", + "Path": "/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.TypeChangedFrom.test", + "Decorators": [] + } + ], + "Protocol": { + "$id": "23" + }, + "Parameters": [ + { + "$id": "24", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "25", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "26", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "2" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/Configuration.json new file mode 100644 index 0000000000..102113a4b3 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Versioning.TypeChangedFrom.V2", + "library-name": "Versioning.TypeChangedFrom.V2", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/Versioning.TypeChangedFrom.V2.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/Versioning.TypeChangedFrom.V2.sln new file mode 100644 index 0000000000..df0fdc64bd --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/Versioning.TypeChangedFrom.V2.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Versioning.TypeChangedFrom.V2", "src\Versioning.TypeChangedFrom.V2.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/Models/TestModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/Models/TestModel.Serialization.cs new file mode 100644 index 0000000000..97154287b7 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/Models/TestModel.Serialization.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Versioning.TypeChangedFrom.V2.Models +{ + public partial class TestModel : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + TestModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual TestModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + TestModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual TestModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(TestModel testModel) => throw null; + + public static explicit operator TestModel(ClientResult result) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/Models/TestModel.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/Models/TestModel.cs new file mode 100644 index 0000000000..4312b1165b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/Models/TestModel.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +namespace Versioning.TypeChangedFrom.V2.Models +{ + public partial class TestModel + { + public TestModel(string prop, string changedProp) => throw null; + + public string Prop + { + get => throw null; + set => throw null; + } + + public string ChangedProp + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/TypeChangedFromClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/TypeChangedFromClient.cs new file mode 100644 index 0000000000..90ad3cde4e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/TypeChangedFromClient.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Versioning.TypeChangedFrom.V2.Models; + +namespace Versioning.TypeChangedFrom.V2 +{ + public partial class TypeChangedFromClient + { + protected TypeChangedFromClient() => throw null; + + public TypeChangedFromClient(Uri endpoint) : this(endpoint, new TypeChangedFromClientOptions()) => throw null; + + public TypeChangedFromClient(Uri endpoint, TypeChangedFromClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult Test(string @param, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task TestAsync(string @param, BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult Test(string @param, TestModel body) => throw null; + + public virtual Task> TestAsync(string @param, TestModel body, CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/TypeChangedFromClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/TypeChangedFromClientOptions.cs new file mode 100644 index 0000000000..02a531c3d0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/TypeChangedFromClientOptions.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Versioning.TypeChangedFrom.V2 +{ + public partial class TypeChangedFromClientOptions : ClientPipelineOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2; + + public TypeChangedFromClientOptions(ServiceVersion version = LatestVersion) => throw null; + + public enum ServiceVersion + { + /// The version v1. + V1 = 1, + /// The version v2. + V2 = 2 + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/VersioningTypeChangedFromV2ModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/VersioningTypeChangedFromV2ModelFactory.cs new file mode 100644 index 0000000000..403986f012 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Generated/VersioningTypeChangedFromV2ModelFactory.cs @@ -0,0 +1,11 @@ +// + +#nullable disable + +namespace Versioning.TypeChangedFrom.V2.Models +{ + public static partial class VersioningTypeChangedFromV2ModelFactory + { + public static TestModel TestModel(string prop = default, string changedProp = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Versioning.TypeChangedFrom.V2.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Versioning.TypeChangedFrom.V2.csproj new file mode 100644 index 0000000000..a16da8eaab --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/src/Versioning.TypeChangedFrom.V2.csproj @@ -0,0 +1,16 @@ + + + This is the Versioning.TypeChangedFrom.V2 client library for developing .NET applications with rich experience. + SDK Code Generation Versioning.TypeChangedFrom.V2 + 1.0.0-beta.1 + Versioning.TypeChangedFrom.V2 + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/tspCodeModel.json new file mode 100644 index 0000000000..710a591393 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/versioning/typeChangedFrom/v2/tspCodeModel.json @@ -0,0 +1,300 @@ +{ + "$id": "1", + "Name": "Versioning.TypeChangedFrom", + "ApiVersions": [ + "v1", + "v2" + ], + "Enums": [ + { + "$id": "2", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Versioning.TypeChangedFrom.Versions", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "v1", + "value": "v1", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "description": "The version v1.", + "decorators": [] + }, + { + "$id": "6", + "kind": "enumvalue", + "name": "v2", + "value": "v2", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "description": "The version v2.", + "decorators": [] + } + ], + "description": "The version of the API.", + "isFixed": true, + "isFlags": false, + "usage": "Input,ApiVersionEnum", + "decorators": [] + } + ], + "Models": [ + { + "$id": "8", + "kind": "model", + "name": "TestModel", + "crossLanguageDefinitionId": "Versioning.TypeChangedFrom.TestModel", + "usage": "Input,Output,Json", + "decorators": [], + "properties": [ + { + "$id": "9", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "type": { + "$id": "10", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.TypeChangedFrom.TestModel.prop" + }, + { + "$id": "11", + "kind": "property", + "name": "changedProp", + "serializedName": "changedProp", + "type": { + "$id": "12", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Versioning.TypeChangedFrom.TestModel.changedProp" + } + ] + } + ], + "Clients": [ + { + "$id": "13", + "Name": "TypeChangedFromClient", + "Description": "Test for the `@typeChangedFrom` decorator.", + "Operations": [ + { + "$id": "14", + "Name": "test", + "ResourceName": "TypeChangedFrom", + "Accessibility": "public", + "Parameters": [ + { + "$id": "15", + "Name": "param", + "NameInRequest": "param", + "Type": { + "$id": "16", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "17", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Body parameter's content type. Known values are application/json", + "Type": { + "$id": "18", + "kind": "constant", + "valueType": { + "$id": "19", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "20", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "21", + "kind": "constant", + "valueType": { + "$id": "22", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "23", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "8" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "24", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "8" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}/versioning/type-changed-from/api-version:{version}", + "Path": "/test", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Versioning.TypeChangedFrom.test", + "Decorators": [] + } + ], + "Protocol": { + "$id": "25" + }, + "Parameters": [ + { + "$id": "26", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "27", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "28", + "Name": "version", + "NameInRequest": "version", + "Description": "Need to be set as 'v1' or 'v2' in client.", + "Type": { + "$ref": "2" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Decorators": [] + } + ] +}