From 3d4589a7f00bd1eb612950331b5ddbdff7804a28 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 14:50:18 +0000 Subject: [PATCH 01/16] Initial plan From 169204f72c0420dd03b683633c0988fa4928f144 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 15:02:37 +0000 Subject: [PATCH 02/16] feat: bump TCGC to 0.67.0 and related dependencies - Update @azure-tools/typespec-client-generator-core from 0.66.3 to 0.67.0 - Update @azure-tools/typespec-azure-core from 0.66.0 to 0.67.0 - Update @typespec/compiler, http, openapi from 1.10.0 to 1.11.0 - Update @typespec/rest, sse, streams, versioning, xml from 0.80.0 to 0.81.0 - Update peer dependencies to match new version ranges - Fix __raw.services breaking change (was __raw.service) - Guard getAccessOverride for synthetic enums without __raw - Update multi-service tests to use autoMergeService and remove @useDependency Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/9b068e45-e5ee-46b0-8dec-fc0c79650546 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../emitter/src/lib/type-converter.ts | 4 +- .../emitter/src/lib/utils.ts | 2 +- .../test/Unit/client-converter.test.ts | 5 +- .../test/Unit/client-model-builder.test.ts | 3 +- packages/http-client-csharp/package-lock.json | 577 +++++++++--------- packages/http-client-csharp/package.json | 46 +- 6 files changed, 334 insertions(+), 303 deletions(-) diff --git a/packages/http-client-csharp/emitter/src/lib/type-converter.ts b/packages/http-client-csharp/emitter/src/lib/type-converter.ts index ded35eb85e8..10ca931a054 100644 --- a/packages/http-client-csharp/emitter/src/lib/type-converter.ts +++ b/packages/http-client-csharp/emitter/src/lib/type-converter.ts @@ -329,7 +329,9 @@ function createEnumType( values: values, // constantType.access, TODO - constant type now does not have access. TCGC will add it later access: - sdkType.kind === "enum" ? getAccessOverride(sdkContext, sdkType.__raw as any) : undefined, + sdkType.kind === "enum" && sdkType.__raw + ? getAccessOverride(sdkContext, sdkType.__raw as any) + : undefined, namespace: namespace, deprecation: sdkType.deprecation, summary: sdkType.summary, diff --git a/packages/http-client-csharp/emitter/src/lib/utils.ts b/packages/http-client-csharp/emitter/src/lib/utils.ts index aa8af4d3889..3f0ff32ffc3 100644 --- a/packages/http-client-csharp/emitter/src/lib/utils.ts +++ b/packages/http-client-csharp/emitter/src/lib/utils.ts @@ -234,5 +234,5 @@ export function containsMultiServiceClient( * @beta */ export function isMultiServiceClient(client: SdkClientType): boolean { - return Array.isArray(client.__raw.service) && client.__raw.service.length > 1; + return client.__raw.services.length > 1; } diff --git a/packages/http-client-csharp/emitter/test/Unit/client-converter.test.ts b/packages/http-client-csharp/emitter/test/Unit/client-converter.test.ts index 8aa7561cbf7..77c21d09e02 100644 --- a/packages/http-client-csharp/emitter/test/Unit/client-converter.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/client-converter.test.ts @@ -72,8 +72,8 @@ describe("isMultiServiceClient", () => { @client({ name: "CombinedClient", service: [ServiceA, ServiceB], + autoMergeService: true, }) - @useDependency(ServiceA.VersionsA.av1, ServiceB.VersionsB.bv2) namespace Service.MultiService {} `, runner, @@ -210,6 +210,7 @@ describe("isMultiServiceClient", () => { @client({ name: "CombinedClient", service: [ServiceA, ServiceB], + autoMergeService: true, }) namespace Service.MultiService {} @@ -426,8 +427,8 @@ describe("client name suffix", () => { @client({ name: "Combined", service: [ServiceA, ServiceB], + autoMergeService: true, }) - @useDependency(ServiceA.VersionsA.av1, ServiceB.VersionsB.bv1) namespace Service.MultiService {} `, runner, diff --git a/packages/http-client-csharp/emitter/test/Unit/client-model-builder.test.ts b/packages/http-client-csharp/emitter/test/Unit/client-model-builder.test.ts index 908ed25ab19..5ce773fe969 100644 --- a/packages/http-client-csharp/emitter/test/Unit/client-model-builder.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/client-model-builder.test.ts @@ -290,8 +290,8 @@ describe("parseApiVersions", () => { @client({ name: "CombinedClient", service: [ServiceA, ServiceB], + autoMergeService: true, }) - @useDependency(ServiceA.VersionsA.av1, ServiceB.VersionsB.bv2) namespace Service.MultiService {} `, runner, @@ -406,6 +406,7 @@ describe("parseApiVersions", () => { @client({ name: "CombinedClient", service: [ServiceA, ServiceB], + autoMergeService: true, }) namespace Service.MultiService {} diff --git a/packages/http-client-csharp/package-lock.json b/packages/http-client-csharp/package-lock.json index 0291e11aba4..c6578f0a3c9 100644 --- a/packages/http-client-csharp/package-lock.json +++ b/packages/http-client-csharp/package-lock.json @@ -9,24 +9,24 @@ "version": "1.0.0", "license": "MIT", "devDependencies": { - "@azure-tools/azure-http-specs": "0.1.0-alpha.38", - "@azure-tools/typespec-azure-core": "0.66.0", - "@azure-tools/typespec-client-generator-core": "0.66.3", + "@azure-tools/azure-http-specs": "0.1.0-alpha.39", + "@azure-tools/typespec-azure-core": "0.67.0", + "@azure-tools/typespec-client-generator-core": "0.67.0", "@microsoft/api-extractor": "^7.52.2", "@types/node": "~22.12.0", - "@typespec/compiler": "1.10.0", - "@typespec/http": "1.10.0", - "@typespec/http-specs": "0.1.0-alpha.35", - "@typespec/json-schema": "1.10.0", - "@typespec/library-linter": "0.80.0", - "@typespec/openapi": "1.10.0", - "@typespec/rest": "0.80.0", - "@typespec/spector": "0.1.0-alpha.24", - "@typespec/sse": "0.80.0", - "@typespec/streams": "0.80.0", + "@typespec/compiler": "1.11.0", + "@typespec/http": "1.11.0", + "@typespec/http-specs": "0.1.0-alpha.36", + "@typespec/json-schema": "1.11.0", + "@typespec/library-linter": "0.81.0", + "@typespec/openapi": "1.11.0", + "@typespec/rest": "0.81.0", + "@typespec/spector": "0.1.0-alpha.25", + "@typespec/sse": "0.81.0", + "@typespec/streams": "0.81.0", "@typespec/tspd": "0.74.1", - "@typespec/versioning": "0.80.0", - "@typespec/xml": "0.80.0", + "@typespec/versioning": "0.81.0", + "@typespec/xml": "0.81.0", "@vitest/coverage-v8": "^3.0.5", "@vitest/ui": "^3.0.5", "c8": "^10.1.2", @@ -35,14 +35,14 @@ "vitest": "^3.0.5" }, "peerDependencies": { - "@azure-tools/typespec-client-generator-core": ">=0.66.3 <0.67.0 || ~0.67.0-0", - "@typespec/compiler": "^1.10.0", - "@typespec/http": "^1.10.0", - "@typespec/openapi": "^1.10.0", - "@typespec/rest": ">=0.80.0 <0.81.0 || ~0.81.0-0", - "@typespec/sse": ">=0.80.0 <0.81.0 || ~0.81.0-0", - "@typespec/streams": ">=0.80.0 <0.81.0 || ~0.81.0-0", - "@typespec/versioning": ">=0.80.0 <0.81.0 || ~0.81.0-0" + "@azure-tools/typespec-client-generator-core": ">=0.67.0 <0.68.0 || ~0.68.0-0", + "@typespec/compiler": "^1.11.0", + "@typespec/http": "^1.11.0", + "@typespec/openapi": "^1.11.0", + "@typespec/rest": ">=0.81.0 <0.82.0 || ~0.82.0-0", + "@typespec/sse": ">=0.81.0 <0.82.0 || ~0.82.0-0", + "@typespec/streams": ">=0.81.0 <0.82.0 || ~0.82.0-0", + "@typespec/versioning": ">=0.81.0 <0.82.0 || ~0.82.0-0" } }, "node_modules/@alloy-js/core": { @@ -97,46 +97,46 @@ } }, "node_modules/@azure-tools/azure-http-specs": { - "version": "0.1.0-alpha.38", - "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.38.tgz", - "integrity": "sha512-OkwmMhmSNOV4PO4UA4Tm4ufyA0UPcOrWgZuhybQjWzUq0bbryW9y5ODyknvUV0Z0IOAInW1dUJQ2wRX9pLqNCA==", + "version": "0.1.0-alpha.39", + "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.39.tgz", + "integrity": "sha512-l9d2Y+B7QBi20ocDJEGO7NpvpCePvdw2ALz1RHAPWBOD0tPUBXUQ4WF1zUC199awz8hQysNRM9jm8x+eoUvjEQ==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.13", - "@typespec/spector": "^0.1.0-alpha.24" + "@typespec/spec-api": "^0.1.0-alpha.14", + "@typespec/spector": "^0.1.0-alpha.25" }, "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.66.0", - "@typespec/compiler": "^1.10.0", - "@typespec/http": "^1.10.0", - "@typespec/rest": "^0.80.0", - "@typespec/versioning": "^0.80.0", - "@typespec/xml": "^0.80.0" + "@azure-tools/typespec-azure-core": "^0.67.0", + "@typespec/compiler": "^1.11.0", + "@typespec/http": "^1.11.0", + "@typespec/rest": "^0.81.0", + "@typespec/versioning": "^0.81.0", + "@typespec/xml": "^0.81.0" } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.66.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.66.0.tgz", - "integrity": "sha512-OBKxRN7AucK3snh+GtLKSDdcZTz08IgcSZlIO3c4KSlmcR5twT1NMyqf1+V8SAhyOdZimndb+ikzrkkgab+GpA==", + "version": "0.67.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.67.0.tgz", + "integrity": "sha512-6DO/fOlVihMlPG0oDXrgURf5MNF4iBzPx5SMA5aaFDx/fW6MjiD+TN9Yy9O+l9mVNh1XaEMjhjA8/lmnHZ/U0g==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0", - "@typespec/http": "^1.10.0", - "@typespec/rest": "^0.80.0" + "@typespec/compiler": "^1.11.0", + "@typespec/http": "^1.11.0", + "@typespec/rest": "^0.81.0" } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.66.3", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.66.3.tgz", - "integrity": "sha512-sNetQ6igxAp/vL6X2kEIy715ToDTqoJeb+OL59GEUtOW/3KBSi5tsxvDdCwSfEoaNEmv/FYjh/gJDwAWCJdFJg==", + "version": "0.67.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.67.0.tgz", + "integrity": "sha512-cJZHRDnSSNhx8DpHudUMDpajpDQD3+lsAXI633dsQYIKdTuP10UEgRUgIKSkF0+ck0kJOeI25r/TBH2P+V/k6Q==", "dev": true, "license": "MIT", "dependencies": { @@ -148,16 +148,16 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.66.0", - "@typespec/compiler": "^1.10.0", - "@typespec/events": "^0.80.0", - "@typespec/http": "^1.10.0", - "@typespec/openapi": "^1.10.0", - "@typespec/rest": "^0.80.0", - "@typespec/sse": "^0.80.0", - "@typespec/streams": "^0.80.0", - "@typespec/versioning": "^0.80.0", - "@typespec/xml": "^0.80.0" + "@azure-tools/typespec-azure-core": "^0.67.0", + "@typespec/compiler": "^1.11.0", + "@typespec/events": "^0.81.0", + "@typespec/http": "^1.11.0", + "@typespec/openapi": "^1.11.0", + "@typespec/rest": "^0.81.0", + "@typespec/sse": "^0.81.0", + "@typespec/streams": "^0.81.0", + "@typespec/versioning": "^0.81.0", + "@typespec/xml": "^0.81.0" } }, "node_modules/@azure/abort-controller": { @@ -315,9 +315,9 @@ } }, "node_modules/@azure/identity": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.13.0.tgz", - "integrity": "sha512-uWC0fssc+hs1TGGVkkghiaFkkS7NkTxfnCH+Hdg+yTehTpMcehpok4PgUKKdyCH+9ldu6FhiHRv84Ntqj1vVcw==", + "version": "4.13.1", + "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.13.1.tgz", + "integrity": "sha512-5C/2WD5Vb1lHnZS16dNQRPMjN6oV/Upba+C9nBIs15PmOi6A3ZGs4Lr2u60zw4S04gi+u3cEXiqTVP7M4Pz3kw==", "dev": true, "license": "MIT", "dependencies": { @@ -328,8 +328,8 @@ "@azure/core-tracing": "^1.0.0", "@azure/core-util": "^1.11.0", "@azure/logger": "^1.0.0", - "@azure/msal-browser": "^4.2.0", - "@azure/msal-node": "^3.5.0", + "@azure/msal-browser": "^5.5.0", + "@azure/msal-node": "^5.1.0", "open": "^10.1.0", "tslib": "^2.2.0" }, @@ -352,22 +352,22 @@ } }, "node_modules/@azure/msal-browser": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-4.29.0.tgz", - "integrity": "sha512-/f3eHkSNUTl6DLQHm+bKecjBKcRQxbd/XLx8lvSYp8Nl/HRyPuIPOijt9Dt0sH50/SxOwQ62RnFCmFlGK+bR/w==", + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-5.6.3.tgz", + "integrity": "sha512-sTjMtUm+bJpENU/1WlRzHEsgEHppZDZ1EtNyaOODg/sQBtMxxJzGB+MOCM+T2Q5Qe1fKBrdxUmjyRxm0r7Ez9w==", "dev": true, "license": "MIT", "dependencies": { - "@azure/msal-common": "15.15.0" + "@azure/msal-common": "16.4.1" }, "engines": { "node": ">=0.8.0" } }, "node_modules/@azure/msal-common": { - "version": "15.15.0", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-15.15.0.tgz", - "integrity": "sha512-/n+bN0AKlVa+AOcETkJSKj38+bvFs78BaP4rNtv3MJCmPH0YrHiskMRe74OhyZ5DZjGISlFyxqvf9/4QVEi2tw==", + "version": "16.4.1", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-16.4.1.tgz", + "integrity": "sha512-Bl8f+w37xkXsYh7QRkAKCFGYtWMYuOVO7Lv+BxILrvGz3HbIEF22Pt0ugyj0QPOl6NLrHcnNUQ9yeew98P/5iw==", "dev": true, "license": "MIT", "engines": { @@ -375,18 +375,18 @@ } }, "node_modules/@azure/msal-node": { - "version": "3.8.8", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-3.8.8.tgz", - "integrity": "sha512-+f1VrJH1iI517t4zgmuhqORja0bL6LDQXfBqkjuMmfTYXTQQnh1EvwwxO3UbKLT05N0obF72SRHFrC1RBDv5Gg==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-5.1.2.tgz", + "integrity": "sha512-DoeSJ9U5KPAIZoHsPywvfEj2MhBniQe0+FSpjLUTdWoIkI999GB5USkW6nNEHnIaLVxROHXvprWA1KzdS1VQ4A==", "dev": true, "license": "MIT", "dependencies": { - "@azure/msal-common": "15.15.0", + "@azure/msal-common": "16.4.1", "jsonwebtoken": "^9.0.0", "uuid": "^8.3.0" }, "engines": { - "node": ">=16" + "node": ">=20" } }, "node_modules/@azure/storage-blob": { @@ -979,9 +979,9 @@ } }, "node_modules/@inquirer/ansi": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.3.tgz", - "integrity": "sha512-g44zhR3NIKVs0zUesa4iMzExmZpLUdTLRMCStqX3GE5NT6VkPcxQGJ+uC8tDgBUC/vB1rUhUd55cOf++4NZcmw==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.5.tgz", + "integrity": "sha512-doc2sWgJpbFQ64UflSVd17ibMGDuxO1yKgOgLMwavzESnXjFWJqUeG8saYosqKpHp4kWiM5x1nXvEjbpx90gzw==", "dev": true, "license": "MIT", "engines": { @@ -989,16 +989,16 @@ } }, "node_modules/@inquirer/checkbox": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-5.0.4.tgz", - "integrity": "sha512-DrAMU3YBGMUAp6ArwTIp/25CNDtDbxk7UjIrrtM25JVVrlVYlVzHh5HR1BDFu9JMyUoZ4ZanzeaHqNDttf3gVg==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-5.1.3.tgz", + "integrity": "sha512-+G7I8CT+EHv/hasNfUl3P37DVoMoZfpA+2FXmM54dA8MxYle1YqucxbacxHalw1iAFSdKNEDTGNV7F+j1Ldqcg==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/ansi": "^2.0.3", - "@inquirer/core": "^11.1.1", - "@inquirer/figures": "^2.0.3", - "@inquirer/type": "^4.0.3" + "@inquirer/ansi": "^2.0.5", + "@inquirer/core": "^11.1.8", + "@inquirer/figures": "^2.0.5", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1013,14 +1013,14 @@ } }, "node_modules/@inquirer/confirm": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-6.0.4.tgz", - "integrity": "sha512-WdaPe7foUnoGYvXzH4jp4wH/3l+dBhZ3uwhKjXjwdrq5tEIFaANxj6zrGHxLdsIA0yKM0kFPVcEalOZXBB5ISA==", + "version": "6.0.11", + "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-6.0.11.tgz", + "integrity": "sha512-pTpHjg0iEIRMYV/7oCZUMf27/383E6Wyhfc/MY+AVQGEoUobffIYWOK9YLP2XFRGz/9i6WlTQh1CkFVIo2Y7XA==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/core": "^11.1.1", - "@inquirer/type": "^4.0.3" + "@inquirer/core": "^11.1.8", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1035,19 +1035,19 @@ } }, "node_modules/@inquirer/core": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-11.1.1.tgz", - "integrity": "sha512-hV9o15UxX46OyQAtaoMqAOxGR8RVl1aZtDx1jHbCtSJy1tBdTfKxLPKf7utsE4cRy4tcmCQ4+vdV+ca+oNxqNA==", + "version": "11.1.8", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-11.1.8.tgz", + "integrity": "sha512-/u+yJk2pOKNDOh1ZgdUH2RQaRx6OOH4I0uwL95qPvTFTIL38YBsuSC4r1yXBB3Q6JvNqFFc202gk0Ew79rrcjA==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/ansi": "^2.0.3", - "@inquirer/figures": "^2.0.3", - "@inquirer/type": "^4.0.3", + "@inquirer/ansi": "^2.0.5", + "@inquirer/figures": "^2.0.5", + "@inquirer/type": "^4.0.5", "cli-width": "^4.1.0", + "fast-wrap-ansi": "^0.2.0", "mute-stream": "^3.0.0", - "signal-exit": "^4.1.0", - "wrap-ansi": "^9.0.2" + "signal-exit": "^4.1.0" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1062,15 +1062,15 @@ } }, "node_modules/@inquirer/editor": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-5.0.4.tgz", - "integrity": "sha512-QI3Jfqcv6UO2/VJaEFONH8Im1ll++Xn/AJTBn9Xf+qx2M+H8KZAdQ5sAe2vtYlo+mLW+d7JaMJB4qWtK4BG3pw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-5.1.0.tgz", + "integrity": "sha512-6wlkYl65Qfayy48gPCfU4D7li6KCAGN79mLXa/tYHZH99OfZ820yY+HA+DgE88r8YwwgeuY6PQgNqMeK6LuMmw==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/core": "^11.1.1", - "@inquirer/external-editor": "^2.0.3", - "@inquirer/type": "^4.0.3" + "@inquirer/core": "^11.1.8", + "@inquirer/external-editor": "^3.0.0", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1085,14 +1085,14 @@ } }, "node_modules/@inquirer/expand": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-5.0.4.tgz", - "integrity": "sha512-0I/16YwPPP0Co7a5MsomlZLpch48NzYfToyqYAOWtBmaXSB80RiNQ1J+0xx2eG+Wfxt0nHtpEWSRr6CzNVnOGg==", + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-5.0.12.tgz", + "integrity": "sha512-vOfrB33b7YIZfDauXS8vNNz2Z86FozTZLIt7e+7/dCaPJ1RXZsHCuI9TlcERzEUq57vkM+UdnBgxP0rFd23JYQ==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/core": "^11.1.1", - "@inquirer/type": "^4.0.3" + "@inquirer/core": "^11.1.8", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1107,9 +1107,9 @@ } }, "node_modules/@inquirer/external-editor": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@inquirer/external-editor/-/external-editor-2.0.3.tgz", - "integrity": "sha512-LgyI7Agbda74/cL5MvA88iDpvdXI2KuMBCGRkbCl2Dg1vzHeOgs+s0SDcXV7b+WZJrv2+ERpWSM65Fpi9VfY3w==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@inquirer/external-editor/-/external-editor-3.0.0.tgz", + "integrity": "sha512-lDSwMgg+M5rq6JKBYaJwSX6T9e/HK2qqZ1oxmOwn4AQoJE5D+7TumsxLGC02PWS//rkIVqbZv3XA3ejsc9FYvg==", "dev": true, "license": "MIT", "dependencies": { @@ -1129,9 +1129,9 @@ } }, "node_modules/@inquirer/figures": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-2.0.3.tgz", - "integrity": "sha512-y09iGt3JKoOCBQ3w4YrSJdokcD8ciSlMIWsD+auPu+OZpfxLuyz+gICAQ6GCBOmJJt4KEQGHuZSVff2jiNOy7g==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-2.0.5.tgz", + "integrity": "sha512-NsSs4kzfm12lNetHwAn3GEuH317IzpwrMCbOuMIVytpjnJ90YYHNwdRgYGuKmVxwuIqSgqk3M5qqQt1cDk0tGQ==", "dev": true, "license": "MIT", "engines": { @@ -1139,14 +1139,14 @@ } }, "node_modules/@inquirer/input": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-5.0.4.tgz", - "integrity": "sha512-4B3s3jvTREDFvXWit92Yc6jF1RJMDy2VpSqKtm4We2oVU65YOh2szY5/G14h4fHlyQdpUmazU5MPCFZPRJ0AOw==", + "version": "5.0.11", + "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-5.0.11.tgz", + "integrity": "sha512-twUWidn4ocPO8qi6fRM7tNWt7W1FOnOZqQ+/+PsfLUacMR5rFLDPK9ql0nBPwxi0oELbo8T5NhRs8B2+qQEqFQ==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/core": "^11.1.1", - "@inquirer/type": "^4.0.3" + "@inquirer/core": "^11.1.8", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1161,14 +1161,14 @@ } }, "node_modules/@inquirer/number": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-4.0.4.tgz", - "integrity": "sha512-CmMp9LF5HwE+G/xWsC333TlCzYYbXMkcADkKzcawh49fg2a1ryLc7JL1NJYYt1lJ+8f4slikNjJM9TEL/AljYQ==", + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-4.0.11.tgz", + "integrity": "sha512-Vscmim9TCksQsfjPtka/JwPUcbLhqWYrgfPf1cHrCm24X/F2joFwnageD50yMKsaX14oNGOyKf/RNXAFkNjWpA==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/core": "^11.1.1", - "@inquirer/type": "^4.0.3" + "@inquirer/core": "^11.1.8", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1183,15 +1183,15 @@ } }, "node_modules/@inquirer/password": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-5.0.4.tgz", - "integrity": "sha512-ZCEPyVYvHK4W4p2Gy6sTp9nqsdHQCfiPXIP9LbJVW4yCinnxL/dDDmPaEZVysGrj8vxVReRnpfS2fOeODe9zjg==", + "version": "5.0.11", + "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-5.0.11.tgz", + "integrity": "sha512-9KZFeRaNHIcejtPb0wN4ddFc7EvobVoAFa049eS3LrDZFxI8O7xUXiITEOinBzkZFAIwY5V4yzQae/QfO9cbbg==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/ansi": "^2.0.3", - "@inquirer/core": "^11.1.1", - "@inquirer/type": "^4.0.3" + "@inquirer/ansi": "^2.0.5", + "@inquirer/core": "^11.1.8", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1206,22 +1206,22 @@ } }, "node_modules/@inquirer/prompts": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-8.2.0.tgz", - "integrity": "sha512-rqTzOprAj55a27jctS3vhvDDJzYXsr33WXTjODgVOru21NvBo9yIgLIAf7SBdSV0WERVly3dR6TWyp7ZHkvKFA==", + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-8.4.1.tgz", + "integrity": "sha512-AH5xPQ997K7e0F0vulPlteIHke2awMkFi8F0dBemrDfmvtPmHJo82mdHbONC4F/t8d1NHwrbI5cGVI+RbLWdoQ==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/checkbox": "^5.0.4", - "@inquirer/confirm": "^6.0.4", - "@inquirer/editor": "^5.0.4", - "@inquirer/expand": "^5.0.4", - "@inquirer/input": "^5.0.4", - "@inquirer/number": "^4.0.4", - "@inquirer/password": "^5.0.4", - "@inquirer/rawlist": "^5.2.0", - "@inquirer/search": "^4.1.0", - "@inquirer/select": "^5.0.4" + "@inquirer/checkbox": "^5.1.3", + "@inquirer/confirm": "^6.0.11", + "@inquirer/editor": "^5.1.0", + "@inquirer/expand": "^5.0.12", + "@inquirer/input": "^5.0.11", + "@inquirer/number": "^4.0.11", + "@inquirer/password": "^5.0.11", + "@inquirer/rawlist": "^5.2.7", + "@inquirer/search": "^4.1.7", + "@inquirer/select": "^5.1.3" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1236,14 +1236,14 @@ } }, "node_modules/@inquirer/rawlist": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-5.2.0.tgz", - "integrity": "sha512-CciqGoOUMrFo6HxvOtU5uL8fkjCmzyeB6fG7O1vdVAZVSopUBYECOwevDBlqNLyyYmzpm2Gsn/7nLrpruy9RFg==", + "version": "5.2.7", + "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-5.2.7.tgz", + "integrity": "sha512-AqRMiD9+uE1lskDPrdqHwrV/EUmxKEBLX44SR7uxK3vD2413AmVfE5EQaPeNzYf5Pq5SitHJDYUFVF0poIr09w==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/core": "^11.1.1", - "@inquirer/type": "^4.0.3" + "@inquirer/core": "^11.1.8", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1258,15 +1258,15 @@ } }, "node_modules/@inquirer/search": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-4.1.0.tgz", - "integrity": "sha512-EAzemfiP4IFvIuWnrHpgZs9lAhWDA0GM3l9F4t4mTQ22IFtzfrk8xbkMLcAN7gmVML9O/i+Hzu8yOUyAaL6BKA==", + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-4.1.7.tgz", + "integrity": "sha512-1y7+0N65AWk5RdlXH/Kn13txf3IjIQ7OEfhCEkDTU+h5wKMLq8DUF3P6z+/kLSxDGDtQT1dRBWEUC3o/VvImsQ==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/core": "^11.1.1", - "@inquirer/figures": "^2.0.3", - "@inquirer/type": "^4.0.3" + "@inquirer/core": "^11.1.8", + "@inquirer/figures": "^2.0.5", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1281,16 +1281,16 @@ } }, "node_modules/@inquirer/select": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-5.0.4.tgz", - "integrity": "sha512-s8KoGpPYMEQ6WXc0dT9blX2NtIulMdLOO3LA1UKOiv7KFWzlJ6eLkEYTDBIi+JkyKXyn8t/CD6TinxGjyLt57g==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-5.1.3.tgz", + "integrity": "sha512-zYyqWgGQi3NhBcNq4Isc5rB3oEdQEh1Q/EcAnOW0FK4MpnXWkvSBYgA4cYrTM4A9UB573omouZbnL9JJ74Mq3A==", "dev": true, "license": "MIT", "dependencies": { - "@inquirer/ansi": "^2.0.3", - "@inquirer/core": "^11.1.1", - "@inquirer/figures": "^2.0.3", - "@inquirer/type": "^4.0.3" + "@inquirer/ansi": "^2.0.5", + "@inquirer/core": "^11.1.8", + "@inquirer/figures": "^2.0.5", + "@inquirer/type": "^4.0.5" }, "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1305,9 +1305,9 @@ } }, "node_modules/@inquirer/type": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-4.0.3.tgz", - "integrity": "sha512-cKZN7qcXOpj1h+1eTTcGDVLaBIHNMT1Rz9JqJP5MnEJ0JhgVWllx7H/tahUp5YEK1qaByH2Itb8wLG/iScD5kw==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-4.0.5.tgz", + "integrity": "sha512-aetVUNeKNc/VriqXlw1NRSW0zhMBB0W4bNbWRJgzRl/3d0QNDQFfk0GO5SDdtjMZVg6o8ZKEiadd7SCCzoOn5Q==", "dev": true, "license": "MIT", "engines": { @@ -2105,25 +2105,25 @@ } }, "node_modules/@typespec/compiler": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.10.0.tgz", - "integrity": "sha512-R6BATDkughntPpaxeESJF+wxma5PEjgmnnKvH0/ByqUH8VyhIckQWE9kkP0Uc/EJ0o0VYhe8qCwWQvV70k5lTw==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.11.0.tgz", + "integrity": "sha512-4vuWtoepc4rYJ81K+P7xn2ByXIRhBM40rfzAGnpagNuGSVHuKEC6lqJqs3ePvhCpnxiYAC8XWpaOi+BEDzyhnQ==", "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "~7.29.0", - "@inquirer/prompts": "^8.0.1", + "@inquirer/prompts": "^8.3.0", "ajv": "~8.18.0", "change-case": "~5.4.4", "env-paths": "^4.0.0", - "globby": "~16.1.0", + "globby": "~16.1.1", "is-unicode-supported": "^2.1.0", "mustache": "~4.2.0", "picocolors": "~1.1.1", - "prettier": "~3.8.0", - "semver": "^7.7.1", - "tar": "^7.5.2", - "temporal-polyfill": "^0.3.0", + "prettier": "~3.8.1", + "semver": "^7.7.4", + "tar": "^7.5.11", + "temporal-polyfill": "^0.3.2", "vscode-languageserver": "~9.0.1", "vscode-languageserver-textdocument": "~1.0.12", "yaml": "~2.8.2", @@ -2151,9 +2151,9 @@ } }, "node_modules/@typespec/events": { - "version": "0.80.0", - "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.80.0.tgz", - "integrity": "sha512-FrWEUwxhDNbE2YN4fyqV5Qrz9qFJbvPoiKrJM7dexkb7eyhepq3dbc5zZgAm/qFBQ+XxGQQVJ4swXxKT+338fw==", + "version": "0.81.0", + "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.81.0.tgz", + "integrity": "sha512-ee9QSBL+k6ccPlbJICZzaGt4iC1nTIl+J9sELY9yJNISvOvUEzY5MU8c7HaISB10cUESRJW+oaLWwyc8XjwHng==", "dev": true, "license": "MIT", "peer": true, @@ -2161,21 +2161,21 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0" + "@typespec/compiler": "^1.11.0" } }, "node_modules/@typespec/http": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.10.0.tgz", - "integrity": "sha512-/fj55fmUj4m/FmNdfH0V52menVrmS2r5Xj9d1H+pnjQbxvvaxS906RSRcoF8kbg3PvlibP/Py5u82TAk53AyqA==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.11.0.tgz", + "integrity": "sha512-/DOkN2+MUZyLdmqYmSMZDjxikJTOuNxikTeOwG2fVOibnu8e6S1jzPAuN/mn6YyQBKeBCItMPmUOXIj61Wy8Bg==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0", - "@typespec/streams": "^0.80.0" + "@typespec/compiler": "^1.11.0", + "@typespec/streams": "^0.81.0" }, "peerDependenciesMeta": { "@typespec/streams": { @@ -2184,31 +2184,31 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.35", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.35.tgz", - "integrity": "sha512-xLQUmldKvO0TTOf/wpYLbj2dIuXiQfw3gGKN0ZblD3Q3VGHOXEYEALdQ7lQWn3l2lV33cKgEfC3fX/q/p9N/ug==", + "version": "0.1.0-alpha.36", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.36.tgz", + "integrity": "sha512-2nwh4YIx7MIwkVV8pZWUgp9dgR9U937MANtJvVILcWLLaBTVfLPXNQZjzDccFozzk8QxL7dBWA/gm7i6lsHZcA==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.13", - "@typespec/spector": "^0.1.0-alpha.24", + "@typespec/spec-api": "^0.1.0-alpha.14", + "@typespec/spector": "^0.1.0-alpha.25", "deep-equal": "^2.2.3" }, "engines": { "node": ">=16.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0", - "@typespec/http": "^1.10.0", - "@typespec/rest": "^0.80.0", - "@typespec/versioning": "^0.80.0", - "@typespec/xml": "^0.80.0" + "@typespec/compiler": "^1.11.0", + "@typespec/http": "^1.11.0", + "@typespec/rest": "^0.81.0", + "@typespec/versioning": "^0.81.0", + "@typespec/xml": "^0.81.0" } }, "node_modules/@typespec/json-schema": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@typespec/json-schema/-/json-schema-1.10.0.tgz", - "integrity": "sha512-FZTJvZoIqMbe/4qi17e8q3KF/2VDSyXiiF8QYwH4lar5dtEDGgwrw9ShLeLNiEZh8Ph3GjrQQV5qdpheDFJJvw==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@typespec/json-schema/-/json-schema-1.11.0.tgz", + "integrity": "sha512-Nb/6PGIPpIeM9hBqy+ko7Su64cIHb0hkJhou6wyfKuh7PDG5gj3CEvZSyqYw0Wmb0mcFhcXIVw9kKJizZ/WWyw==", "dev": true, "license": "MIT", "dependencies": { @@ -2219,58 +2219,58 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0" + "@typespec/compiler": "^1.11.0" } }, "node_modules/@typespec/library-linter": { - "version": "0.80.0", - "resolved": "https://registry.npmjs.org/@typespec/library-linter/-/library-linter-0.80.0.tgz", - "integrity": "sha512-7J0jkd6v3360nP/WS9xOPaLIwanaJH/YRkUja7FoOIPyCYem6qnjd/kaCHPo2tV5yZUwvlgE0OkvKTuUHvF/tw==", + "version": "0.81.0", + "resolved": "https://registry.npmjs.org/@typespec/library-linter/-/library-linter-0.81.0.tgz", + "integrity": "sha512-B2PBS41inX//4b5L2THcS8kORh1zawI6TOZ7ybQQ6Nw03sMOU+McDno0uSz8CwheRyfbK9DBv2rG6rX1C6AZYw==", "dev": true, "license": "MIT", "engines": { "node": ">=14.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0" + "@typespec/compiler": "^1.11.0" } }, "node_modules/@typespec/openapi": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.10.0.tgz", - "integrity": "sha512-tukmyp+c9CFlA2FdF61XfT9eTe5WXWz6J8pOrJ9+IYg0BcBwhJkvDj6BYpDD6SjxbRr1wO5ZL2Whe6MequsyVw==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.11.0.tgz", + "integrity": "sha512-xUQrHExKBh0XSP4cn+HcondDXjHJM5HCq2Xfy9tB1QflsFh5uP1JJt1+67g73VmHlhZVSUDcoFrnU95pfjyubg==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0", - "@typespec/http": "^1.10.0" + "@typespec/compiler": "^1.11.0", + "@typespec/http": "^1.11.0" } }, "node_modules/@typespec/rest": { - "version": "0.80.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.80.0.tgz", - "integrity": "sha512-xczXLoB2akSIDner41gQYTS9CG6TdCN0QHYvXBT6ZrYEnBh+pMvdymW//5CSOTamZLOGo9AOJVJaFfwbFA4vQQ==", + "version": "0.81.0", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.81.0.tgz", + "integrity": "sha512-qQXZRKEvq5aNlDFEUqBiiXXPIFyr/+PWgBY0kIrnhyZzMjfUqPInkB12QgXpVp2O2Wm3jmETJD45SaLHTCYBbg==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0", - "@typespec/http": "^1.10.0" + "@typespec/compiler": "^1.11.0", + "@typespec/http": "^1.11.0" } }, "node_modules/@typespec/spec-api": { - "version": "0.1.0-alpha.13", - "resolved": "https://registry.npmjs.org/@typespec/spec-api/-/spec-api-0.1.0-alpha.13.tgz", - "integrity": "sha512-ed0qqGM92vKuangmENUYMeDQZpSlsEMYdeH7+wMl+bIgXzfZ7yv07fNwcmROzSEJd0CzdCTgz+Hp+ifmR4USNQ==", + "version": "0.1.0-alpha.14", + "resolved": "https://registry.npmjs.org/@typespec/spec-api/-/spec-api-0.1.0-alpha.14.tgz", + "integrity": "sha512-MpLVtJZMsONMB9Di9aiXRbbihqa/+4MmbDHpuwd3ka39wtRhcA3sbFQY/+oU5zVEfEAldGgVkenFd2wnoI/xkQ==", "dev": true, "license": "MIT", "dependencies": { - "deep-equal": "^2.2.0", + "deep-equal": "^2.2.3", "express": "^5.2.1", "xml2js": "^0.6.2" }, @@ -2326,27 +2326,27 @@ "license": "MIT" }, "node_modules/@typespec/spector": { - "version": "0.1.0-alpha.24", - "resolved": "https://registry.npmjs.org/@typespec/spector/-/spector-0.1.0-alpha.24.tgz", - "integrity": "sha512-POUSFunRZ4UbPEs+YLz0vE9tDoc6chQ/61moyiWO/k4hD2R1KTH0qlRHhuKW8/Y2wa8Jbuex39Ft/O3reHZSTQ==", + "version": "0.1.0-alpha.25", + "resolved": "https://registry.npmjs.org/@typespec/spector/-/spector-0.1.0-alpha.25.tgz", + "integrity": "sha512-KxMiwA/+XDWpZOdhr7TbnsR8ppXVi+edFa9hdUuerOGQzzALbSeQYUJLUr4RErRiHpqg2/P4FyJ2E0eiA2fTYA==", "dev": true, "license": "MIT", "dependencies": { "@azure/identity": "~4.13.0", - "@typespec/compiler": "^1.10.0", - "@typespec/http": "^1.10.0", - "@typespec/rest": "^0.80.0", - "@typespec/spec-api": "^0.1.0-alpha.13", + "@typespec/compiler": "^1.11.0", + "@typespec/http": "^1.11.0", + "@typespec/rest": "^0.81.0", + "@typespec/spec-api": "^0.1.0-alpha.14", "@typespec/spec-coverage-sdk": "^0.1.0-alpha.16", - "@typespec/versioning": "^0.80.0", + "@typespec/versioning": "^0.81.0", "ajv": "~8.18.0", - "body-parser": "^2.2.0", - "deep-equal": "^2.2.0", + "body-parser": "^2.2.2", + "deep-equal": "^2.2.3", "express": "^5.2.1", - "globby": "~16.1.0", + "globby": "~16.1.1", "micromatch": "^4.0.8", - "morgan": "^1.10.0", - "multer": "^2.0.1", + "morgan": "^1.10.1", + "multer": "^2.1.1", "picocolors": "~1.1.1", "source-map-support": "~0.5.21", "xml2js": "^0.6.2", @@ -2361,32 +2361,32 @@ } }, "node_modules/@typespec/sse": { - "version": "0.80.0", - "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.80.0.tgz", - "integrity": "sha512-/lxYgMaxgEcjBVhep9tf/VnFD2wnkZlkmjUHLeZL8Cuf+qip61Ren6Ml91YtNnnIFYsuuymDzRclrA073ZBR6Q==", + "version": "0.81.0", + "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.81.0.tgz", + "integrity": "sha512-VinoeN+5ClKlGXf77fWayAQna8SaYtvEBhnLR8t8FdvmMsL6ce1LghR2kAL3ARbNXfwMZRmQiq+ajKKebDLIng==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0", - "@typespec/events": "^0.80.0", - "@typespec/http": "^1.10.0", - "@typespec/streams": "^0.80.0" + "@typespec/compiler": "^1.11.0", + "@typespec/events": "^0.81.0", + "@typespec/http": "^1.11.0", + "@typespec/streams": "^0.81.0" } }, "node_modules/@typespec/streams": { - "version": "0.80.0", - "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.80.0.tgz", - "integrity": "sha512-lNvzrvX/ZRIxRpxIBZu90XNsT+uWsMbLtxHd9edspHAiID3c9WKZbl2fnLcPqdR/60odqKve4yGzB9gF58GUDQ==", + "version": "0.81.0", + "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.81.0.tgz", + "integrity": "sha512-IIEKq18aqAtM65f8ZLs3Kzua97wjkr8fTehqPs/Q4neWo2UkDJp64LfA37iXJzaku8xMFSwXdVu4EW8wo+KV8w==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0" + "@typespec/compiler": "^1.11.0" } }, "node_modules/@typespec/ts-http-runtime": { @@ -2434,29 +2434,29 @@ } }, "node_modules/@typespec/versioning": { - "version": "0.80.0", - "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.80.0.tgz", - "integrity": "sha512-WQCT0jN2lSRfwOy+Cd1KUYzenpKR5TdoX0uW6zQdvxQ9nQZIXoaSaReh9/ldhmSV4xv3p2dqF9oq1cdbVGfJTg==", + "version": "0.81.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.81.0.tgz", + "integrity": "sha512-5bha4t64xA85zLY8VGm/6jNd2kwPHzjPq/dlCUjtgGfGXv2R6Ow/YIukqhqZnwnIgNAIlZ7nguekRMRx+2oO2w==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0" + "@typespec/compiler": "^1.11.0" } }, "node_modules/@typespec/xml": { - "version": "0.80.0", - "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.80.0.tgz", - "integrity": "sha512-Qfy5eyCcOF3xYOU/dejhpmmeY75U1Q9C8XBE+GvSZ3lakRfKBIpT+X6Q07qmKSAbGYJZKYLWCIAy/dgCuu/OAA==", + "version": "0.81.0", + "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.81.0.tgz", + "integrity": "sha512-4docnAcV1a8gE4c4TmYuirZf2PEzS4xHUH4QjHFU6hk6J2M6OMU6YG4iSq9tmlUzQ/2DraVcWNO/fsG8Lt383A==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.10.0" + "@typespec/compiler": "^1.11.0" } }, "node_modules/@vitest/coverage-v8": { @@ -3295,9 +3295,9 @@ } }, "node_modules/content-disposition": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", - "integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", "dev": true, "license": "MIT", "engines": { @@ -3833,6 +3833,23 @@ "node": ">=8.6.0" } }, + "node_modules/fast-string-truncated-width": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz", + "integrity": "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-string-width": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/fast-string-width/-/fast-string-width-3.0.2.tgz", + "integrity": "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-string-truncated-width": "^3.0.2" + } + }, "node_modules/fast-uri": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz", @@ -3850,6 +3867,16 @@ ], "license": "BSD-3-Clause" }, + "node_modules/fast-wrap-ansi": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/fast-wrap-ansi/-/fast-wrap-ansi-0.2.0.tgz", + "integrity": "sha512-rLV8JHxTyhVmFYhBJuMujcrHqOT2cnO5Zxj37qROj23CP39GXubJRBUFF0z8KFK77Uc0SukZUf7JZhsVEQ6n8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-string-width": "^3.0.2" + } + }, "node_modules/fast-xml-builder": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.4.tgz", @@ -3867,9 +3894,9 @@ } }, "node_modules/fast-xml-parser": { - "version": "5.5.7", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.5.7.tgz", - "integrity": "sha512-LteOsISQ2GEiDHZch6L9hB0+MLoYVLToR7xotrzU0opCICBkxOPgHAy1HxAvtxfJNXDJpgAsQN30mkrfpO2Prg==", + "version": "5.5.11", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.5.11.tgz", + "integrity": "sha512-QL0eb0YbSTVWF6tTf1+LEMSgtCEjBYPpnAjoLC8SscESlAjXEIRJ7cHtLG0pLeDFaZLa4VKZLArtA/60ZS7vyA==", "dev": true, "funding": [ { @@ -3880,8 +3907,8 @@ "license": "MIT", "dependencies": { "fast-xml-builder": "^1.1.4", - "path-expression-matcher": "^1.1.3", - "strnum": "^2.2.0" + "path-expression-matcher": "^1.4.0", + "strnum": "^2.2.3" }, "bin": { "fxparser": "src/cli/cli.js" @@ -4167,9 +4194,9 @@ } }, "node_modules/globby": { - "version": "16.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-16.1.0.tgz", - "integrity": "sha512-+A4Hq7m7Ze592k9gZRy4gJ27DrXRNnC1vPjxTt1qQxEY8RxagBkBxivkCwg7FxSTG0iLLEMaUx13oOr0R2/qcQ==", + "version": "16.1.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-16.1.1.tgz", + "integrity": "sha512-dW7vl+yiAJSp6aCekaVnVJxurRv7DCOLyXqEG3RYMYUg7AuJ2jCqPkZTA8ooqC2vtnkaMcV5WfFBMuEnTu1OQg==", "dev": true, "license": "MIT", "dependencies": { @@ -5659,9 +5686,9 @@ } }, "node_modules/path-expression-matcher": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.1.3.tgz", - "integrity": "sha512-qdVgY8KXmVdJZRSS1JdEPOKPdTiEK/pi0RkcT2sw1RhXxohdujUlJFPuS1TSkevZ9vzd3ZlL7ULl1MHGTApKzQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.4.0.tgz", + "integrity": "sha512-s4DQMxIdhj3jLFWd9LxHOplj4p9yQ4ffMGowFf3cpEgrrJjEhN0V5nxw4Ye1EViAGDoL4/1AeO6qHpqYPOzE4Q==", "dev": true, "funding": [ { @@ -5709,9 +5736,9 @@ } }, "node_modules/path-to-regexp": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", - "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", "dev": true, "license": "MIT", "funding": { @@ -6162,9 +6189,9 @@ "license": "MIT" }, "node_modules/sax": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.5.0.tgz", - "integrity": "sha512-21IYA3Q5cQf089Z6tgaUTr7lDAyzoTPx5HRtbhsME8Udispad8dC/+sziTNugOEx54ilvatQ9YCzl4KQLPcRHA==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.0.tgz", + "integrity": "sha512-6R3J5M4AcbtLUdZmRv2SygeVaM7IhrLXu9BmnOGmmACak8fiUtOsYNWUS4uK7upbmHIBbLBeFeI//477BKLBzA==", "dev": true, "license": "BlueOak-1.0.0", "engines": { @@ -6639,9 +6666,9 @@ "license": "MIT" }, "node_modules/strnum": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.0.tgz", - "integrity": "sha512-Y7Bj8XyJxnPAORMZj/xltsfo55uOiyHcU2tnAVzHUnSJR/KsEX+9RoDeXEnsXtl/CX4fAcrt64gZ13aGaWPeBg==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.2.3.tgz", + "integrity": "sha512-oKx6RUCuHfT3oyVjtnrmn19H1SiCqgJSg+54XqURKp5aCMbrXrhLjRN9TjuwMjiYstZ0MzDrHqkGZ5dFTKd+zg==", "dev": true, "funding": [ { @@ -6681,9 +6708,9 @@ } }, "node_modules/tar": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.9.tgz", - "integrity": "sha512-BTLcK0xsDh2+PUe9F6c2TlRp4zOOBMTkoQHQIWSIzI0R7KG46uEwq4OPk2W7bZcprBMsuaeFsqwYr7pjh6CuHg==", + "version": "7.5.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.13.tgz", + "integrity": "sha512-tOG/7GyXpFevhXVh8jOPJrmtRpOTsYqUIkVdVooZYJS/z8WhfQUX8RJILmeuJNinGAMSu1veBr4asSHFt5/hng==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -6698,19 +6725,19 @@ } }, "node_modules/temporal-polyfill": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.3.0.tgz", - "integrity": "sha512-qNsTkX9K8hi+FHDfHmf22e/OGuXmfBm9RqNismxBrnSmZVJKegQ+HYYXT+R7Ha8F/YSm2Y34vmzD4cxMu2u95g==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.3.2.tgz", + "integrity": "sha512-TzHthD/heRK947GNiSu3Y5gSPpeUDH34+LESnfsq8bqpFhsB79HFBX8+Z834IVX68P3EUyRPZK5bL/1fh437Eg==", "dev": true, "license": "MIT", "dependencies": { - "temporal-spec": "0.3.0" + "temporal-spec": "0.3.1" } }, "node_modules/temporal-spec": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-0.3.0.tgz", - "integrity": "sha512-n+noVpIqz4hYgFSMOSiINNOUOMFtV5cZQNCmmszA6GiVFVRt3G7AqVyhXjhCSmowvQn+NsGn+jMDMKJYHd3bSQ==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-0.3.1.tgz", + "integrity": "sha512-B4TUhezh9knfSIMwt7RVggApDRJZo73uZdj8AacL2mZ8RP5KtLianh2MXxL06GN9ESYiIsiuoLQhgVfwe55Yhw==", "dev": true, "license": "ISC" }, diff --git a/packages/http-client-csharp/package.json b/packages/http-client-csharp/package.json index d7e2d7198c4..f85e6cde0a9 100644 --- a/packages/http-client-csharp/package.json +++ b/packages/http-client-csharp/package.json @@ -52,34 +52,34 @@ "emitter/lib/*.tsp" ], "peerDependencies": { - "@azure-tools/typespec-client-generator-core": ">=0.66.3 <0.67.0 || ~0.67.0-0", - "@typespec/compiler": "^1.10.0", - "@typespec/http": "^1.10.0", - "@typespec/openapi": "^1.10.0", - "@typespec/rest": ">=0.80.0 <0.81.0 || ~0.81.0-0", - "@typespec/sse": ">=0.80.0 <0.81.0 || ~0.81.0-0", - "@typespec/streams": ">=0.80.0 <0.81.0 || ~0.81.0-0", - "@typespec/versioning": ">=0.80.0 <0.81.0 || ~0.81.0-0" + "@azure-tools/typespec-client-generator-core": ">=0.67.0 <0.68.0 || ~0.68.0-0", + "@typespec/compiler": "^1.11.0", + "@typespec/http": "^1.11.0", + "@typespec/openapi": "^1.11.0", + "@typespec/rest": ">=0.81.0 <0.82.0 || ~0.82.0-0", + "@typespec/sse": ">=0.81.0 <0.82.0 || ~0.82.0-0", + "@typespec/streams": ">=0.81.0 <0.82.0 || ~0.82.0-0", + "@typespec/versioning": ">=0.81.0 <0.82.0 || ~0.82.0-0" }, "devDependencies": { - "@azure-tools/azure-http-specs": "0.1.0-alpha.38", - "@azure-tools/typespec-azure-core": "0.66.0", - "@azure-tools/typespec-client-generator-core": "0.66.3", + "@azure-tools/azure-http-specs": "0.1.0-alpha.39", + "@azure-tools/typespec-azure-core": "0.67.0", + "@azure-tools/typespec-client-generator-core": "0.67.0", "@microsoft/api-extractor": "^7.52.2", "@types/node": "~22.12.0", - "@typespec/compiler": "1.10.0", - "@typespec/http": "1.10.0", - "@typespec/http-specs": "0.1.0-alpha.35", - "@typespec/json-schema": "1.10.0", - "@typespec/library-linter": "0.80.0", - "@typespec/openapi": "1.10.0", - "@typespec/rest": "0.80.0", - "@typespec/spector": "0.1.0-alpha.24", - "@typespec/sse": "0.80.0", - "@typespec/streams": "0.80.0", + "@typespec/compiler": "1.11.0", + "@typespec/http": "1.11.0", + "@typespec/http-specs": "0.1.0-alpha.36", + "@typespec/json-schema": "1.11.0", + "@typespec/library-linter": "0.81.0", + "@typespec/openapi": "1.11.0", + "@typespec/rest": "0.81.0", + "@typespec/spector": "0.1.0-alpha.25", + "@typespec/sse": "0.81.0", + "@typespec/streams": "0.81.0", "@typespec/tspd": "0.74.1", - "@typespec/versioning": "0.80.0", - "@typespec/xml": "0.80.0", + "@typespec/versioning": "0.81.0", + "@typespec/xml": "0.81.0", "@vitest/coverage-v8": "^3.0.5", "@vitest/ui": "^3.0.5", "c8": "^10.1.2", From 09b215a1b24fa39e5bcc7b0bb4deb257e09c1b21 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 15:15:03 +0000 Subject: [PATCH 03/16] chore: regenerate test libraries after TCGC 0.67.0 bump Code model changes include: - Doc string updates (removing @operationGroup references) - crossLanguageDefinitionId now includes full namespace paths - Better naming for constant types - Model ordering changes in code model JSON Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/9b068e45-e5ee-46b0-8dec-fc0c79650546 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../structure/default/tspCodeModel.json | 2 +- .../Generated/DocumentationModelFactory.cs | 1 + .../http/documentation/tspCodeModel.json | 86 +++++++++---------- .../http/parameters/spread/tspCodeModel.json | 18 ++-- .../http/payload/multipart/tspCodeModel.json | 4 +- .../http/payload/pageable/tspCodeModel.json | 4 +- .../Spector/http/type/union/tspCodeModel.json | 10 +-- 7 files changed, 63 insertions(+), 62 deletions(-) diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/default/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/default/tspCodeModel.json index d680b3ba158..426fc3a3869 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/default/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/client/structure/default/tspCodeModel.json @@ -96,7 +96,7 @@ "kind": "client", "name": "ServiceClient", "namespace": "Client.Structure.Service", - "doc": "Test that we can use @client and @operationGroup decorators to customize client side code structure, such as:\n1. have everything as default.\n2. to rename client or operation group\n3. one client can have more than one operations groups\n4. split one interface into two clients\n5. have two clients with operations come from different interfaces\n6. have two clients with a hierarchy relation.", + "doc": "Test that we can use @client decorators to customize client side code structure, such as:\n1. have everything as default.\n2. to rename client or operation group\n3. one client can have more than one operations groups\n4. split one interface into two clients\n5. have two clients with operations come from different interfaces\n6. have two clients with a hierarchy relation.", "methods": [ { "$id": "9", diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/src/Generated/DocumentationModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/src/Generated/DocumentationModelFactory.cs index 4440dc1b6a0..8918ac1946c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/src/Generated/DocumentationModelFactory.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/src/Generated/DocumentationModelFactory.cs @@ -8,6 +8,7 @@ namespace Documentation { public static partial class DocumentationModelFactory { + public static BulletPointsModel BulletPointsModel(BulletPointsEnum prop = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/tspCodeModel.json index 8954a325268..446bfd5157a 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/documentation/tspCodeModel.json @@ -88,45 +88,6 @@ { "$id": "8", "kind": "model", - "name": "BulletPointsModel", - "namespace": "Documentation.Lists", - "crossLanguageDefinitionId": "Documentation.Lists.BulletPointsModel", - "usage": "Input,Json", - "doc": "This tests:\n- Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.\n- Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation.\n- Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.\n- Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.\n- **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines.\n- *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines.", - "decorators": [], - "serializationOptions": { - "json": { - "name": "BulletPointsModel" - } - }, - "properties": [ - { - "$id": "9", - "kind": "property", - "name": "prop", - "serializedName": "prop", - "doc": "This property uses an enum with bullet point documentation. The enum documentation includes various formatting styles to test rendering. The styles are:\n- Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.\n- Bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple\n- Bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.\n- Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.\n- **Bold bullet point**\n- *Italic bullet point*", - "type": { - "$ref": "1" - }, - "optional": false, - "readOnly": false, - "discriminator": false, - "flatten": false, - "decorators": [], - "crossLanguageDefinitionId": "Documentation.Lists.BulletPointsModel.prop", - "serializationOptions": { - "json": { - "name": "prop" - } - }, - "isHttpMetadata": false - } - ] - }, - { - "$id": "10", - "kind": "model", "name": "BulletPointsModelRequest", "namespace": "Documentation.Lists", "crossLanguageDefinitionId": "Documentation.Lists.bulletPointsModel.Request.anonymous", @@ -139,12 +100,48 @@ }, "properties": [ { - "$id": "11", + "$id": "9", "kind": "property", "name": "input", "serializedName": "input", "type": { - "$ref": "8" + "$id": "10", + "kind": "model", + "name": "BulletPointsModel", + "namespace": "Documentation.Lists", + "crossLanguageDefinitionId": "Documentation.Lists.BulletPointsModel", + "usage": "Input,Json", + "doc": "This tests:\n- Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.\n- Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation.\n- Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.\n- Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.\n- **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines.\n- *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines.", + "decorators": [], + "serializationOptions": { + "json": { + "name": "BulletPointsModel" + } + }, + "properties": [ + { + "$id": "11", + "kind": "property", + "name": "prop", + "serializedName": "prop", + "doc": "This property uses an enum with bullet point documentation. The enum documentation includes various formatting styles to test rendering. The styles are:\n- Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.\n- Bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple\n- Bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.\n- Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.\n- **Bold bullet point**\n- *Italic bullet point*", + "type": { + "$ref": "1" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Documentation.Lists.BulletPointsModel.prop", + "serializationOptions": { + "json": { + "name": "prop" + } + }, + "isHttpMetadata": false + } + ] }, "optional": false, "readOnly": false, @@ -160,6 +157,9 @@ "isHttpMetadata": false } ] + }, + { + "$ref": "10" } ], "clients": [ @@ -308,7 +308,7 @@ "name": "bulletPointsModelRequest", "serializedName": "bulletPointsModelRequest", "type": { - "$ref": "10" + "$ref": "8" }, "isApiVersion": false, "contentTypes": [ @@ -327,7 +327,7 @@ "name": "input", "serializedName": "input", "type": { - "$ref": "8" + "$ref": "10" }, "location": "Body", "isApiVersion": false, diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/spread/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/spread/tspCodeModel.json index af620e7ec68..feae073760a 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/spread/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/parameters/spread/tspCodeModel.json @@ -222,7 +222,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "spreadCompositeRequestMix.Request.anonymous.prop", + "crossLanguageDefinitionId": "Parameters.Spread.Model.spreadCompositeRequestMix.Request.anonymous.prop", "serializationOptions": { "json": { "name": "prop" @@ -304,7 +304,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "spreadParameterWithInnerModel.Request.anonymous.name", + "crossLanguageDefinitionId": "Parameters.Spread.Alias.spreadParameterWithInnerModel.Request.anonymous.name", "serializationOptions": { "json": { "name": "name" @@ -345,7 +345,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "spreadAsRequestParameter.Request.anonymous.name", + "crossLanguageDefinitionId": "Parameters.Spread.Alias.spreadAsRequestParameter.Request.anonymous.name", "serializationOptions": { "json": { "name": "name" @@ -387,7 +387,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "spreadWithMultipleParameters.Request.anonymous.requiredString", + "crossLanguageDefinitionId": "Parameters.Spread.Alias.spreadWithMultipleParameters.Request.anonymous.requiredString", "serializationOptions": { "json": { "name": "requiredString" @@ -413,7 +413,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "spreadWithMultipleParameters.Request.anonymous.optionalInt", + "crossLanguageDefinitionId": "Parameters.Spread.Alias.spreadWithMultipleParameters.Request.anonymous.optionalInt", "serializationOptions": { "json": { "name": "optionalInt" @@ -446,7 +446,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "spreadWithMultipleParameters.Request.anonymous.requiredIntList", + "crossLanguageDefinitionId": "Parameters.Spread.Alias.spreadWithMultipleParameters.Request.anonymous.requiredIntList", "serializationOptions": { "json": { "name": "requiredIntList" @@ -479,7 +479,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "spreadWithMultipleParameters.Request.anonymous.optionalStringList", + "crossLanguageDefinitionId": "Parameters.Spread.Alias.spreadWithMultipleParameters.Request.anonymous.optionalStringList", "serializationOptions": { "json": { "name": "optionalStringList" @@ -521,7 +521,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "spreadParameterWithInnerAlias.Request.anonymous.name", + "crossLanguageDefinitionId": "Parameters.Spread.Alias.spreadParameterWithInnerAlias.Request.anonymous.name", "serializationOptions": { "json": { "name": "name" @@ -547,7 +547,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "spreadParameterWithInnerAlias.Request.anonymous.age", + "crossLanguageDefinitionId": "Parameters.Spread.Alias.spreadParameterWithInnerAlias.Request.anonymous.age", "serializationOptions": { "json": { "name": "age" diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/multipart/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/multipart/tspCodeModel.json index cef69d74b7f..d977c404114 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/multipart/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/multipart/tspCodeModel.json @@ -2403,7 +2403,7 @@ "name": "string", "crossLanguageDefinitionId": "TypeSpec.string" }, - "name": "FloatRequestTemperatureContentType", + "name": "FloatRequest1", "isGeneratedName": true }, "name": "contentType", @@ -2411,7 +2411,7 @@ "optional": false, "isApiVersionParam": false, "onClient": false, - "crossLanguageDefinitionId": "Payload.MultiPart.FormData.HttpParts.NonString.float.Request.temperature.anonymous.contentType", + "crossLanguageDefinitionId": "Payload.MultiPart.FormData.HttpParts.NonString.float.Request.anonymous.contentType", "decorators": [], "visibility": [ 1, diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/pageable/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/pageable/tspCodeModel.json index 8295c355212..95fa88e75bc 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/pageable/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/pageable/tspCodeModel.json @@ -1221,7 +1221,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "requestQueryResponseHeader.Response.anonymous.pets", + "crossLanguageDefinitionId": "Payload.Pageable.ServerDrivenPagination.ContinuationToken.requestQueryResponseHeader.Response.anonymous.pets", "serializationOptions": { "json": { "name": "pets" @@ -1258,7 +1258,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "requestHeaderResponseHeader.Response.anonymous.pets", + "crossLanguageDefinitionId": "Payload.Pageable.ServerDrivenPagination.ContinuationToken.requestHeaderResponseHeader.Response.anonymous.pets", "serializationOptions": { "json": { "name": "pets" diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/tspCodeModel.json index 2c21b31efe3..7b5c6d926d3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/tspCodeModel.json @@ -394,7 +394,7 @@ { "$id": "34", "kind": "constant", - "name": "GetResponseProp5", + "name": "MixedLiteralsCasesStringLiteral1", "namespace": "", "usage": "None", "valueType": { @@ -410,7 +410,7 @@ { "$id": "36", "kind": "constant", - "name": "GetResponseProp6", + "name": "MixedLiteralsCasesStringLiteral2", "namespace": "", "usage": "None", "valueType": { @@ -426,7 +426,7 @@ { "$id": "38", "kind": "constant", - "name": "GetResponseProp7", + "name": "MixedLiteralsCasesStringLiteral3", "namespace": "", "usage": "None", "valueType": { @@ -442,7 +442,7 @@ { "$id": "40", "kind": "constant", - "name": "MixedLiteralsCasesStringLiteral1", + "name": "MixedLiteralsCasesStringLiteral4", "namespace": "", "usage": "None", "valueType": { @@ -458,7 +458,7 @@ { "$id": "42", "kind": "constant", - "name": "GetResponseProp51", + "name": "MixedLiteralsCasesStringLiteral11", "namespace": "", "usage": "None", "valueType": { From 3d5aff5cb9e4d917db1827253f28fe5965ea17d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 16:30:43 +0000 Subject: [PATCH 04/16] fix: run full Generate.ps1 regen, update SampleService and fix emitter override - Update SampleService package.json to latest published version (1.0.0-alpha.20260407.1) - Fix Generate.ps1 to use local emitter for SampleService compilation via --emit flag - Regenerate all test projects including Sample-TypeSpec and SampleService - Add newly generated files (ConfigurationSchema.json, Settings files, NuGet targets) Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/9f94861c-2ccb-44cb-ad44-3e6e7238053d Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../Generated/schema/ConfigurationSchema.json | 60 + .../SampleClient/SampleTypeSpec.NuGet.targets | 6 + .../src/Generated/AnimalOperations.cs | 152 +- .../src/Generated/DogOperations.cs | 76 +- .../SampleClient/src/Generated/Metrics.cs | 139 +- .../src/Generated/MetricsSettings.cs | 45 + .../src/Generated/PetOperations.cs | 152 +- .../src/Generated/PlantOperations.cs | 296 +-- .../SampleTypeSpecClient.RestClient.cs | 4 +- .../src/Generated/SampleTypeSpecClient.cs | 2096 +++-------------- .../Generated/SampleTypeSpecClientOptions.cs | 18 + .../Generated/SampleTypeSpecClientSettings.cs | 37 + .../client/csharp/SampleService/package.json | 2 +- packages/http-client-csharp/README.md | 184 ++ .../eng/scripts/Generate.ps1 | 2 +- .../SampleTypeSpecClient.RestClient.cs | 4 +- .../src/Generated/SampleTypeSpecClient.cs | 36 +- .../Local/Sample-TypeSpec/tspCodeModel.json | 633 +++-- .../src/Generated/EnumsOnly.RestClient.cs | 45 + .../type/union/src/Generated/EnumsOnly.cs | 140 +- .../src/Generated/FloatsOnly.RestClient.cs | 45 + .../type/union/src/Generated/FloatsOnly.cs | 134 +- .../union/src/Generated/Internal/Argument.cs | 110 + .../Internal/CancellationTokenExtensions.cs | 14 + .../Internal/ChangeTrackingDictionary.cs | 186 ++ .../Generated/Internal/ChangeTrackingList.cs | 165 ++ .../Internal/ClientPipelineExtensions.cs | 67 + .../Generated/Internal/ClientUriBuilder.cs | 181 ++ .../Internal/CodeGenMemberAttribute.cs | 17 + .../Internal/CodeGenSerializationAttribute.cs | 45 + .../Internal/CodeGenSuppressAttribute.cs | 26 + .../Internal/CodeGenTypeAttribute.cs | 21 + .../src/Generated/Internal/ErrorResult.cs | 24 + .../Internal/ModelSerializationExtensions.cs | 265 +++ .../Generated/Internal/SerializationFormat.cs | 46 + .../src/Generated/Internal/TypeFormatters.cs | 178 ++ .../src/Generated/IntsOnly.RestClient.cs | 45 + .../http/type/union/src/Generated/IntsOnly.cs | 134 +- .../src/Generated/MixedLiterals.RestClient.cs | 45 + .../type/union/src/Generated/MixedLiterals.cs | 140 +- .../src/Generated/MixedTypes.RestClient.cs | 45 + .../type/union/src/Generated/MixedTypes.cs | 140 +- .../src/Generated/Models/Cat.Serialization.cs | 126 +- .../type/union/src/Generated/Models/Cat.cs | 29 +- .../src/Generated/Models/Dog.Serialization.cs | 126 +- .../type/union/src/Generated/Models/Dog.cs | 29 +- .../Models/EnumsOnlyCases.Serialization.cs | 134 +- .../src/Generated/Models/EnumsOnlyCases.cs | 33 +- .../Models/EnumsOnlyCasesLr.Serialization.cs | 43 + .../src/Generated/Models/EnumsOnlyCasesLr.cs | 1 + .../Models/EnumsOnlyCasesUd.Serialization.cs | 33 + .../src/Generated/Models/EnumsOnlyCasesUd.cs | 1 + .../Models/GetResponse.Serialization.cs | 134 +- .../union/src/Generated/Models/GetResponse.cs | 26 +- .../Models/GetResponse1.Serialization.cs | 134 +- .../src/Generated/Models/GetResponse1.cs | 26 +- .../Models/GetResponse2.Serialization.cs | 134 +- .../src/Generated/Models/GetResponse2.cs | 26 +- .../Models/GetResponse3.Serialization.cs | 134 +- .../src/Generated/Models/GetResponse3.cs | 26 +- .../Models/GetResponse4.Serialization.cs | 134 +- .../src/Generated/Models/GetResponse4.cs | 26 +- .../Models/GetResponse5.Serialization.cs | 141 +- .../src/Generated/Models/GetResponse5.cs | 63 +- .../Models/GetResponse6.Serialization.cs | 134 +- .../src/Generated/Models/GetResponse6.cs | 26 +- .../Models/GetResponse7.Serialization.cs | 134 +- .../src/Generated/Models/GetResponse7.cs | 26 +- .../Models/GetResponse8.Serialization.cs | 134 +- .../src/Generated/Models/GetResponse8.cs | 26 +- .../Models/GetResponse9.Serialization.cs | 134 +- .../src/Generated/Models/GetResponse9.cs | 26 +- .../Models/GetResponseProp.Serialization.cs | 38 + .../src/Generated/Models/GetResponseProp.cs | 1 + .../src/Generated/Models/GetResponseProp1.cs | 51 +- .../Models/GetResponseProp2.Serialization.cs | 29 + .../src/Generated/Models/GetResponseProp2.cs | 1 + .../Models/GetResponseProp3.Serialization.cs | 38 + .../src/Generated/Models/GetResponseProp3.cs | 1 + .../MixedLiteralsCases.Serialization.cs | 178 +- .../Generated/Models/MixedLiteralsCases.cs | 236 +- .../Models/MixedTypesCases.Serialization.cs | 221 +- .../src/Generated/Models/MixedTypesCases.cs | 288 ++- .../Models/SendRequest.Serialization.cs | 150 ++ .../union/src/Generated/Models/SendRequest.cs | 35 + .../Models/SendRequest1.Serialization.cs | 150 ++ .../src/Generated/Models/SendRequest1.cs | 35 + .../Models/SendRequest2.Serialization.cs | 150 ++ .../src/Generated/Models/SendRequest2.cs | 35 + .../Models/SendRequest3.Serialization.cs | 150 ++ .../src/Generated/Models/SendRequest3.cs | 35 + .../Models/SendRequest4.Serialization.cs | 150 ++ .../src/Generated/Models/SendRequest4.cs | 35 + .../Models/SendRequest5.Serialization.cs | 157 ++ .../src/Generated/Models/SendRequest5.cs | 74 + .../Models/SendRequest6.Serialization.cs | 150 ++ .../src/Generated/Models/SendRequest6.cs | 35 + .../Models/SendRequest7.Serialization.cs | 150 ++ .../src/Generated/Models/SendRequest7.cs | 35 + .../Models/SendRequest8.Serialization.cs | 150 ++ .../src/Generated/Models/SendRequest8.cs | 35 + .../Models/SendRequest9.Serialization.cs | 150 ++ .../src/Generated/Models/SendRequest9.cs | 35 + .../StringAndArrayCases.Serialization.cs | 148 +- .../Generated/Models/StringAndArrayCases.cs | 112 +- .../Models/StringExtensibleNamedUnion.cs | 51 +- .../src/Generated/Models/_TypeUnionContext.cs | 14 + .../src/Generated/ModelsOnly.RestClient.cs | 45 + .../type/union/src/Generated/ModelsOnly.cs | 140 +- .../Generated/StringAndArray.RestClient.cs | 45 + .../union/src/Generated/StringAndArray.cs | 140 +- .../Generated/StringExtensible.RestClient.cs | 45 + .../union/src/Generated/StringExtensible.cs | 134 +- .../StringExtensibleNamed.RestClient.cs | 45 + .../src/Generated/StringExtensibleNamed.cs | 134 +- .../src/Generated/StringsOnly.RestClient.cs | 45 + .../type/union/src/Generated/StringsOnly.cs | 134 +- .../src/Generated/TypeUnionModelFactory.cs | 177 +- .../src/Generated/UnionClient.RestClient.cs | 11 + .../type/union/src/Generated/UnionClient.cs | 145 +- .../union/src/Generated/UnionClientOptions.cs | 16 +- .../src/Generated/UnionClientSettings.cs | 28 +- 122 files changed, 9859 insertions(+), 3127 deletions(-) create mode 100644 docs/samples/client/csharp/SampleService/SampleClient/Generated/schema/ConfigurationSchema.json create mode 100644 docs/samples/client/csharp/SampleService/SampleClient/SampleTypeSpec.NuGet.targets create mode 100644 docs/samples/client/csharp/SampleService/SampleClient/src/Generated/MetricsSettings.cs create mode 100644 docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientSettings.cs create mode 100644 packages/http-client-csharp/README.md create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/Argument.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CancellationTokenExtensions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingList.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientPipelineExtensions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientUriBuilder.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenMemberAttribute.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSerializationAttribute.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSuppressAttribute.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenTypeAttribute.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ErrorResult.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ModelSerializationExtensions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/SerializationFormat.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/TypeFormatters.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.RestClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.RestClient.cs diff --git a/docs/samples/client/csharp/SampleService/SampleClient/Generated/schema/ConfigurationSchema.json b/docs/samples/client/csharp/SampleService/SampleClient/Generated/schema/ConfigurationSchema.json new file mode 100644 index 00000000000..a41ff644b36 --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/Generated/schema/ConfigurationSchema.json @@ -0,0 +1,60 @@ +{ + "type": "object", + "properties": { + "Clients": { + "type": "object", + "properties": { + "Metrics": { + "type": "object", + "description": "Configuration for Metrics.", + "properties": { + "SampleTypeSpecUrl": { + "type": "string", + "format": "uri", + "description": "Gets or sets the SampleTypeSpecUrl." + }, + "MetricsNamespace": { + "type": "string" + }, + "Credential": { + "$ref": "#/definitions/credential" + }, + "Options": { + "$ref": "#/definitions/sampleTypeSpecClientOptions" + } + } + }, + "SampleTypeSpecClient": { + "type": "object", + "description": "Configuration for SampleTypeSpecClient.", + "properties": { + "SampleTypeSpecUrl": { + "type": "string", + "format": "uri", + "description": "Gets or sets the SampleTypeSpecUrl." + }, + "Credential": { + "$ref": "#/definitions/credential" + }, + "Options": { + "$ref": "#/definitions/sampleTypeSpecClientOptions" + } + } + } + }, + "additionalProperties": { + "type": "object", + "description": "Configuration for a named client instance." + } + } + }, + "definitions": { + "sampleTypeSpecClientOptions": { + "allOf": [ + { + "$ref": "#/definitions/options" + } + ] + } + } +} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/SampleTypeSpec.NuGet.targets b/docs/samples/client/csharp/SampleService/SampleClient/SampleTypeSpec.NuGet.targets new file mode 100644 index 00000000000..9df53f09f6f --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/SampleTypeSpec.NuGet.targets @@ -0,0 +1,6 @@ + + + + + diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/AnimalOperations.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/AnimalOperations.cs index 8fa8739984f..8b2255811e9 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/AnimalOperations.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/AnimalOperations.cs @@ -47,23 +47,10 @@ internal AnimalOperations(ClientPipeline pipeline, Uri endpoint) /// The response returned from the service. public virtual ClientResult UpdatePetAsAnimal(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdatePetAsAnimal."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdatePetAsAnimalRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimal: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdatePetAsAnimal."); - } + using PipelineMessage message = CreateUpdatePetAsAnimalRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -81,23 +68,10 @@ public virtual ClientResult UpdatePetAsAnimal(BinaryContent content, RequestOpti /// The response returned from the service. public virtual async Task UpdatePetAsAnimalAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdatePetAsAnimalAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdatePetAsAnimalRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimalAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdatePetAsAnimalAsync."); - } + using PipelineMessage message = CreateUpdatePetAsAnimalRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Update a pet as an animal. @@ -107,23 +81,10 @@ public virtual async Task UpdatePetAsAnimalAsync(BinaryContent con /// Service returned a non-success status code. public virtual ClientResult UpdatePetAsAnimal(Animal animal, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdatePetAsAnimal."); - Argument.AssertNotNull(animal, nameof(animal)); + Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = UpdatePetAsAnimal(animal, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimal: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdatePetAsAnimal."); - } + ClientResult result = UpdatePetAsAnimal(animal, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); } /// Update a pet as an animal. @@ -133,23 +94,10 @@ public virtual ClientResult UpdatePetAsAnimal(Animal animal, Cancellatio /// Service returned a non-success status code. public virtual async Task> UpdatePetAsAnimalAsync(Animal animal, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdatePetAsAnimalAsync."); - Argument.AssertNotNull(animal, nameof(animal)); + Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = await UpdatePetAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimalAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdatePetAsAnimalAsync."); - } + ClientResult result = await UpdatePetAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); } /// @@ -167,23 +115,10 @@ public virtual async Task> UpdatePetAsAnimalAsync(Animal an /// The response returned from the service. public virtual ClientResult UpdateDogAsAnimal(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsAnimal."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsAnimalRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimal: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsAnimal."); - } + using PipelineMessage message = CreateUpdateDogAsAnimalRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -201,23 +136,10 @@ public virtual ClientResult UpdateDogAsAnimal(BinaryContent content, RequestOpti /// The response returned from the service. public virtual async Task UpdateDogAsAnimalAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsAnimalAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsAnimalRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimalAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsAnimalAsync."); - } + using PipelineMessage message = CreateUpdateDogAsAnimalRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Update a dog as an animal. @@ -227,23 +149,10 @@ public virtual async Task UpdateDogAsAnimalAsync(BinaryContent con /// Service returned a non-success status code. public virtual ClientResult UpdateDogAsAnimal(Animal animal, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsAnimal."); - Argument.AssertNotNull(animal, nameof(animal)); + Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = UpdateDogAsAnimal(animal, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimal: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsAnimal."); - } + ClientResult result = UpdateDogAsAnimal(animal, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); } /// Update a dog as an animal. @@ -253,23 +162,10 @@ public virtual ClientResult UpdateDogAsAnimal(Animal animal, Cancellatio /// Service returned a non-success status code. public virtual async Task> UpdateDogAsAnimalAsync(Animal animal, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsAnimalAsync."); - Argument.AssertNotNull(animal, nameof(animal)); + Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = await UpdateDogAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimalAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsAnimalAsync."); - } + ClientResult result = await UpdateDogAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/DogOperations.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/DogOperations.cs index c80c36367aa..a269c6b6c5b 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/DogOperations.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/DogOperations.cs @@ -47,23 +47,10 @@ internal DogOperations(ClientPipeline pipeline, Uri endpoint) /// The response returned from the service. public virtual ClientResult UpdateDogAsDog(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsDog."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDog: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsDog."); - } + using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -81,23 +68,10 @@ public virtual ClientResult UpdateDogAsDog(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task UpdateDogAsDogAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsDogAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDogAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsDogAsync."); - } + using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Update a dog as a dog. @@ -107,23 +81,10 @@ public virtual async Task UpdateDogAsDogAsync(BinaryContent conten /// Service returned a non-success status code. public virtual ClientResult UpdateDogAsDog(Dog dog, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsDog."); - Argument.AssertNotNull(dog, nameof(dog)); + Argument.AssertNotNull(dog, nameof(dog)); - ClientResult result = UpdateDogAsDog(dog, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Dog)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDog: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsDog."); - } + ClientResult result = UpdateDogAsDog(dog, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Dog)result, result.GetRawResponse()); } /// Update a dog as a dog. @@ -133,23 +94,10 @@ public virtual ClientResult UpdateDogAsDog(Dog dog, CancellationToken cance /// Service returned a non-success status code. public virtual async Task> UpdateDogAsDogAsync(Dog dog, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsDogAsync."); - Argument.AssertNotNull(dog, nameof(dog)); + Argument.AssertNotNull(dog, nameof(dog)); - ClientResult result = await UpdateDogAsDogAsync(dog, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Dog)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDogAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsDogAsync."); - } + ClientResult result = await UpdateDogAsDogAsync(dog, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Dog)result, result.GetRawResponse()); } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Metrics.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Metrics.cs index 65e1ea56883..18538f3d727 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Metrics.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Metrics.cs @@ -5,6 +5,8 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; @@ -14,6 +16,17 @@ namespace SampleTypeSpec public partial class Metrics { private readonly Uri _endpoint; + private const string AuthorizationHeader = "my-api-key"; + /// The OAuth2 flows supported by the service. + private static readonly Dictionary[] _flows = new Dictionary[] + { + new Dictionary + { + { GetTokenOptions.ScopesPropertyName, new string[] { "read" } }, + { GetTokenOptions.AuthorizationUrlPropertyName, "https://api.example.com/oauth2/authorize" }, + { GetTokenOptions.RefreshUrlPropertyName, "https://api.example.com/oauth2/refresh" } + } + }; private readonly string _metricsNamespace; /// Initializes a new instance of Metrics for mocking. @@ -35,19 +48,29 @@ internal Metrics(ClientPipeline pipeline, Uri endpoint, string metricsNamespace) /// Initializes a new instance of Metrics. /// Service endpoint. /// - /// or is null. + /// A credential used to authenticate to the service. + /// , or is null. /// is an empty string, and was expected to be non-empty. - public Metrics(Uri endpoint, string metricsNamespace) : this(endpoint, metricsNamespace, new SampleTypeSpecClientOptions()) + public Metrics(Uri endpoint, string metricsNamespace, ApiKeyCredential credential) : this(endpoint, metricsNamespace, credential, new SampleTypeSpecClientOptions()) { } /// Initializes a new instance of Metrics. /// Service endpoint. /// - /// The options for configuring the client. - /// or is null. + /// A credential provider used to authenticate to the service. + /// , or is null. /// is an empty string, and was expected to be non-empty. - public Metrics(Uri endpoint, string metricsNamespace, SampleTypeSpecClientOptions options) + public Metrics(Uri endpoint, string metricsNamespace, AuthenticationTokenProvider tokenProvider) : this(endpoint, metricsNamespace, tokenProvider, new SampleTypeSpecClientOptions()) + { + } + + /// Initializes a new instance of Metrics. + /// The authentication policy to use for pipeline creation. + /// Service endpoint. + /// + /// The options for configuring the client. + internal Metrics(AuthenticationPolicy authenticationPolicy, Uri endpoint, string metricsNamespace, SampleTypeSpecClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNullOrEmpty(metricsNamespace, nameof(metricsNamespace)); @@ -56,7 +79,43 @@ public Metrics(Uri endpoint, string metricsNamespace, SampleTypeSpecClientOption _endpoint = endpoint; _metricsNamespace = metricsNamespace; - Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(Metrics).Assembly) }, Array.Empty()); + if (authenticationPolicy != null) + { + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(Metrics).Assembly), authenticationPolicy }, Array.Empty()); + } + else + { + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(Metrics).Assembly) }, Array.Empty()); + } + } + + /// Initializes a new instance of Metrics. + /// Service endpoint. + /// + /// A credential used to authenticate to the service. + /// The options for configuring the client. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Metrics(Uri endpoint, string metricsNamespace, ApiKeyCredential credential, SampleTypeSpecClientOptions options) : this(ApiKeyAuthenticationPolicy.CreateHeaderApiKeyPolicy(credential, AuthorizationHeader), endpoint, metricsNamespace, options) + { + } + + /// Initializes a new instance of Metrics. + /// Service endpoint. + /// + /// A credential provider used to authenticate to the service. + /// The options for configuring the client. + /// , or is null. + /// is an empty string, and was expected to be non-empty. + public Metrics(Uri endpoint, string metricsNamespace, AuthenticationTokenProvider tokenProvider, SampleTypeSpecClientOptions options) : this(new BearerTokenPolicy(tokenProvider, _flows), endpoint, metricsNamespace, options) + { + } + + /// Initializes a new instance of Metrics from a . + /// The settings for Metrics. + [Experimental("SCME0002")] + public Metrics(MetricsSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.SampleTypeSpecUrl, settings?.MetricsNamespace, settings?.Options) + { } /// The HTTP pipeline for sending and receiving REST requests and responses. @@ -76,21 +135,8 @@ public Metrics(Uri endpoint, string metricsNamespace, SampleTypeSpecClientOption /// The response returned from the service. public virtual ClientResult GetWidgetMetrics(string day, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method GetWidgetMetrics."); - using PipelineMessage message = CreateGetWidgetMetricsRequest(day, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWidgetMetrics: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWidgetMetrics."); - } + using PipelineMessage message = CreateGetWidgetMetricsRequest(day, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -107,21 +153,8 @@ public virtual ClientResult GetWidgetMetrics(string day, RequestOptions options /// The response returned from the service. public virtual async Task GetWidgetMetricsAsync(string day, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method GetWidgetMetricsAsync."); - using PipelineMessage message = CreateGetWidgetMetricsRequest(day, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWidgetMetricsAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWidgetMetricsAsync."); - } + using PipelineMessage message = CreateGetWidgetMetricsRequest(day, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Get Widget metrics for given day of week. @@ -130,21 +163,8 @@ public virtual async Task GetWidgetMetricsAsync(string day, Reques /// Service returned a non-success status code. public virtual ClientResult GetWidgetMetrics(DaysOfWeekExtensibleEnum day, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWidgetMetrics."); - ClientResult result = GetWidgetMetrics(day.ToString(), cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWidgetMetrics: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWidgetMetrics."); - } + ClientResult result = GetWidgetMetrics(day.ToString(), cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); } /// Get Widget metrics for given day of week. @@ -153,21 +173,8 @@ public virtual ClientResult GetWidgetMetrics(DaysOfWee /// Service returned a non-success status code. public virtual async Task> GetWidgetMetricsAsync(DaysOfWeekExtensibleEnum day, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWidgetMetricsAsync."); - ClientResult result = await GetWidgetMetricsAsync(day.ToString(), cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWidgetMetricsAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWidgetMetricsAsync."); - } + ClientResult result = await GetWidgetMetricsAsync(day.ToString(), cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/MetricsSettings.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/MetricsSettings.cs new file mode 100644 index 00000000000..6302674bf01 --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/MetricsSettings.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Configuration; + +namespace SampleTypeSpec +{ + /// Represents the settings used to configure a that can be loaded from an . + [Experimental("SCME0002")] + public partial class MetricsSettings : ClientSettings + { + /// Gets or sets the SampleTypeSpecUrl. + public Uri SampleTypeSpecUrl { get; set; } + + /// Gets or sets the MetricsNamespace. + public string MetricsNamespace { get; set; } + + /// Gets or sets the Options. + public SampleTypeSpecClientOptions Options { get; set; } + + /// Binds configuration values from the given section. + /// The configuration section. + protected override void BindCore(IConfigurationSection section) + { + if (Uri.TryCreate(section["SampleTypeSpecUrl"], UriKind.Absolute, out Uri sampleTypeSpecUrl)) + { + SampleTypeSpecUrl = sampleTypeSpecUrl; + } + string metricsNamespace = section["MetricsNamespace"]; + if (!string.IsNullOrEmpty(metricsNamespace)) + { + MetricsNamespace = metricsNamespace; + } + IConfigurationSection optionsSection = section.GetSection("Options"); + if (optionsSection.Exists()) + { + Options = new SampleTypeSpecClientOptions(optionsSection); + } + } + } +} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PetOperations.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PetOperations.cs index 395ff6b18d9..8183d3fcd4e 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PetOperations.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PetOperations.cs @@ -47,23 +47,10 @@ internal PetOperations(ClientPipeline pipeline, Uri endpoint) /// The response returned from the service. public virtual ClientResult UpdatePetAsPet(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdatePetAsPet."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdatePetAsPetRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdatePetAsPet: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdatePetAsPet."); - } + using PipelineMessage message = CreateUpdatePetAsPetRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -81,23 +68,10 @@ public virtual ClientResult UpdatePetAsPet(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task UpdatePetAsPetAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdatePetAsPetAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdatePetAsPetRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdatePetAsPetAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdatePetAsPetAsync."); - } + using PipelineMessage message = CreateUpdatePetAsPetRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Update a pet as a pet. @@ -107,23 +81,10 @@ public virtual async Task UpdatePetAsPetAsync(BinaryContent conten /// Service returned a non-success status code. public virtual ClientResult UpdatePetAsPet(Pet pet, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdatePetAsPet."); - Argument.AssertNotNull(pet, nameof(pet)); + Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = UpdatePetAsPet(pet, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdatePetAsPet: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdatePetAsPet."); - } + ClientResult result = UpdatePetAsPet(pet, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); } /// Update a pet as a pet. @@ -133,23 +94,10 @@ public virtual ClientResult UpdatePetAsPet(Pet pet, CancellationToken cance /// Service returned a non-success status code. public virtual async Task> UpdatePetAsPetAsync(Pet pet, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdatePetAsPetAsync."); - Argument.AssertNotNull(pet, nameof(pet)); + Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = await UpdatePetAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdatePetAsPetAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdatePetAsPetAsync."); - } + ClientResult result = await UpdatePetAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); } /// @@ -167,23 +115,10 @@ public virtual async Task> UpdatePetAsPetAsync(Pet pet, Cancel /// The response returned from the service. public virtual ClientResult UpdateDogAsPet(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsPet."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsPetRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsPet: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsPet."); - } + using PipelineMessage message = CreateUpdateDogAsPetRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -201,23 +136,10 @@ public virtual ClientResult UpdateDogAsPet(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task UpdateDogAsPetAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsPetAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsPetRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsPetAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsPetAsync."); - } + using PipelineMessage message = CreateUpdateDogAsPetRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Update a dog as a pet. @@ -227,23 +149,10 @@ public virtual async Task UpdateDogAsPetAsync(BinaryContent conten /// Service returned a non-success status code. public virtual ClientResult UpdateDogAsPet(Pet pet, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsPet."); - Argument.AssertNotNull(pet, nameof(pet)); + Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = UpdateDogAsPet(pet, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsPet: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsPet."); - } + ClientResult result = UpdateDogAsPet(pet, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); } /// Update a dog as a pet. @@ -253,23 +162,10 @@ public virtual ClientResult UpdateDogAsPet(Pet pet, CancellationToken cance /// Service returned a non-success status code. public virtual async Task> UpdateDogAsPetAsync(Pet pet, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateDogAsPetAsync."); - Argument.AssertNotNull(pet, nameof(pet)); + Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = await UpdateDogAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateDogAsPetAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateDogAsPetAsync."); - } + ClientResult result = await UpdateDogAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PlantOperations.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PlantOperations.cs index dcfa7b2cb12..70a66822b03 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PlantOperations.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PlantOperations.cs @@ -45,21 +45,8 @@ internal PlantOperations(ClientPipeline pipeline, Uri endpoint) /// The response returned from the service. public virtual ClientResult GetTree(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetTree."); - using PipelineMessage message = CreateGetTreeRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetTree: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetTree."); - } + using PipelineMessage message = CreateGetTreeRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -75,21 +62,8 @@ public virtual ClientResult GetTree(RequestOptions options) /// The response returned from the service. public virtual async Task GetTreeAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetTreeAsync."); - using PipelineMessage message = CreateGetTreeRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetTreeAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetTreeAsync."); - } + using PipelineMessage message = CreateGetTreeRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Get a tree as a plant. @@ -97,21 +71,8 @@ public virtual async Task GetTreeAsync(RequestOptions options) /// Service returned a non-success status code. public virtual ClientResult GetTree(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetTree."); - ClientResult result = GetTree(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetTree: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetTree."); - } + ClientResult result = GetTree(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); } /// Get a tree as a plant. @@ -119,21 +80,8 @@ public virtual ClientResult GetTree(CancellationToken cancellationToken = /// Service returned a non-success status code. public virtual async Task> GetTreeAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetTreeAsync."); - ClientResult result = await GetTreeAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetTreeAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetTreeAsync."); - } + ClientResult result = await GetTreeAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); } /// @@ -149,21 +97,8 @@ public virtual async Task> GetTreeAsync(CancellationToken can /// The response returned from the service. public virtual ClientResult GetTreeAsJson(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetTreeAsJson."); - using PipelineMessage message = CreateGetTreeAsJsonRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetTreeAsJson: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetTreeAsJson."); - } + using PipelineMessage message = CreateGetTreeAsJsonRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -179,21 +114,8 @@ public virtual ClientResult GetTreeAsJson(RequestOptions options) /// The response returned from the service. public virtual async Task GetTreeAsJsonAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetTreeAsJsonAsync."); - using PipelineMessage message = CreateGetTreeAsJsonRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetTreeAsJsonAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetTreeAsJsonAsync."); - } + using PipelineMessage message = CreateGetTreeAsJsonRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Get a tree as a plant. @@ -201,21 +123,8 @@ public virtual async Task GetTreeAsJsonAsync(RequestOptions option /// Service returned a non-success status code. public virtual ClientResult GetTreeAsJson(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetTreeAsJson."); - ClientResult result = GetTreeAsJson(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetTreeAsJson: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetTreeAsJson."); - } + ClientResult result = GetTreeAsJson(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); } /// Get a tree as a plant. @@ -223,21 +132,8 @@ public virtual ClientResult GetTreeAsJson(CancellationToken cancellationTo /// Service returned a non-success status code. public virtual async Task> GetTreeAsJsonAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetTreeAsJsonAsync."); - ClientResult result = await GetTreeAsJsonAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetTreeAsJsonAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetTreeAsJsonAsync."); - } + ClientResult result = await GetTreeAsJsonAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); } /// @@ -255,23 +151,10 @@ public virtual async Task> GetTreeAsJsonAsync(CancellationTok /// The response returned from the service. public virtual ClientResult UpdateTree(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateTree."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateTreeRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateTree: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateTree."); - } + using PipelineMessage message = CreateUpdateTreeRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -289,23 +172,10 @@ public virtual ClientResult UpdateTree(BinaryContent content, RequestOptions opt /// The response returned from the service. public virtual async Task UpdateTreeAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateTreeAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateTreeRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateTreeAsync."); - } + using PipelineMessage message = CreateUpdateTreeRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Update a tree as a plant. @@ -315,24 +185,11 @@ public virtual async Task UpdateTreeAsync(BinaryContent content, R /// Service returned a non-success status code. public virtual ClientResult UpdateTree(Tree tree, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateTree."); - Argument.AssertNotNull(tree, nameof(tree)); + Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("X"); - ClientResult result = UpdateTree(content, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateTree: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateTree."); - } + using BinaryContent content = tree.ToBinaryContent("X"); + ClientResult result = UpdateTree(content, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); } /// Update a tree as a plant. @@ -342,24 +199,11 @@ public virtual ClientResult UpdateTree(Tree tree, CancellationToken cancel /// Service returned a non-success status code. public virtual async Task> UpdateTreeAsync(Tree tree, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateTreeAsync."); - Argument.AssertNotNull(tree, nameof(tree)); + Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("X"); - ClientResult result = await UpdateTreeAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateTreeAsync."); - } + using BinaryContent content = tree.ToBinaryContent("X"); + ClientResult result = await UpdateTreeAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); } /// @@ -377,23 +221,10 @@ public virtual async Task> UpdateTreeAsync(Tree tree, Cancell /// The response returned from the service. public virtual ClientResult UpdateTreeAsJson(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateTreeAsJson."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateTreeAsJsonRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsJson: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateTreeAsJson."); - } + using PipelineMessage message = CreateUpdateTreeAsJsonRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -411,23 +242,10 @@ public virtual ClientResult UpdateTreeAsJson(BinaryContent content, RequestOptio /// The response returned from the service. public virtual async Task UpdateTreeAsJsonAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateTreeAsJsonAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateTreeAsJsonRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsJsonAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateTreeAsJsonAsync."); - } + using PipelineMessage message = CreateUpdateTreeAsJsonRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Update a tree as a plant. @@ -437,24 +255,11 @@ public virtual async Task UpdateTreeAsJsonAsync(BinaryContent cont /// Service returned a non-success status code. public virtual ClientResult UpdateTreeAsJson(Tree tree, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateTreeAsJson."); - Argument.AssertNotNull(tree, nameof(tree)); + Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("J"); - ClientResult result = UpdateTreeAsJson(content, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsJson: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateTreeAsJson."); - } + using BinaryContent content = tree.ToBinaryContent("J"); + ClientResult result = UpdateTreeAsJson(content, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); } /// Update a tree as a plant. @@ -464,24 +269,11 @@ public virtual ClientResult UpdateTreeAsJson(Tree tree, CancellationToken /// Service returned a non-success status code. public virtual async Task> UpdateTreeAsJsonAsync(Tree tree, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateTreeAsJsonAsync."); - Argument.AssertNotNull(tree, nameof(tree)); + Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("J"); - ClientResult result = await UpdateTreeAsJsonAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsJsonAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateTreeAsJsonAsync."); - } + using BinaryContent content = tree.ToBinaryContent("J"); + ClientResult result = await UpdateTreeAsJsonAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs index 7388bc4fc20..0f038c721bc 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs @@ -216,14 +216,14 @@ internal PipelineMessage CreateReturnsAnonymousModelRequest(RequestOptions optio return message; } - internal PipelineMessage CreateGetUnknownValueRequest(string accept, RequestOptions options) + internal PipelineMessage CreateGetUnknownValueRequest(RequestOptions options) { ClientUriBuilder uri = new ClientUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/unknown-value", false); PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); PipelineRequest request = message.Request; - request.Headers.Set("Accept", accept); + request.Headers.Set("Accept", "text/plain"); message.Apply(options); return message; } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs index fdf22f78834..d5b160ecf7e 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs @@ -6,6 +6,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -16,13 +17,9 @@ namespace SampleTypeSpec public partial class SampleTypeSpecClient { private readonly Uri _endpoint; - /// A credential used to authenticate to the service. - private readonly ApiKeyCredential _keyCredential; private const string AuthorizationHeader = "my-api-key"; - /// A credential provider used to authenticate to the service. - private readonly AuthenticationTokenProvider _tokenProvider; /// The OAuth2 flows supported by the service. - private readonly Dictionary[] _flows = new Dictionary[] + private static readonly Dictionary[] _flows = new Dictionary[] { new Dictionary { @@ -59,39 +56,50 @@ protected SampleTypeSpecClient() } /// Initializes a new instance of SampleTypeSpecClient. + /// The authentication policy to use for pipeline creation. /// Service endpoint. - /// A credential used to authenticate to the service. /// The options for configuring the client. - /// or is null. - public SampleTypeSpecClient(Uri endpoint, ApiKeyCredential credential, SampleTypeSpecClientOptions options) + internal SampleTypeSpecClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, SampleTypeSpecClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); - Argument.AssertNotNull(credential, nameof(credential)); options ??= new SampleTypeSpecClientOptions(); _endpoint = endpoint; - _keyCredential = credential; - Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(SampleTypeSpecClient).Assembly), ApiKeyAuthenticationPolicy.CreateHeaderApiKeyPolicy(_keyCredential, AuthorizationHeader) }, Array.Empty()); + if (authenticationPolicy != null) + { + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(SampleTypeSpecClient).Assembly), authenticationPolicy }, Array.Empty()); + } + else + { + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(SampleTypeSpecClient).Assembly) }, Array.Empty()); + } _apiVersion = options.Version; } + /// Initializes a new instance of SampleTypeSpecClient. + /// Service endpoint. + /// A credential used to authenticate to the service. + /// The options for configuring the client. + /// or is null. + public SampleTypeSpecClient(Uri endpoint, ApiKeyCredential credential, SampleTypeSpecClientOptions options) : this(ApiKeyAuthenticationPolicy.CreateHeaderApiKeyPolicy(credential, AuthorizationHeader), endpoint, options) + { + } + /// Initializes a new instance of SampleTypeSpecClient. /// Service endpoint. /// A credential provider used to authenticate to the service. /// The options for configuring the client. /// or is null. - public SampleTypeSpecClient(Uri endpoint, AuthenticationTokenProvider tokenProvider, SampleTypeSpecClientOptions options) + public SampleTypeSpecClient(Uri endpoint, AuthenticationTokenProvider tokenProvider, SampleTypeSpecClientOptions options) : this(new BearerTokenPolicy(tokenProvider, _flows), endpoint, options) { - Argument.AssertNotNull(endpoint, nameof(endpoint)); - Argument.AssertNotNull(tokenProvider, nameof(tokenProvider)); - - options ??= new SampleTypeSpecClientOptions(); + } - _endpoint = endpoint; - _tokenProvider = tokenProvider; - Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(SampleTypeSpecClient).Assembly), new BearerTokenPolicy(_tokenProvider, _flows) }, Array.Empty()); - _apiVersion = options.Version; + /// Initializes a new instance of SampleTypeSpecClient from a . + /// The settings for SampleTypeSpecClient. + [Experimental("SCME0002")] + public SampleTypeSpecClient(SampleTypeSpecClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.SampleTypeSpecUrl, settings?.Options) + { } /// The HTTP pipeline for sending and receiving REST requests and responses. @@ -115,24 +123,11 @@ public SampleTypeSpecClient(Uri endpoint, AuthenticationTokenProvider tokenProvi /// The response returned from the service. public virtual ClientResult SayHi(string headParameter, string queryParameter, string optionalQuery, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method SayHi."); - Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); - Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); + Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); + Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - using PipelineMessage message = CreateSayHiRequest(headParameter, queryParameter, optionalQuery, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method SayHi: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method SayHi."); - } + using PipelineMessage message = CreateSayHiRequest(headParameter, queryParameter, optionalQuery, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -153,24 +148,11 @@ public virtual ClientResult SayHi(string headParameter, string queryParameter, s /// The response returned from the service. public virtual async Task SayHiAsync(string headParameter, string queryParameter, string optionalQuery, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method SayHiAsync."); - Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); - Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); + Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); + Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - using PipelineMessage message = CreateSayHiRequest(headParameter, queryParameter, optionalQuery, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method SayHiAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method SayHiAsync."); - } + using PipelineMessage message = CreateSayHiRequest(headParameter, queryParameter, optionalQuery, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Return hi. @@ -183,24 +165,11 @@ public virtual async Task SayHiAsync(string headParameter, string /// Service returned a non-success status code. public virtual ClientResult SayHi(string headParameter, string queryParameter, string optionalQuery = default, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method SayHi."); - Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); - Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); + Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); + Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - ClientResult result = SayHi(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method SayHi: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method SayHi."); - } + ClientResult result = SayHi(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// Return hi. @@ -213,24 +182,11 @@ public virtual ClientResult SayHi(string headParameter, string queryParam /// Service returned a non-success status code. public virtual async Task> SayHiAsync(string headParameter, string queryParameter, string optionalQuery = default, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method SayHiAsync."); - Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); - Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); + Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); + Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - ClientResult result = await SayHiAsync(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method SayHiAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method SayHiAsync."); - } + ClientResult result = await SayHiAsync(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// @@ -251,25 +207,12 @@ public virtual async Task> SayHiAsync(string headParameter, /// The response returned from the service. public virtual ClientResult HelloAgain(string p2, string p1, BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method HelloAgain."); - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateHelloAgainRequest(p2, p1, content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloAgain: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloAgain."); - } + using PipelineMessage message = CreateHelloAgainRequest(p2, p1, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -290,25 +233,12 @@ public virtual ClientResult HelloAgain(string p2, string p1, BinaryContent conte /// The response returned from the service. public virtual async Task HelloAgainAsync(string p2, string p1, BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method HelloAgainAsync."); - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateHelloAgainRequest(p2, p1, content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloAgainAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloAgainAsync."); - } + using PipelineMessage message = CreateHelloAgainRequest(p2, p1, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Return hi again. @@ -321,25 +251,12 @@ public virtual async Task HelloAgainAsync(string p2, string p1, Bi /// Service returned a non-success status code. public virtual ClientResult HelloAgain(string p2, string p1, RoundTripModel action, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method HelloAgain."); - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(action, nameof(action)); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(action, nameof(action)); - ClientResult result = HelloAgain(p2, p1, action, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloAgain: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloAgain."); - } + ClientResult result = HelloAgain(p2, p1, action, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); } /// Return hi again. @@ -352,25 +269,12 @@ public virtual ClientResult HelloAgain(string p2, string p1, Rou /// Service returned a non-success status code. public virtual async Task> HelloAgainAsync(string p2, string p1, RoundTripModel action, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method HelloAgainAsync."); - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(action, nameof(action)); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(action, nameof(action)); - ClientResult result = await HelloAgainAsync(p2, p1, action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloAgainAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloAgainAsync."); - } + ClientResult result = await HelloAgainAsync(p2, p1, action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); } /// @@ -391,25 +295,12 @@ public virtual async Task> HelloAgainAsync(string p /// The response returned from the service. public virtual ClientResult NoContentType(string p2, string p1, BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method NoContentType."); - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateNoContentTypeRequest(p2, p1, content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method NoContentType: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method NoContentType."); - } + using PipelineMessage message = CreateNoContentTypeRequest(p2, p1, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -430,25 +321,12 @@ public virtual ClientResult NoContentType(string p2, string p1, BinaryContent co /// The response returned from the service. public virtual async Task NoContentTypeAsync(string p2, string p1, BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method NoContentTypeAsync."); - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateNoContentTypeRequest(p2, p1, content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method NoContentTypeAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method NoContentTypeAsync."); - } + using PipelineMessage message = CreateNoContentTypeRequest(p2, p1, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Return hi again. @@ -458,23 +336,10 @@ public virtual async Task NoContentTypeAsync(string p2, string p1, /// Service returned a non-success status code. public virtual ClientResult NoContentType(Wrapper info, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method NoContentType."); - Argument.AssertNotNull(info, nameof(info)); + Argument.AssertNotNull(info, nameof(info)); - ClientResult result = NoContentType(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method NoContentType: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method NoContentType."); - } + ClientResult result = NoContentType(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); } /// Return hi again. @@ -484,23 +349,10 @@ public virtual ClientResult NoContentType(Wrapper info, Cancella /// Service returned a non-success status code. public virtual async Task> NoContentTypeAsync(Wrapper info, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method NoContentTypeAsync."); - Argument.AssertNotNull(info, nameof(info)); + Argument.AssertNotNull(info, nameof(info)); - ClientResult result = await NoContentTypeAsync(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method NoContentTypeAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method NoContentTypeAsync."); - } + ClientResult result = await NoContentTypeAsync(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); } /// @@ -516,21 +368,8 @@ public virtual async Task> NoContentTypeAsync(Wrapp /// The response returned from the service. public virtual ClientResult HelloDemo2(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method HelloDemo2."); - using PipelineMessage message = CreateHelloDemo2Request(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloDemo2: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloDemo2."); - } + using PipelineMessage message = CreateHelloDemo2Request(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -546,21 +385,8 @@ public virtual ClientResult HelloDemo2(RequestOptions options) /// The response returned from the service. public virtual async Task HelloDemo2Async(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method HelloDemo2Async."); - using PipelineMessage message = CreateHelloDemo2Request(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloDemo2Async: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloDemo2Async."); - } + using PipelineMessage message = CreateHelloDemo2Request(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Return hi in demo2. @@ -568,21 +394,8 @@ public virtual async Task HelloDemo2Async(RequestOptions options) /// Service returned a non-success status code. public virtual ClientResult HelloDemo2(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method HelloDemo2."); - ClientResult result = HelloDemo2(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloDemo2: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloDemo2."); - } + ClientResult result = HelloDemo2(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// Return hi in demo2. @@ -590,21 +403,8 @@ public virtual ClientResult HelloDemo2(CancellationToken cancellationToke /// Service returned a non-success status code. public virtual async Task> HelloDemo2Async(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method HelloDemo2Async."); - ClientResult result = await HelloDemo2Async(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloDemo2Async: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloDemo2Async."); - } + ClientResult result = await HelloDemo2Async(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// @@ -622,23 +422,10 @@ public virtual async Task> HelloDemo2Async(CancellationToken /// The response returned from the service. public virtual ClientResult CreateLiteral(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method CreateLiteral."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateCreateLiteralRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method CreateLiteral: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method CreateLiteral."); - } + using PipelineMessage message = CreateCreateLiteralRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -656,23 +443,10 @@ public virtual ClientResult CreateLiteral(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task CreateLiteralAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method CreateLiteralAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateCreateLiteralRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method CreateLiteralAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method CreateLiteralAsync."); - } + using PipelineMessage message = CreateCreateLiteralRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Create with literal value. @@ -682,23 +456,10 @@ public virtual async Task CreateLiteralAsync(BinaryContent content /// Service returned a non-success status code. public virtual ClientResult CreateLiteral(Thing body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method CreateLiteral."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = CreateLiteral(body, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method CreateLiteral: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method CreateLiteral."); - } + ClientResult result = CreateLiteral(body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// Create with literal value. @@ -708,23 +469,10 @@ public virtual ClientResult CreateLiteral(Thing body, CancellationToken c /// Service returned a non-success status code. public virtual async Task> CreateLiteralAsync(Thing body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method CreateLiteralAsync."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = await CreateLiteralAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method CreateLiteralAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method CreateLiteralAsync."); - } + ClientResult result = await CreateLiteralAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// @@ -740,21 +488,8 @@ public virtual async Task> CreateLiteralAsync(Thing body, Ca /// The response returned from the service. public virtual ClientResult HelloLiteral(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method HelloLiteral."); - using PipelineMessage message = CreateHelloLiteralRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloLiteral: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloLiteral."); - } + using PipelineMessage message = CreateHelloLiteralRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -770,21 +505,8 @@ public virtual ClientResult HelloLiteral(RequestOptions options) /// The response returned from the service. public virtual async Task HelloLiteralAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method HelloLiteralAsync."); - using PipelineMessage message = CreateHelloLiteralRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloLiteralAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloLiteralAsync."); - } + using PipelineMessage message = CreateHelloLiteralRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Send literal parameters. @@ -792,21 +514,8 @@ public virtual async Task HelloLiteralAsync(RequestOptions options /// Service returned a non-success status code. public virtual ClientResult HelloLiteral(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method HelloLiteral."); - ClientResult result = HelloLiteral(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloLiteral: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloLiteral."); - } + ClientResult result = HelloLiteral(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// Send literal parameters. @@ -814,21 +523,8 @@ public virtual ClientResult HelloLiteral(CancellationToken cancellationTo /// Service returned a non-success status code. public virtual async Task> HelloLiteralAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method HelloLiteralAsync."); - ClientResult result = await HelloLiteralAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HelloLiteralAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HelloLiteralAsync."); - } + ClientResult result = await HelloLiteralAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// @@ -845,21 +541,8 @@ public virtual async Task> HelloLiteralAsync(CancellationTok /// The response returned from the service. public virtual ClientResult TopAction(DateTimeOffset action, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method TopAction."); - using PipelineMessage message = CreateTopActionRequest(action, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method TopAction: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method TopAction."); - } + using PipelineMessage message = CreateTopActionRequest(action, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -876,21 +559,8 @@ public virtual ClientResult TopAction(DateTimeOffset action, RequestOptions opti /// The response returned from the service. public virtual async Task TopActionAsync(DateTimeOffset action, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method TopActionAsync."); - using PipelineMessage message = CreateTopActionRequest(action, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method TopActionAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method TopActionAsync."); - } + using PipelineMessage message = CreateTopActionRequest(action, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// top level method. @@ -899,21 +569,8 @@ public virtual async Task TopActionAsync(DateTimeOffset action, Re /// Service returned a non-success status code. public virtual ClientResult TopAction(DateTimeOffset action, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method TopAction."); - ClientResult result = TopAction(action, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method TopAction: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method TopAction."); - } + ClientResult result = TopAction(action, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// top level method. @@ -922,21 +579,8 @@ public virtual ClientResult TopAction(DateTimeOffset action, Cancellation /// Service returned a non-success status code. public virtual async Task> TopActionAsync(DateTimeOffset action, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method TopActionAsync."); - ClientResult result = await TopActionAsync(action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method TopActionAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method TopActionAsync."); - } + ClientResult result = await TopActionAsync(action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// @@ -952,21 +596,8 @@ public virtual async Task> TopActionAsync(DateTimeOffset act /// The response returned from the service. public virtual ClientResult TopAction2(RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method TopAction2."); - using PipelineMessage message = CreateTopAction2Request(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method TopAction2: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method TopAction2."); - } + using PipelineMessage message = CreateTopAction2Request(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -982,21 +613,8 @@ public virtual ClientResult TopAction2(RequestOptions options = null) /// The response returned from the service. public virtual async Task TopAction2Async(RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method TopAction2Async."); - using PipelineMessage message = CreateTopAction2Request(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method TopAction2Async: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method TopAction2Async."); - } + using PipelineMessage message = CreateTopAction2Request(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// @@ -1014,23 +632,10 @@ public virtual async Task TopAction2Async(RequestOptions options = /// The response returned from the service. public virtual ClientResult PatchAction(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method PatchAction."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreatePatchActionRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method PatchAction: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method PatchAction."); - } + using PipelineMessage message = CreatePatchActionRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -1048,23 +653,10 @@ public virtual ClientResult PatchAction(BinaryContent content, RequestOptions op /// The response returned from the service. public virtual async Task PatchActionAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method PatchActionAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreatePatchActionRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method PatchActionAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method PatchActionAsync."); - } + using PipelineMessage message = CreatePatchActionRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// @@ -1082,23 +674,10 @@ public virtual async Task PatchActionAsync(BinaryContent content, /// The response returned from the service. public virtual ClientResult AnonymousBody(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method AnonymousBody."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateAnonymousBodyRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method AnonymousBody: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method AnonymousBody."); - } + using PipelineMessage message = CreateAnonymousBodyRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -1116,23 +695,10 @@ public virtual ClientResult AnonymousBody(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task AnonymousBodyAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method AnonymousBodyAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateAnonymousBodyRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method AnonymousBodyAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method AnonymousBodyAsync."); - } + using PipelineMessage message = CreateAnonymousBodyRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// body parameter without body decorator. @@ -1158,45 +724,32 @@ public virtual async Task AnonymousBodyAsync(BinaryContent content /// Service returned a non-success status code. public virtual ClientResult AnonymousBody(string name, BinaryData requiredUnion, string requiredNullableString, ThingRequiredNullableLiteralString1? requiredNullableLiteralString, string requiredBadDescription, IEnumerable requiredNullableList, string propertyWithSpecialDocs, string optionalNullableString = default, ThingOptionalLiteralString? optionalLiteralString = default, ThingOptionalLiteralInt? optionalLiteralInt = default, ThingOptionalLiteralFloat? optionalLiteralFloat = default, bool? optionalLiteralBool = default, IEnumerable optionalNullableList = default, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method AnonymousBody."); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(requiredUnion, nameof(requiredUnion)); - Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); - Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); - - Thing spreadModel = new Thing( - name, - requiredUnion, - "accept", - requiredNullableString, - optionalNullableString, - 123, - 1.23F, - false, - optionalLiteralString, - requiredNullableLiteralString, - optionalLiteralInt, - optionalLiteralFloat, - optionalLiteralBool, - requiredBadDescription, - optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), - requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), - propertyWithSpecialDocs, - default); - ClientResult result = AnonymousBody(spreadModel, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method AnonymousBody: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method AnonymousBody."); - } + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(requiredUnion, nameof(requiredUnion)); + Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); + Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); + + Thing spreadModel = new Thing( + name, + requiredUnion, + "accept", + requiredNullableString, + optionalNullableString, + 123, + 1.23F, + false, + optionalLiteralString, + requiredNullableLiteralString, + optionalLiteralInt, + optionalLiteralFloat, + optionalLiteralBool, + requiredBadDescription, + optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), + requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), + propertyWithSpecialDocs, + default); + ClientResult result = AnonymousBody(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// body parameter without body decorator. @@ -1222,45 +775,32 @@ public virtual ClientResult AnonymousBody(string name, BinaryData require /// Service returned a non-success status code. public virtual async Task> AnonymousBodyAsync(string name, BinaryData requiredUnion, string requiredNullableString, ThingRequiredNullableLiteralString1? requiredNullableLiteralString, string requiredBadDescription, IEnumerable requiredNullableList, string propertyWithSpecialDocs, string optionalNullableString = default, ThingOptionalLiteralString? optionalLiteralString = default, ThingOptionalLiteralInt? optionalLiteralInt = default, ThingOptionalLiteralFloat? optionalLiteralFloat = default, bool? optionalLiteralBool = default, IEnumerable optionalNullableList = default, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method AnonymousBodyAsync."); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(requiredUnion, nameof(requiredUnion)); - Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); - Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); - - Thing spreadModel = new Thing( - name, - requiredUnion, - "accept", - requiredNullableString, - optionalNullableString, - 123, - 1.23F, - false, - optionalLiteralString, - requiredNullableLiteralString, - optionalLiteralInt, - optionalLiteralFloat, - optionalLiteralBool, - requiredBadDescription, - optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), - requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), - propertyWithSpecialDocs, - default); - ClientResult result = await AnonymousBodyAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method AnonymousBodyAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method AnonymousBodyAsync."); - } + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(requiredUnion, nameof(requiredUnion)); + Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); + Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); + + Thing spreadModel = new Thing( + name, + requiredUnion, + "accept", + requiredNullableString, + optionalNullableString, + 123, + 1.23F, + false, + optionalLiteralString, + requiredNullableLiteralString, + optionalLiteralInt, + optionalLiteralFloat, + optionalLiteralBool, + requiredBadDescription, + optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), + requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), + propertyWithSpecialDocs, + default); + ClientResult result = await AnonymousBodyAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// @@ -1278,23 +818,10 @@ public virtual async Task> AnonymousBodyAsync(string name, B /// The response returned from the service. public virtual ClientResult FriendlyModel(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method FriendlyModel."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateFriendlyModelRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method FriendlyModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method FriendlyModel."); - } + using PipelineMessage message = CreateFriendlyModelRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -1312,23 +839,10 @@ public virtual ClientResult FriendlyModel(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task FriendlyModelAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method FriendlyModelAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateFriendlyModelRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method FriendlyModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method FriendlyModelAsync."); - } + using PipelineMessage message = CreateFriendlyModelRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Model can have its friendly name. @@ -1339,24 +853,11 @@ public virtual async Task FriendlyModelAsync(BinaryContent content /// Service returned a non-success status code. public virtual ClientResult FriendlyModel(string name, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method FriendlyModel."); - Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); - Friend spreadModel = new Friend(name, default); - ClientResult result = FriendlyModel(spreadModel, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Friend)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method FriendlyModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method FriendlyModel."); - } + Friend spreadModel = new Friend(name, default); + ClientResult result = FriendlyModel(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Friend)result, result.GetRawResponse()); } /// Model can have its friendly name. @@ -1367,24 +868,11 @@ public virtual ClientResult FriendlyModel(string name, CancellationToken /// Service returned a non-success status code. public virtual async Task> FriendlyModelAsync(string name, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method FriendlyModelAsync."); - Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); - Friend spreadModel = new Friend(name, default); - ClientResult result = await FriendlyModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Friend)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method FriendlyModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method FriendlyModelAsync."); - } + Friend spreadModel = new Friend(name, default); + ClientResult result = await FriendlyModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Friend)result, result.GetRawResponse()); } /// @@ -1400,21 +888,8 @@ public virtual async Task> FriendlyModelAsync(string name, /// The response returned from the service. public virtual ClientResult AddTimeHeader(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method AddTimeHeader."); - using PipelineMessage message = CreateAddTimeHeaderRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method AddTimeHeader: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method AddTimeHeader."); - } + using PipelineMessage message = CreateAddTimeHeaderRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -1430,21 +905,8 @@ public virtual ClientResult AddTimeHeader(RequestOptions options) /// The response returned from the service. public virtual async Task AddTimeHeaderAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method AddTimeHeaderAsync."); - using PipelineMessage message = CreateAddTimeHeaderRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method AddTimeHeaderAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method AddTimeHeaderAsync."); - } + using PipelineMessage message = CreateAddTimeHeaderRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// AddTimeHeader. @@ -1452,20 +914,7 @@ public virtual async Task AddTimeHeaderAsync(RequestOptions option /// Service returned a non-success status code. public virtual ClientResult AddTimeHeader(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method AddTimeHeader."); - return AddTimeHeader(cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method AddTimeHeader: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method AddTimeHeader."); - } + return AddTimeHeader(cancellationToken.ToRequestOptions()); } /// AddTimeHeader. @@ -1473,20 +922,7 @@ public virtual ClientResult AddTimeHeader(CancellationToken cancellationToken = /// Service returned a non-success status code. public virtual async Task AddTimeHeaderAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method AddTimeHeaderAsync."); - return await AddTimeHeaderAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method AddTimeHeaderAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method AddTimeHeaderAsync."); - } + return await AddTimeHeaderAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); } /// @@ -1504,23 +940,10 @@ public virtual async Task AddTimeHeaderAsync(CancellationToken can /// The response returned from the service. public virtual ClientResult ProjectedNameModel(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method ProjectedNameModel."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateProjectedNameModelRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method ProjectedNameModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method ProjectedNameModel."); - } + using PipelineMessage message = CreateProjectedNameModelRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -1538,23 +961,10 @@ public virtual ClientResult ProjectedNameModel(BinaryContent content, RequestOpt /// The response returned from the service. public virtual async Task ProjectedNameModelAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method ProjectedNameModelAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateProjectedNameModelRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method ProjectedNameModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method ProjectedNameModelAsync."); - } + using PipelineMessage message = CreateProjectedNameModelRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Model can have its projected name. @@ -1565,24 +975,11 @@ public virtual async Task ProjectedNameModelAsync(BinaryContent co /// Service returned a non-success status code. public virtual ClientResult ProjectedNameModel(string otherName, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method ProjectedNameModel."); - Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); + Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); - RenamedModel spreadModel = new RenamedModel(otherName, default); - ClientResult result = ProjectedNameModel(spreadModel, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((RenamedModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method ProjectedNameModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method ProjectedNameModel."); - } + RenamedModel spreadModel = new RenamedModel(otherName, default); + ClientResult result = ProjectedNameModel(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RenamedModel)result, result.GetRawResponse()); } /// Model can have its projected name. @@ -1593,24 +990,11 @@ public virtual ClientResult ProjectedNameModel(string otherName, C /// Service returned a non-success status code. public virtual async Task> ProjectedNameModelAsync(string otherName, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method ProjectedNameModelAsync."); - Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); + Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); - RenamedModel spreadModel = new RenamedModel(otherName, default); - ClientResult result = await ProjectedNameModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((RenamedModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method ProjectedNameModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method ProjectedNameModelAsync."); - } + RenamedModel spreadModel = new RenamedModel(otherName, default); + ClientResult result = await ProjectedNameModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RenamedModel)result, result.GetRawResponse()); } /// @@ -1626,21 +1010,8 @@ public virtual async Task> ProjectedNameModelAsync(st /// The response returned from the service. public virtual ClientResult ReturnsAnonymousModel(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method ReturnsAnonymousModel."); - using PipelineMessage message = CreateReturnsAnonymousModelRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method ReturnsAnonymousModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method ReturnsAnonymousModel."); - } + using PipelineMessage message = CreateReturnsAnonymousModelRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -1656,21 +1027,8 @@ public virtual ClientResult ReturnsAnonymousModel(RequestOptions options) /// The response returned from the service. public virtual async Task ReturnsAnonymousModelAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method ReturnsAnonymousModelAsync."); - using PipelineMessage message = CreateReturnsAnonymousModelRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method ReturnsAnonymousModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method ReturnsAnonymousModelAsync."); - } + using PipelineMessage message = CreateReturnsAnonymousModelRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// return anonymous model. @@ -1678,21 +1036,8 @@ public virtual async Task ReturnsAnonymousModelAsync(RequestOption /// Service returned a non-success status code. public virtual ClientResult ReturnsAnonymousModel(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method ReturnsAnonymousModel."); - ClientResult result = ReturnsAnonymousModel(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method ReturnsAnonymousModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method ReturnsAnonymousModel."); - } + ClientResult result = ReturnsAnonymousModel(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); } /// return anonymous model. @@ -1700,21 +1045,8 @@ public virtual ClientResult ReturnsAnonymousModel /// Service returned a non-success status code. public virtual async Task> ReturnsAnonymousModelAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method ReturnsAnonymousModelAsync."); - ClientResult result = await ReturnsAnonymousModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method ReturnsAnonymousModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method ReturnsAnonymousModelAsync."); - } + ClientResult result = await ReturnsAnonymousModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); } /// @@ -1725,31 +1057,13 @@ public virtual async Task> ReturnsAn /// /// /// - /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - public virtual ClientResult GetUnknownValue(string accept, RequestOptions options) + public virtual ClientResult GetUnknownValue(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetUnknownValue."); - Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - - using PipelineMessage message = CreateGetUnknownValueRequest(accept, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetUnknownValue: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetUnknownValue."); - } + using PipelineMessage message = CreateGetUnknownValueRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -1760,85 +1074,31 @@ public virtual ClientResult GetUnknownValue(string accept, RequestOptions option /// /// /// - /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task GetUnknownValueAsync(string accept, RequestOptions options) + public virtual async Task GetUnknownValueAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetUnknownValueAsync."); - Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - - using PipelineMessage message = CreateGetUnknownValueRequest(accept, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetUnknownValueAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetUnknownValueAsync."); - } + using PipelineMessage message = CreateGetUnknownValueRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// get extensible enum. - /// /// The cancellation token that can be used to cancel the operation. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - public virtual ClientResult GetUnknownValue(string accept, CancellationToken cancellationToken = default) + public virtual ClientResult GetUnknownValue(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetUnknownValue."); - Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - - ClientResult result = GetUnknownValue(accept, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetUnknownValue: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetUnknownValue."); - } + ClientResult result = GetUnknownValue(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); } /// get extensible enum. - /// /// The cancellation token that can be used to cancel the operation. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - public virtual async Task> GetUnknownValueAsync(string accept, CancellationToken cancellationToken = default) + public virtual async Task> GetUnknownValueAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetUnknownValueAsync."); - Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - - ClientResult result = await GetUnknownValueAsync(accept, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetUnknownValueAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetUnknownValueAsync."); - } + ClientResult result = await GetUnknownValueAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); } /// @@ -1856,23 +1116,10 @@ public virtual async Task> GetUnknownValueAsync(string acce /// The response returned from the service. public virtual ClientResult InternalProtocol(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method InternalProtocol."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateInternalProtocolRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method InternalProtocol: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method InternalProtocol."); - } + using PipelineMessage message = CreateInternalProtocolRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -1890,23 +1137,10 @@ public virtual ClientResult InternalProtocol(BinaryContent content, RequestOptio /// The response returned from the service. public virtual async Task InternalProtocolAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method InternalProtocolAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateInternalProtocolRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method InternalProtocolAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method InternalProtocolAsync."); - } + using PipelineMessage message = CreateInternalProtocolRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// When set protocol false and convenient true, then the protocol method should be internal. @@ -1916,23 +1150,10 @@ public virtual async Task InternalProtocolAsync(BinaryContent cont /// Service returned a non-success status code. public virtual ClientResult InternalProtocol(Thing body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method InternalProtocol."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = InternalProtocol(body, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method InternalProtocol: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method InternalProtocol."); - } + ClientResult result = InternalProtocol(body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// When set protocol false and convenient true, then the protocol method should be internal. @@ -1942,23 +1163,10 @@ public virtual ClientResult InternalProtocol(Thing body, CancellationToke /// Service returned a non-success status code. public virtual async Task> InternalProtocolAsync(Thing body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method InternalProtocolAsync."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = await InternalProtocolAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method InternalProtocolAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method InternalProtocolAsync."); - } + ClientResult result = await InternalProtocolAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); } /// @@ -1974,21 +1182,8 @@ public virtual async Task> InternalProtocolAsync(Thing body, /// The response returned from the service. public virtual ClientResult StillConvenient(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method StillConvenient."); - using PipelineMessage message = CreateStillConvenientRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method StillConvenient: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method StillConvenient."); - } + using PipelineMessage message = CreateStillConvenientRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -2004,21 +1199,8 @@ public virtual ClientResult StillConvenient(RequestOptions options) /// The response returned from the service. public virtual async Task StillConvenientAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method StillConvenientAsync."); - using PipelineMessage message = CreateStillConvenientRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method StillConvenientAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method StillConvenientAsync."); - } + using PipelineMessage message = CreateStillConvenientRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one. @@ -2026,20 +1208,7 @@ public virtual async Task StillConvenientAsync(RequestOptions opti /// Service returned a non-success status code. public virtual ClientResult StillConvenient(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method StillConvenient."); - return StillConvenient(cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method StillConvenient: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method StillConvenient."); - } + return StillConvenient(cancellationToken.ToRequestOptions()); } /// When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one. @@ -2047,20 +1216,7 @@ public virtual ClientResult StillConvenient(CancellationToken cancellationToken /// Service returned a non-success status code. public virtual async Task StillConvenientAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method StillConvenientAsync."); - return await StillConvenientAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method StillConvenientAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method StillConvenientAsync."); - } + return await StillConvenientAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); } /// @@ -2079,23 +1235,10 @@ public virtual async Task StillConvenientAsync(CancellationToken c /// The response returned from the service. public virtual ClientResult HeadAsBoolean(string id, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method HeadAsBoolean."); - Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNullOrEmpty(id, nameof(id)); - using PipelineMessage message = CreateHeadAsBooleanRequest(id, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HeadAsBoolean: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HeadAsBoolean."); - } + using PipelineMessage message = CreateHeadAsBooleanRequest(id, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -2114,23 +1257,10 @@ public virtual ClientResult HeadAsBoolean(string id, RequestOptions options) /// The response returned from the service. public virtual async Task HeadAsBooleanAsync(string id, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method HeadAsBooleanAsync."); - Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNullOrEmpty(id, nameof(id)); - using PipelineMessage message = CreateHeadAsBooleanRequest(id, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HeadAsBooleanAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HeadAsBooleanAsync."); - } + using PipelineMessage message = CreateHeadAsBooleanRequest(id, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// head as boolean. @@ -2141,22 +1271,9 @@ public virtual async Task HeadAsBooleanAsync(string id, RequestOpt /// Service returned a non-success status code. public virtual ClientResult HeadAsBoolean(string id, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method HeadAsBoolean."); - Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNullOrEmpty(id, nameof(id)); - return HeadAsBoolean(id, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HeadAsBoolean: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HeadAsBoolean."); - } + return HeadAsBoolean(id, cancellationToken.ToRequestOptions()); } /// head as boolean. @@ -2167,22 +1284,9 @@ public virtual ClientResult HeadAsBoolean(string id, CancellationToken cancellat /// Service returned a non-success status code. public virtual async Task HeadAsBooleanAsync(string id, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method HeadAsBooleanAsync."); - Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNullOrEmpty(id, nameof(id)); - return await HeadAsBooleanAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method HeadAsBooleanAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method HeadAsBooleanAsync."); - } + return await HeadAsBooleanAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); } /// @@ -2201,23 +1305,10 @@ public virtual async Task HeadAsBooleanAsync(string id, Cancellati /// The response returned from the service. public virtual ClientResult WithApiVersion(string p1, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method WithApiVersion."); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - using PipelineMessage message = CreateWithApiVersionRequest(p1, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method WithApiVersion: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method WithApiVersion."); - } + using PipelineMessage message = CreateWithApiVersionRequest(p1, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -2236,23 +1327,10 @@ public virtual ClientResult WithApiVersion(string p1, RequestOptions options) /// The response returned from the service. public virtual async Task WithApiVersionAsync(string p1, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method WithApiVersionAsync."); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - using PipelineMessage message = CreateWithApiVersionRequest(p1, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method WithApiVersionAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method WithApiVersionAsync."); - } + using PipelineMessage message = CreateWithApiVersionRequest(p1, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Return hi again. @@ -2263,22 +1341,9 @@ public virtual async Task WithApiVersionAsync(string p1, RequestOp /// Service returned a non-success status code. public virtual ClientResult WithApiVersion(string p1, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method WithApiVersion."); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - return WithApiVersion(p1, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method WithApiVersion: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method WithApiVersion."); - } + return WithApiVersion(p1, cancellationToken.ToRequestOptions()); } /// Return hi again. @@ -2289,22 +1354,9 @@ public virtual ClientResult WithApiVersion(string p1, CancellationToken cancella /// Service returned a non-success status code. public virtual async Task WithApiVersionAsync(string p1, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method WithApiVersionAsync."); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - return await WithApiVersionAsync(p1, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method WithApiVersionAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method WithApiVersionAsync."); - } + return await WithApiVersionAsync(p1, cancellationToken.ToRequestOptions()).ConfigureAwait(false); } /// @@ -2320,20 +1372,7 @@ public virtual async Task WithApiVersionAsync(string p1, Cancellat /// The response returned from the service. public virtual CollectionResult GetWithNextLink(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithNextLink."); - return new SampleTypeSpecClientGetWithNextLinkCollectionResult(this, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithNextLink: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithNextLink."); - } + return new SampleTypeSpecClientGetWithNextLinkCollectionResult(this, options); } /// @@ -2349,20 +1388,7 @@ public virtual CollectionResult GetWithNextLink(RequestOptions options) /// The response returned from the service. public virtual AsyncCollectionResult GetWithNextLinkAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithNextLinkAsync."); - return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult(this, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithNextLinkAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithNextLinkAsync."); - } + return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult(this, options); } /// List things with nextlink. @@ -2370,20 +1396,7 @@ public virtual AsyncCollectionResult GetWithNextLinkAsync(RequestOptions options /// Service returned a non-success status code. public virtual CollectionResult GetWithNextLink(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithNextLink."); - return new SampleTypeSpecClientGetWithNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithNextLink: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithNextLink."); - } + return new SampleTypeSpecClientGetWithNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); } /// List things with nextlink. @@ -2391,20 +1404,7 @@ public virtual CollectionResult GetWithNextLink(CancellationToken cancell /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithNextLinkAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithNextLinkAsync."); - return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithNextLinkAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithNextLinkAsync."); - } + return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); } /// @@ -2420,20 +1420,7 @@ public virtual AsyncCollectionResult GetWithNextLinkAsync(CancellationTok /// The response returned from the service. public virtual CollectionResult GetWithStringNextLink(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithStringNextLink."); - return new SampleTypeSpecClientGetWithStringNextLinkCollectionResult(this, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithStringNextLink: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithStringNextLink."); - } + return new SampleTypeSpecClientGetWithStringNextLinkCollectionResult(this, options); } /// @@ -2449,20 +1436,7 @@ public virtual CollectionResult GetWithStringNextLink(RequestOptions options) /// The response returned from the service. public virtual AsyncCollectionResult GetWithStringNextLinkAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithStringNextLinkAsync."); - return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult(this, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithStringNextLinkAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithStringNextLinkAsync."); - } + return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult(this, options); } /// List things with nextlink. @@ -2470,20 +1444,7 @@ public virtual AsyncCollectionResult GetWithStringNextLinkAsync(RequestOptions o /// Service returned a non-success status code. public virtual CollectionResult GetWithStringNextLink(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithStringNextLink."); - return new SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithStringNextLink: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithStringNextLink."); - } + return new SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); } /// List things with nextlink. @@ -2491,20 +1452,7 @@ public virtual CollectionResult GetWithStringNextLink(CancellationToken c /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithStringNextLinkAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithStringNextLinkAsync."); - return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithStringNextLinkAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithStringNextLinkAsync."); - } + return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); } /// @@ -2521,20 +1469,7 @@ public virtual AsyncCollectionResult GetWithStringNextLinkAsync(Cancellat /// The response returned from the service. public virtual CollectionResult GetWithContinuationToken(string token, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithContinuationToken."); - return new SampleTypeSpecClientGetWithContinuationTokenCollectionResult(this, token, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithContinuationToken: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithContinuationToken."); - } + return new SampleTypeSpecClientGetWithContinuationTokenCollectionResult(this, token, options); } /// @@ -2551,20 +1486,7 @@ public virtual CollectionResult GetWithContinuationToken(string token, RequestOp /// The response returned from the service. public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string token, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithContinuationTokenAsync."); - return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult(this, token, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithContinuationTokenAsync."); - } + return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult(this, token, options); } /// List things with continuation token. @@ -2573,20 +1495,7 @@ public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string token, /// Service returned a non-success status code. public virtual CollectionResult GetWithContinuationToken(string token = default, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithContinuationToken."); - return new SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithContinuationToken: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithContinuationToken."); - } + return new SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); } /// List things with continuation token. @@ -2595,20 +1504,7 @@ public virtual CollectionResult GetWithContinuationToken(string token = d /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string token = default, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithContinuationTokenAsync."); - return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithContinuationTokenAsync."); - } + return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); } /// @@ -2625,20 +1521,7 @@ public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string /// The response returned from the service. public virtual CollectionResult GetWithContinuationTokenHeaderResponse(string token, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithContinuationTokenHeaderResponse."); - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult(this, token, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenHeaderResponse: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithContinuationTokenHeaderResponse."); - } + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult(this, token, options); } /// @@ -2655,20 +1538,7 @@ public virtual CollectionResult GetWithContinuationTokenHeaderResponse(string to /// The response returned from the service. public virtual AsyncCollectionResult GetWithContinuationTokenHeaderResponseAsync(string token, RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithContinuationTokenHeaderResponseAsync."); - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult(this, token, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenHeaderResponseAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithContinuationTokenHeaderResponseAsync."); - } + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult(this, token, options); } /// List things with continuation token header response. @@ -2677,20 +1547,7 @@ public virtual AsyncCollectionResult GetWithContinuationTokenHeaderResponseAsync /// Service returned a non-success status code. public virtual CollectionResult GetWithContinuationTokenHeaderResponse(string token = default, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithContinuationTokenHeaderResponse."); - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenHeaderResponse: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithContinuationTokenHeaderResponse."); - } + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); } /// List things with continuation token header response. @@ -2699,20 +1556,7 @@ public virtual CollectionResult GetWithContinuationTokenHeaderResponse(st /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithContinuationTokenHeaderResponseAsync(string token = default, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithContinuationTokenHeaderResponseAsync."); - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenHeaderResponseAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithContinuationTokenHeaderResponseAsync."); - } + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); } /// @@ -2728,20 +1572,7 @@ public virtual AsyncCollectionResult GetWithContinuationTokenHeaderRespon /// The response returned from the service. public virtual CollectionResult GetWithPaging(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithPaging."); - return new SampleTypeSpecClientGetWithPagingCollectionResult(this, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithPaging: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithPaging."); - } + return new SampleTypeSpecClientGetWithPagingCollectionResult(this, options); } /// @@ -2757,20 +1588,7 @@ public virtual CollectionResult GetWithPaging(RequestOptions options) /// The response returned from the service. public virtual AsyncCollectionResult GetWithPagingAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetWithPagingAsync."); - return new SampleTypeSpecClientGetWithPagingAsyncCollectionResult(this, options); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithPagingAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithPagingAsync."); - } + return new SampleTypeSpecClientGetWithPagingAsyncCollectionResult(this, options); } /// List things with paging. @@ -2778,20 +1596,7 @@ public virtual AsyncCollectionResult GetWithPagingAsync(RequestOptions options) /// Service returned a non-success status code. public virtual CollectionResult GetWithPaging(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithPaging."); - return new SampleTypeSpecClientGetWithPagingCollectionResultOfT(this, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithPaging: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithPaging."); - } + return new SampleTypeSpecClientGetWithPagingCollectionResultOfT(this, cancellationToken.ToRequestOptions()); } /// List things with paging. @@ -2799,20 +1604,7 @@ public virtual CollectionResult GetWithPaging(CancellationToken cancellat /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithPagingAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetWithPagingAsync."); - return new SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetWithPagingAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetWithPagingAsync."); - } + return new SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); } /// @@ -2835,25 +1627,12 @@ public virtual AsyncCollectionResult GetWithPagingAsync(CancellationToken /// The response returned from the service. public virtual ClientResult EmbeddedParameters(string requiredHeader, string requiredQuery, BinaryContent content, string optionalHeader = default, string optionalQuery = default, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method EmbeddedParameters."); - Argument.AssertNotNullOrEmpty(requiredHeader, nameof(requiredHeader)); - Argument.AssertNotNullOrEmpty(requiredQuery, nameof(requiredQuery)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(requiredHeader, nameof(requiredHeader)); + Argument.AssertNotNullOrEmpty(requiredQuery, nameof(requiredQuery)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateEmbeddedParametersRequest(requiredHeader, requiredQuery, content, optionalHeader, optionalQuery, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method EmbeddedParameters: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method EmbeddedParameters."); - } + using PipelineMessage message = CreateEmbeddedParametersRequest(requiredHeader, requiredQuery, content, optionalHeader, optionalQuery, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -2876,25 +1655,12 @@ public virtual ClientResult EmbeddedParameters(string requiredHeader, string req /// The response returned from the service. public virtual async Task EmbeddedParametersAsync(string requiredHeader, string requiredQuery, BinaryContent content, string optionalHeader = default, string optionalQuery = default, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method EmbeddedParametersAsync."); - Argument.AssertNotNullOrEmpty(requiredHeader, nameof(requiredHeader)); - Argument.AssertNotNullOrEmpty(requiredQuery, nameof(requiredQuery)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(requiredHeader, nameof(requiredHeader)); + Argument.AssertNotNullOrEmpty(requiredQuery, nameof(requiredQuery)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateEmbeddedParametersRequest(requiredHeader, requiredQuery, content, optionalHeader, optionalQuery, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method EmbeddedParametersAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method EmbeddedParametersAsync."); - } + using PipelineMessage message = CreateEmbeddedParametersRequest(requiredHeader, requiredQuery, content, optionalHeader, optionalQuery, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// An operation with embedded parameters within the body. @@ -2904,22 +1670,9 @@ public virtual async Task EmbeddedParametersAsync(string requiredH /// Service returned a non-success status code. public virtual ClientResult EmbeddedParameters(ModelWithEmbeddedNonBodyParameters body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method EmbeddedParameters."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - return EmbeddedParameters(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method EmbeddedParameters: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method EmbeddedParameters."); - } + return EmbeddedParameters(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()); } /// An operation with embedded parameters within the body. @@ -2929,22 +1682,9 @@ public virtual ClientResult EmbeddedParameters(ModelWithEmbeddedNonBodyParameter /// Service returned a non-success status code. public virtual async Task EmbeddedParametersAsync(ModelWithEmbeddedNonBodyParameters body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method EmbeddedParametersAsync."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - return await EmbeddedParametersAsync(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method EmbeddedParametersAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method EmbeddedParametersAsync."); - } + return await EmbeddedParametersAsync(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); } /// @@ -2962,23 +1702,10 @@ public virtual async Task EmbeddedParametersAsync(ModelWithEmbedde /// The response returned from the service. public virtual ClientResult DynamicModelOperation(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method DynamicModelOperation."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateDynamicModelOperationRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method DynamicModelOperation: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method DynamicModelOperation."); - } + using PipelineMessage message = CreateDynamicModelOperationRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -2996,23 +1723,10 @@ public virtual ClientResult DynamicModelOperation(BinaryContent content, Request /// The response returned from the service. public virtual async Task DynamicModelOperationAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method DynamicModelOperationAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateDynamicModelOperationRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method DynamicModelOperationAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method DynamicModelOperationAsync."); - } + using PipelineMessage message = CreateDynamicModelOperationRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// An operation with a dynamic model. @@ -3022,22 +1736,9 @@ public virtual async Task DynamicModelOperationAsync(BinaryContent /// Service returned a non-success status code. public virtual ClientResult DynamicModelOperation(DynamicModel body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method DynamicModelOperation."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - return DynamicModelOperation(body, cancellationToken.ToRequestOptions()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method DynamicModelOperation: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method DynamicModelOperation."); - } + return DynamicModelOperation(body, cancellationToken.ToRequestOptions()); } /// An operation with a dynamic model. @@ -3047,22 +1748,9 @@ public virtual ClientResult DynamicModelOperation(DynamicModel body, Cancellatio /// Service returned a non-success status code. public virtual async Task DynamicModelOperationAsync(DynamicModel body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method DynamicModelOperationAsync."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - return await DynamicModelOperationAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method DynamicModelOperationAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method DynamicModelOperationAsync."); - } + return await DynamicModelOperationAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); } /// @@ -3078,21 +1766,8 @@ public virtual async Task DynamicModelOperationAsync(DynamicModel /// The response returned from the service. public virtual ClientResult GetXmlAdvancedModel(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetXmlAdvancedModel."); - using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetXmlAdvancedModel."); - } + using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -3108,21 +1783,8 @@ public virtual ClientResult GetXmlAdvancedModel(RequestOptions options) /// The response returned from the service. public virtual async Task GetXmlAdvancedModelAsync(RequestOptions options) { - try - { - System.Console.WriteLine("Entering method GetXmlAdvancedModelAsync."); - using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetXmlAdvancedModelAsync."); - } + using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Get an advanced XML model with various property types. @@ -3130,21 +1792,8 @@ public virtual async Task GetXmlAdvancedModelAsync(RequestOptions /// Service returned a non-success status code. public virtual ClientResult GetXmlAdvancedModel(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetXmlAdvancedModel."); - ClientResult result = GetXmlAdvancedModel(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetXmlAdvancedModel."); - } + ClientResult result = GetXmlAdvancedModel(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); } /// Get an advanced XML model with various property types. @@ -3152,21 +1801,8 @@ public virtual ClientResult GetXmlAdvancedModel(CancellationTo /// Service returned a non-success status code. public virtual async Task> GetXmlAdvancedModelAsync(CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method GetXmlAdvancedModelAsync."); - ClientResult result = await GetXmlAdvancedModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method GetXmlAdvancedModelAsync."); - } + ClientResult result = await GetXmlAdvancedModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); } /// @@ -3184,23 +1820,10 @@ public virtual async Task> GetXmlAdvancedModelAsy /// The response returned from the service. public virtual ClientResult UpdateXmlAdvancedModel(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateXmlAdvancedModel."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateXmlAdvancedModelRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateXmlAdvancedModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateXmlAdvancedModel."); - } + using PipelineMessage message = CreateUpdateXmlAdvancedModelRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } /// @@ -3218,23 +1841,10 @@ public virtual ClientResult UpdateXmlAdvancedModel(BinaryContent content, Reques /// The response returned from the service. public virtual async Task UpdateXmlAdvancedModelAsync(BinaryContent content, RequestOptions options = null) { - try - { - System.Console.WriteLine("Entering method UpdateXmlAdvancedModelAsync."); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateXmlAdvancedModelRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateXmlAdvancedModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateXmlAdvancedModelAsync."); - } + using PipelineMessage message = CreateUpdateXmlAdvancedModelRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// Update an advanced XML model with various property types. @@ -3244,23 +1854,10 @@ public virtual async Task UpdateXmlAdvancedModelAsync(BinaryConten /// Service returned a non-success status code. public virtual ClientResult UpdateXmlAdvancedModel(XmlAdvancedModel body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateXmlAdvancedModel."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = UpdateXmlAdvancedModel(body, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateXmlAdvancedModel: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateXmlAdvancedModel."); - } + ClientResult result = UpdateXmlAdvancedModel(body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); } /// Update an advanced XML model with various property types. @@ -3270,23 +1867,10 @@ public virtual ClientResult UpdateXmlAdvancedModel(XmlAdvanced /// Service returned a non-success status code. public virtual async Task> UpdateXmlAdvancedModelAsync(XmlAdvancedModel body, CancellationToken cancellationToken = default) { - try - { - System.Console.WriteLine("Entering method UpdateXmlAdvancedModelAsync."); - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = await UpdateXmlAdvancedModelAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); - } - catch (Exception ex) - { - System.Console.WriteLine($"An exception was thrown in method UpdateXmlAdvancedModelAsync: {ex}"); - throw; - } - finally - { - System.Console.WriteLine("Exiting method UpdateXmlAdvancedModelAsync."); - } + ClientResult result = await UpdateXmlAdvancedModelAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); } /// Initializes a new instance of AnimalOperations. diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientOptions.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientOptions.cs index c62f450a18d..019e2638bf5 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientOptions.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientOptions.cs @@ -4,6 +4,8 @@ using System; using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Configuration; namespace SampleTypeSpec { @@ -24,6 +26,22 @@ public SampleTypeSpecClientOptions(ServiceVersion version = LatestVersion) }; } + /// Initializes a new instance of SampleTypeSpecClientOptions from configuration. + /// The configuration section. + [Experimental("SCME0002")] + internal SampleTypeSpecClientOptions(IConfigurationSection section) : base(section) + { + Version = "2024-08-16-preview"; + if (section is null || !section.Exists()) + { + return; + } + if (section["Version"] is string version) + { + Version = version; + } + } + /// Gets the Version. internal string Version { get; } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientSettings.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientSettings.cs new file mode 100644 index 00000000000..a1fa0ba0560 --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientSettings.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Configuration; + +namespace SampleTypeSpec +{ + /// Represents the settings used to configure a that can be loaded from an . + [Experimental("SCME0002")] + public partial class SampleTypeSpecClientSettings : ClientSettings + { + /// Gets or sets the SampleTypeSpecUrl. + public Uri SampleTypeSpecUrl { get; set; } + + /// Gets or sets the Options. + public SampleTypeSpecClientOptions Options { get; set; } + + /// Binds configuration values from the given section. + /// The configuration section. + protected override void BindCore(IConfigurationSection section) + { + if (Uri.TryCreate(section["SampleTypeSpecUrl"], UriKind.Absolute, out Uri sampleTypeSpecUrl)) + { + SampleTypeSpecUrl = sampleTypeSpecUrl; + } + IConfigurationSection optionsSection = section.GetSection("Options"); + if (optionsSection.Exists()) + { + Options = new SampleTypeSpecClientOptions(optionsSection); + } + } + } +} diff --git a/docs/samples/client/csharp/SampleService/package.json b/docs/samples/client/csharp/SampleService/package.json index e24bc78579c..97c31d59fb2 100644 --- a/docs/samples/client/csharp/SampleService/package.json +++ b/docs/samples/client/csharp/SampleService/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@typespec/http-client-csharp": "1.0.0-alpha.20260310.2", + "@typespec/http-client-csharp": "1.0.0-alpha.20260407.1", "logging-plugin": "file:../plugins/logging" } } diff --git a/packages/http-client-csharp/README.md b/packages/http-client-csharp/README.md new file mode 100644 index 00000000000..2acc3d7cbaf --- /dev/null +++ b/packages/http-client-csharp/README.md @@ -0,0 +1,184 @@ +# @typespec/http-client-csharp + +TypeSpec library for emitting Http Client libraries for C#. + +## Install + +```bash +npm install @typespec/http-client-csharp +``` + +## Usage + +### Prerequisite + +- Install [Node.js](https://nodejs.org/download/) 20 or above. (Verify by running `node --version`) +- Install [**.NET 8.0 SDK**](https://dotnet.microsoft.com/download/dotnet/8.0) for your specific platform. (or a higher version) + +### Customizing Generated Code + +For detailed instructions on how to customize the generated C# code, see the [Customization Guide](https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/.tspd/docs/customization.md). + +## Emitter usage + +1. Via the command line + +```bash +tsp compile . --emit=@typespec/http-client-csharp +``` + +2. Via the config + +```yaml +emit: + - "@typespec/http-client-csharp" +``` + +The config can be extended with options as follows: + +```yaml +emit: + - "@typespec/http-client-csharp" +options: + "@typespec/http-client-csharp": + option: value +``` + +## Emitter options + +### `emitter-output-dir` + +**Type:** `absolutePath` + +Defines the emitter output directory. Defaults to `{output-dir}/@typespec/http-client-csharp` +See [Configuring output directory for more info](https://typespec.io/docs/handbook/configuration/configuration/#configuring-output-directory) + +### `api-version` + +**Type:** `string` + +For TypeSpec files using the [`@versioned`](https://typespec.io/docs/libraries/versioning/reference/decorators/#@TypeSpec.Versioning.versioned) decorator, set this option to the version that should be used to generate against. + +### `generate-protocol-methods` + +**Type:** `boolean` + +Set to `false` to skip generation of protocol methods. The default value is `true`. + +### `generate-convenience-methods` + +**Type:** `boolean` + +Set to `false` to skip generation of convenience methods. The default value is `true`. + +### `unreferenced-types-handling` + +**Type:** `"removeOrInternalize" | "internalize" | "keepAll"` + +Defines the strategy on how to handle unreferenced types. The default value is `removeOrInternalize`. + +### `new-project` + +**Type:** `boolean` + +Set to `true` to overwrite the csproj if it already exists. The default value is `false`. + +### `save-inputs` + +**Type:** `boolean` + +Set to `true` to save the `tspCodeModel.json` and `Configuration.json` files that are emitted and used as inputs to the generator. The default value is `false`. + +### `package-name` + +**Type:** `string` + +Define the package name. If not specified, the first namespace defined in the TypeSpec is used as the package name. + +### `debug` + +**Type:** `boolean` + +Set to `true` to automatically attempt to attach to a debugger when executing the C# generator. The default value is `false`. + +### `logLevel` + +**Type:** `"info" | "debug" | "verbose"` + +Set the log level for which to collect traces. The default value is `info`. + +### `disable-xml-docs` + +**Type:** `boolean` + +Set to `true` to disable XML documentation generation. The default value is `false`. + +### `generator-name` + +**Type:** `string` + +The name of the generator. By default this is set to `ScmCodeModelGenerator`. Generator authors can set this to the name of a generator that inherits from `ScmCodeModelGenerator`. + +### `emitter-extension-path` + +**Type:** `string` + +Allows emitter authors to specify the path to a custom emitter package, allowing you to extend the emitter behavior. This should be set to `import.meta.url` if you are using a custom emitter. + +### `plugins` + +**Type:** `array` + +Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends GeneratorPlugin. + +### `license` + +**Type:** `object` + +License information for the generated client code. + +### `sdk-context-options` + +**Type:** `object` + +The SDK context options that implement the `CreateSdkContextOptions` interface from the [`@azure-tools/typespec-client-generator-core`](https://www.npmjs.com/package/@azure-tools/typespec-client-generator-core) package to be used by the CSharp emitter. + +## Decorators + +### TypeSpec.HttpClient.CSharp + +- [`@dynamicModel`](#@dynamicmodel) + +#### `@dynamicModel` + +Marks a model or namespace as dynamic, indicating it should generate dynamic model code. +Can be applied to Model or Namespace types. + +```typespec +@TypeSpec.HttpClient.CSharp.dynamicModel +``` + +##### Target + +`Model | Namespace` + +##### Parameters + +None + +##### Examples + +```tsp +@dynamicModel +model Pet { + name: string; + kind: string; +} + +@dynamicModel +namespace PetStore { + model Dog extends Pet { + breed: string; + } +} +``` diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index e1cfdeb502c..5462350078e 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -31,7 +31,7 @@ if (-not $LaunchOnly) { Write-Host "Generating SampleTypeSpec using plugins" -ForegroundColor Cyan - Invoke "npx tsp compile . --trace @typespec/http-client-csharp" $sampleDir + Invoke "npx tsp compile . --trace @typespec/http-client-csharp --emit $packageRoot" $sampleDir # exit if the generation failed if ($LASTEXITCODE -ne 0) { diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.RestClient.cs index 8842d696981..00b3f0e971c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.RestClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.RestClient.cs @@ -219,14 +219,14 @@ internal PipelineMessage CreateReturnsAnonymousModelRequest(RequestOptions optio return message; } - internal PipelineMessage CreateGetUnknownValueRequest(string accept, RequestOptions options) + internal PipelineMessage CreateGetUnknownValueRequest(RequestOptions options) { ClientUriBuilder uri = new ClientUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/unknown-value", false); PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); PipelineRequest request = message.Request; - request.Headers.Set("Accept", accept); + request.Headers.Set("Accept", "text/plain"); message.Apply(options); return message; } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs index 8d8a1d19a65..1ccc42db7ea 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs @@ -1053,17 +1053,12 @@ public virtual async Task> ReturnsAn /// /// /// - /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - public virtual ClientResult GetUnknownValue(string accept, RequestOptions options) + public virtual ClientResult GetUnknownValue(RequestOptions options) { - Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - - using PipelineMessage message = CreateGetUnknownValueRequest(accept, options); + using PipelineMessage message = CreateGetUnknownValueRequest(options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } @@ -1075,45 +1070,30 @@ public virtual ClientResult GetUnknownValue(string accept, RequestOptions option /// /// /// - /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task GetUnknownValueAsync(string accept, RequestOptions options) + public virtual async Task GetUnknownValueAsync(RequestOptions options) { - Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - - using PipelineMessage message = CreateGetUnknownValueRequest(accept, options); + using PipelineMessage message = CreateGetUnknownValueRequest(options); return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// get extensible enum. - /// /// The cancellation token that can be used to cancel the operation. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - public virtual ClientResult GetUnknownValue(string accept, CancellationToken cancellationToken = default) + public virtual ClientResult GetUnknownValue(CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - - ClientResult result = GetUnknownValue(accept, cancellationToken.ToRequestOptions()); + ClientResult result = GetUnknownValue(cancellationToken.ToRequestOptions()); return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); } /// get extensible enum. - /// /// The cancellation token that can be used to cancel the operation. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - public virtual async Task> GetUnknownValueAsync(string accept, CancellationToken cancellationToken = default) + public virtual async Task> GetUnknownValueAsync(CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(accept, nameof(accept)); - - ClientResult result = await GetUnknownValueAsync(accept, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + ClientResult result = await GetUnknownValueAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json index b387bdf191f..c8e082d8da9 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json @@ -3731,7 +3731,7 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "ListWithContinuationTokenHeaderResponse.Response.anonymous.things", + "crossLanguageDefinitionId": "SampleTypeSpec.ListWithContinuationTokenHeaderResponse.Response.anonymous.things", "serializationOptions": { "json": { "name": "things" @@ -9537,9 +9537,126 @@ "serializedName": "Accept", "type": { "$id": "696", - "kind": "string", - "name": "string", - "crossLanguageDefinitionId": "TypeSpec.string", + "kind": "enum", + "name": "getUnknownValueContentType", + "crossLanguageDefinitionId": "SampleTypeSpec.getUnknownValue.accept", + "valueType": { + "$id": "697", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "698", + "kind": "enumvalue", + "name": "text/plain", + "value": "text/plain", + "valueType": { + "$ref": "697" + }, + "enumType": { + "$ref": "696" + }, + "decorators": [] + }, + { + "$id": "699", + "kind": "enumvalue", + "name": "text/plain", + "value": "text/plain", + "valueType": { + "$ref": "697" + }, + "enumType": { + "$ref": "696" + }, + "decorators": [] + }, + { + "$id": "700", + "kind": "enumvalue", + "name": "text/plain", + "value": "text/plain", + "valueType": { + "$ref": "697" + }, + "enumType": { + "$ref": "696" + }, + "decorators": [] + }, + { + "$id": "701", + "kind": "enumvalue", + "name": "text/plain", + "value": "text/plain", + "valueType": { + "$ref": "697" + }, + "enumType": { + "$ref": "696" + }, + "decorators": [] + }, + { + "$id": "702", + "kind": "enumvalue", + "name": "text/plain", + "value": "text/plain", + "valueType": { + "$ref": "697" + }, + "enumType": { + "$ref": "696" + }, + "decorators": [] + }, + { + "$id": "703", + "kind": "enumvalue", + "name": "text/plain", + "value": "text/plain", + "valueType": { + "$ref": "697" + }, + "enumType": { + "$ref": "696" + }, + "decorators": [] + }, + { + "$id": "704", + "kind": "enumvalue", + "name": "text/plain", + "value": "text/plain", + "valueType": { + "$ref": "697" + }, + "enumType": { + "$ref": "696" + }, + "decorators": [] + }, + { + "$id": "705", + "kind": "enumvalue", + "name": "text/plain", + "value": "text/plain", + "valueType": { + "$ref": "697" + }, + "enumType": { + "$ref": "696" + }, + "decorators": [] + } + ], + "namespace": "", + "isFixed": true, + "isFlags": false, + "usage": "None", "decorators": [] }, "isApiVersion": false, @@ -9551,7 +9668,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.getUnknownValue.accept", "methodParameterSegments": [ { - "$id": "697", + "$id": "706", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -9576,7 +9693,7 @@ 200 ], "bodyType": { - "$id": "698", + "$id": "707", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -9608,12 +9725,12 @@ }, "parameters": [ { - "$ref": "697" + "$ref": "706" } ], "response": { "type": { - "$ref": "698" + "$ref": "707" } }, "isOverride": false, @@ -9622,7 +9739,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.getUnknownValue" }, { - "$id": "699", + "$id": "708", "kind": "basic", "name": "internalProtocol", "accessibility": "public", @@ -9632,14 +9749,14 @@ ], "doc": "When set protocol false and convenient true, then the protocol method should be internal", "operation": { - "$id": "700", + "$id": "709", "name": "internalProtocol", "resourceName": "SampleTypeSpec", "doc": "When set protocol false and convenient true, then the protocol method should be internal", "accessibility": "public", "parameters": [ { - "$id": "701", + "$id": "710", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -9656,7 +9773,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.internalProtocol.contentType", "methodParameterSegments": [ { - "$id": "702", + "$id": "711", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -9676,7 +9793,7 @@ ] }, { - "$id": "703", + "$id": "712", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -9692,7 +9809,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.internalProtocol.accept", "methodParameterSegments": [ { - "$id": "704", + "$id": "713", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -9711,7 +9828,7 @@ ] }, { - "$id": "705", + "$id": "714", "kind": "body", "name": "body", "serializedName": "body", @@ -9730,7 +9847,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.internalProtocol.body", "methodParameterSegments": [ { - "$id": "706", + "$id": "715", "kind": "method", "name": "body", "serializedName": "body", @@ -9779,13 +9896,13 @@ }, "parameters": [ { - "$ref": "706" + "$ref": "715" }, { - "$ref": "702" + "$ref": "711" }, { - "$ref": "704" + "$ref": "713" } ], "response": { @@ -9799,7 +9916,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.internalProtocol" }, { - "$id": "707", + "$id": "716", "kind": "basic", "name": "stillConvenient", "accessibility": "public", @@ -9809,7 +9926,7 @@ ], "doc": "When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one", "operation": { - "$id": "708", + "$id": "717", "name": "stillConvenient", "resourceName": "SampleTypeSpec", "doc": "When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one", @@ -9842,7 +9959,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.stillConvenient" }, { - "$id": "709", + "$id": "718", "kind": "basic", "name": "headAsBoolean", "accessibility": "public", @@ -9852,19 +9969,19 @@ ], "doc": "head as boolean.", "operation": { - "$id": "710", + "$id": "719", "name": "headAsBoolean", "resourceName": "SampleTypeSpec", "doc": "head as boolean.", "accessibility": "public", "parameters": [ { - "$id": "711", + "$id": "720", "kind": "path", "name": "id", "serializedName": "id", "type": { - "$id": "712", + "$id": "721", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -9882,12 +9999,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.headAsBoolean.id", "methodParameterSegments": [ { - "$id": "713", + "$id": "722", "kind": "method", "name": "id", "serializedName": "id", "type": { - "$id": "714", + "$id": "723", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -9926,7 +10043,7 @@ }, "parameters": [ { - "$ref": "713" + "$ref": "722" } ], "response": {}, @@ -9936,7 +10053,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.headAsBoolean" }, { - "$id": "715", + "$id": "724", "kind": "basic", "name": "WithApiVersion", "accessibility": "public", @@ -9946,19 +10063,19 @@ ], "doc": "Return hi again", "operation": { - "$id": "716", + "$id": "725", "name": "WithApiVersion", "resourceName": "SampleTypeSpec", "doc": "Return hi again", "accessibility": "public", "parameters": [ { - "$id": "717", + "$id": "726", "kind": "header", "name": "p1", "serializedName": "p1", "type": { - "$id": "718", + "$id": "727", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -9973,12 +10090,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.WithApiVersion.p1", "methodParameterSegments": [ { - "$id": "719", + "$id": "728", "kind": "method", "name": "p1", "serializedName": "p1", "type": { - "$id": "720", + "$id": "729", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -9996,12 +10113,12 @@ ] }, { - "$id": "721", + "$id": "730", "kind": "query", "name": "apiVersion", "serializedName": "apiVersion", "type": { - "$id": "722", + "$id": "731", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10011,7 +10128,7 @@ "explode": false, "defaultValue": { "type": { - "$id": "723", + "$id": "732", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string" @@ -10025,12 +10142,12 @@ "readOnly": false, "methodParameterSegments": [ { - "$id": "724", + "$id": "733", "kind": "method", "name": "apiVersion", "serializedName": "apiVersion", "type": { - "$id": "725", + "$id": "734", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10040,7 +10157,7 @@ "isApiVersion": true, "defaultValue": { "type": { - "$id": "726", + "$id": "735", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string" @@ -10078,7 +10195,7 @@ }, "parameters": [ { - "$ref": "719" + "$ref": "728" } ], "response": {}, @@ -10088,7 +10205,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.WithApiVersion" }, { - "$id": "727", + "$id": "736", "kind": "paging", "name": "ListWithNextLink", "accessibility": "public", @@ -10098,14 +10215,14 @@ ], "doc": "List things with nextlink", "operation": { - "$id": "728", + "$id": "737", "name": "ListWithNextLink", "resourceName": "SampleTypeSpec", "doc": "List things with nextlink", "accessibility": "public", "parameters": [ { - "$id": "729", + "$id": "738", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -10121,7 +10238,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.ListWithNextLink.accept", "methodParameterSegments": [ { - "$id": "730", + "$id": "739", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -10167,7 +10284,7 @@ }, "parameters": [ { - "$ref": "730" + "$ref": "739" } ], "response": { @@ -10196,7 +10313,7 @@ } }, { - "$id": "731", + "$id": "740", "kind": "paging", "name": "ListWithStringNextLink", "accessibility": "public", @@ -10206,14 +10323,14 @@ ], "doc": "List things with nextlink", "operation": { - "$id": "732", + "$id": "741", "name": "ListWithStringNextLink", "resourceName": "SampleTypeSpec", "doc": "List things with nextlink", "accessibility": "public", "parameters": [ { - "$id": "733", + "$id": "742", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -10229,7 +10346,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.ListWithStringNextLink.accept", "methodParameterSegments": [ { - "$id": "734", + "$id": "743", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -10275,7 +10392,7 @@ }, "parameters": [ { - "$ref": "734" + "$ref": "743" } ], "response": { @@ -10304,7 +10421,7 @@ } }, { - "$id": "735", + "$id": "744", "kind": "paging", "name": "ListWithContinuationToken", "accessibility": "public", @@ -10314,19 +10431,19 @@ ], "doc": "List things with continuation token", "operation": { - "$id": "736", + "$id": "745", "name": "ListWithContinuationToken", "resourceName": "SampleTypeSpec", "doc": "List things with continuation token", "accessibility": "public", "parameters": [ { - "$id": "737", + "$id": "746", "kind": "query", "name": "token", "serializedName": "token", "type": { - "$id": "738", + "$id": "747", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10341,12 +10458,12 @@ "readOnly": false, "methodParameterSegments": [ { - "$id": "739", + "$id": "748", "kind": "method", "name": "token", "serializedName": "token", "type": { - "$id": "740", + "$id": "749", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10364,7 +10481,7 @@ ] }, { - "$id": "741", + "$id": "750", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -10380,7 +10497,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.ListWithContinuationToken.accept", "methodParameterSegments": [ { - "$id": "742", + "$id": "751", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -10426,10 +10543,10 @@ }, "parameters": [ { - "$ref": "739" + "$ref": "748" }, { - "$ref": "742" + "$ref": "751" } ], "response": { @@ -10450,7 +10567,7 @@ ], "continuationToken": { "parameter": { - "$ref": "737" + "$ref": "746" }, "responseSegments": [ "nextToken" @@ -10461,7 +10578,7 @@ } }, { - "$id": "743", + "$id": "752", "kind": "paging", "name": "ListWithContinuationTokenHeaderResponse", "accessibility": "public", @@ -10471,19 +10588,19 @@ ], "doc": "List things with continuation token header response", "operation": { - "$id": "744", + "$id": "753", "name": "ListWithContinuationTokenHeaderResponse", "resourceName": "SampleTypeSpec", "doc": "List things with continuation token header response", "accessibility": "public", "parameters": [ { - "$id": "745", + "$id": "754", "kind": "query", "name": "token", "serializedName": "token", "type": { - "$id": "746", + "$id": "755", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10498,12 +10615,12 @@ "readOnly": false, "methodParameterSegments": [ { - "$id": "747", + "$id": "756", "kind": "method", "name": "token", "serializedName": "token", "type": { - "$id": "748", + "$id": "757", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10521,7 +10638,7 @@ ] }, { - "$id": "749", + "$id": "758", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -10537,7 +10654,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.ListWithContinuationTokenHeaderResponse.accept", "methodParameterSegments": [ { - "$id": "750", + "$id": "759", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -10569,7 +10686,7 @@ "name": "nextToken", "nameInResponse": "next-token", "type": { - "$id": "751", + "$id": "760", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10595,10 +10712,10 @@ }, "parameters": [ { - "$ref": "747" + "$ref": "756" }, { - "$ref": "750" + "$ref": "759" } ], "response": { @@ -10619,7 +10736,7 @@ ], "continuationToken": { "parameter": { - "$ref": "745" + "$ref": "754" }, "responseSegments": [ "next-token" @@ -10630,7 +10747,7 @@ } }, { - "$id": "752", + "$id": "761", "kind": "paging", "name": "ListWithPaging", "accessibility": "public", @@ -10640,14 +10757,14 @@ ], "doc": "List things with paging", "operation": { - "$id": "753", + "$id": "762", "name": "ListWithPaging", "resourceName": "SampleTypeSpec", "doc": "List things with paging", "accessibility": "public", "parameters": [ { - "$id": "754", + "$id": "763", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -10663,7 +10780,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.ListWithPaging.accept", "methodParameterSegments": [ { - "$id": "755", + "$id": "764", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -10709,7 +10826,7 @@ }, "parameters": [ { - "$ref": "755" + "$ref": "764" } ], "response": { @@ -10732,7 +10849,7 @@ } }, { - "$id": "756", + "$id": "765", "kind": "basic", "name": "EmbeddedParameters", "accessibility": "public", @@ -10742,20 +10859,20 @@ ], "doc": "An operation with embedded parameters within the body", "operation": { - "$id": "757", + "$id": "766", "name": "EmbeddedParameters", "resourceName": "SampleTypeSpec", "doc": "An operation with embedded parameters within the body", "accessibility": "public", "parameters": [ { - "$id": "758", + "$id": "767", "kind": "header", "name": "requiredHeader", "serializedName": "required-header", "doc": "required header parameter", "type": { - "$id": "759", + "$id": "768", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10770,7 +10887,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.ModelWithEmbeddedNonBodyParameters.requiredHeader", "methodParameterSegments": [ { - "$id": "760", + "$id": "769", "kind": "method", "name": "body", "serializedName": "body", @@ -10787,7 +10904,7 @@ "decorators": [] }, { - "$id": "761", + "$id": "770", "kind": "method", "name": "requiredHeader", "serializedName": "requiredHeader", @@ -10807,13 +10924,13 @@ ] }, { - "$id": "762", + "$id": "771", "kind": "header", "name": "optionalHeader", "serializedName": "optional-header", "doc": "optional header parameter", "type": { - "$id": "763", + "$id": "772", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10828,10 +10945,10 @@ "crossLanguageDefinitionId": "SampleTypeSpec.ModelWithEmbeddedNonBodyParameters.optionalHeader", "methodParameterSegments": [ { - "$ref": "760" + "$ref": "769" }, { - "$id": "764", + "$id": "773", "kind": "method", "name": "optionalHeader", "serializedName": "optionalHeader", @@ -10851,13 +10968,13 @@ ] }, { - "$id": "765", + "$id": "774", "kind": "query", "name": "requiredQuery", "serializedName": "requiredQuery", "doc": "required query parameter", "type": { - "$id": "766", + "$id": "775", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10872,10 +10989,10 @@ "readOnly": false, "methodParameterSegments": [ { - "$ref": "760" + "$ref": "769" }, { - "$id": "767", + "$id": "776", "kind": "method", "name": "requiredQuery", "serializedName": "requiredQuery", @@ -10895,13 +11012,13 @@ ] }, { - "$id": "768", + "$id": "777", "kind": "query", "name": "optionalQuery", "serializedName": "optionalQuery", "doc": "optional query parameter", "type": { - "$id": "769", + "$id": "778", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -10916,10 +11033,10 @@ "readOnly": false, "methodParameterSegments": [ { - "$ref": "760" + "$ref": "769" }, { - "$id": "770", + "$id": "779", "kind": "method", "name": "optionalQuery", "serializedName": "optionalQuery", @@ -10939,7 +11056,7 @@ ] }, { - "$id": "771", + "$id": "780", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -10956,7 +11073,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.EmbeddedParameters.contentType", "methodParameterSegments": [ { - "$id": "772", + "$id": "781", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -10976,7 +11093,7 @@ ] }, { - "$id": "773", + "$id": "782", "kind": "body", "name": "body", "serializedName": "body", @@ -10995,7 +11112,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.EmbeddedParameters.body", "methodParameterSegments": [ { - "$ref": "760" + "$ref": "769" } ] } @@ -11024,10 +11141,10 @@ }, "parameters": [ { - "$ref": "760" + "$ref": "769" }, { - "$ref": "772" + "$ref": "781" } ], "response": {}, @@ -11037,7 +11154,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.EmbeddedParameters" }, { - "$id": "774", + "$id": "783", "kind": "basic", "name": "DynamicModelOperation", "accessibility": "public", @@ -11047,14 +11164,14 @@ ], "doc": "An operation with a dynamic model", "operation": { - "$id": "775", + "$id": "784", "name": "DynamicModelOperation", "resourceName": "SampleTypeSpec", "doc": "An operation with a dynamic model", "accessibility": "public", "parameters": [ { - "$id": "776", + "$id": "785", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -11071,7 +11188,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.DynamicModelOperation.contentType", "methodParameterSegments": [ { - "$id": "777", + "$id": "786", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -11091,7 +11208,7 @@ ] }, { - "$id": "778", + "$id": "787", "kind": "body", "name": "body", "serializedName": "body", @@ -11110,7 +11227,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.DynamicModelOperation.body", "methodParameterSegments": [ { - "$id": "779", + "$id": "788", "kind": "method", "name": "body", "serializedName": "body", @@ -11153,10 +11270,10 @@ }, "parameters": [ { - "$ref": "779" + "$ref": "788" }, { - "$ref": "777" + "$ref": "786" } ], "response": {}, @@ -11166,7 +11283,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.DynamicModelOperation" }, { - "$id": "780", + "$id": "789", "kind": "basic", "name": "GetXmlAdvancedModel", "accessibility": "public", @@ -11176,14 +11293,14 @@ ], "doc": "Get an advanced XML model with various property types", "operation": { - "$id": "781", + "$id": "790", "name": "GetXmlAdvancedModel", "resourceName": "SampleTypeSpec", "doc": "Get an advanced XML model with various property types", "accessibility": "public", "parameters": [ { - "$id": "782", + "$id": "791", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -11199,7 +11316,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.GetXmlAdvancedModel.accept", "methodParameterSegments": [ { - "$id": "783", + "$id": "792", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -11253,7 +11370,7 @@ }, "parameters": [ { - "$ref": "783" + "$ref": "792" } ], "response": { @@ -11267,7 +11384,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.GetXmlAdvancedModel" }, { - "$id": "784", + "$id": "793", "kind": "basic", "name": "UpdateXmlAdvancedModel", "accessibility": "public", @@ -11277,14 +11394,14 @@ ], "doc": "Update an advanced XML model with various property types", "operation": { - "$id": "785", + "$id": "794", "name": "UpdateXmlAdvancedModel", "resourceName": "SampleTypeSpec", "doc": "Update an advanced XML model with various property types", "accessibility": "public", "parameters": [ { - "$id": "786", + "$id": "795", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -11300,7 +11417,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.UpdateXmlAdvancedModel.contentType", "methodParameterSegments": [ { - "$id": "787", + "$id": "796", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -11319,7 +11436,7 @@ ] }, { - "$id": "788", + "$id": "797", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -11335,7 +11452,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.UpdateXmlAdvancedModel.accept", "methodParameterSegments": [ { - "$id": "789", + "$id": "798", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -11354,7 +11471,7 @@ ] }, { - "$id": "790", + "$id": "799", "kind": "body", "name": "body", "serializedName": "body", @@ -11373,7 +11490,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.UpdateXmlAdvancedModel.body", "methodParameterSegments": [ { - "$id": "791", + "$id": "800", "kind": "method", "name": "body", "serializedName": "body", @@ -11430,13 +11547,13 @@ }, "parameters": [ { - "$ref": "791" + "$ref": "800" }, { - "$ref": "787" + "$ref": "796" }, { - "$ref": "789" + "$ref": "798" } ], "response": { @@ -11452,12 +11569,12 @@ ], "parameters": [ { - "$id": "792", + "$id": "801", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "793", + "$id": "802", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -11472,7 +11589,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.sampleTypeSpecUrl" }, { - "$ref": "724" + "$ref": "733" } ], "initializedBy": 1, @@ -11484,13 +11601,13 @@ ], "children": [ { - "$id": "794", + "$id": "803", "kind": "client", "name": "Notebooks", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "795", + "$id": "804", "kind": "basic", "name": "getNotebook", "accessibility": "public", @@ -11500,19 +11617,19 @@ ], "doc": "Get a notebook by name", "operation": { - "$id": "796", + "$id": "805", "name": "getNotebook", "resourceName": "Notebooks", "doc": "Get a notebook by name", "accessibility": "public", "parameters": [ { - "$id": "797", + "$id": "806", "kind": "path", "name": "notebookName", "serializedName": "notebookName", "type": { - "$id": "798", + "$id": "807", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -11530,12 +11647,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.Notebooks.getNotebook.notebookName", "methodParameterSegments": [ { - "$id": "799", + "$id": "808", "kind": "method", "name": "notebook", "serializedName": "notebook", "type": { - "$id": "800", + "$id": "809", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -11554,7 +11671,7 @@ ] }, { - "$id": "801", + "$id": "810", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -11570,7 +11687,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.Notebooks.getNotebook.accept", "methodParameterSegments": [ { - "$id": "802", + "$id": "811", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -11616,7 +11733,7 @@ }, "parameters": [ { - "$ref": "802" + "$ref": "811" } ], "response": { @@ -11632,12 +11749,12 @@ ], "parameters": [ { - "$id": "803", + "$id": "812", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "804", + "$id": "813", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -11652,7 +11769,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.Notebooks.sampleTypeSpecUrl" }, { - "$ref": "799" + "$ref": "808" } ], "initializedBy": 3, @@ -11668,13 +11785,13 @@ "isMultiServiceClient": false }, { - "$id": "805", + "$id": "814", "kind": "client", "name": "AnimalOperations", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "806", + "$id": "815", "kind": "basic", "name": "updatePetAsAnimal", "accessibility": "public", @@ -11684,14 +11801,14 @@ ], "doc": "Update a pet as an animal", "operation": { - "$id": "807", + "$id": "816", "name": "updatePetAsAnimal", "resourceName": "AnimalOperations", "doc": "Update a pet as an animal", "accessibility": "public", "parameters": [ { - "$id": "808", + "$id": "817", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -11708,7 +11825,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updatePetAsAnimal.contentType", "methodParameterSegments": [ { - "$id": "809", + "$id": "818", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -11728,7 +11845,7 @@ ] }, { - "$id": "810", + "$id": "819", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -11744,7 +11861,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updatePetAsAnimal.accept", "methodParameterSegments": [ { - "$id": "811", + "$id": "820", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -11763,7 +11880,7 @@ ] }, { - "$id": "812", + "$id": "821", "kind": "body", "name": "animal", "serializedName": "animal", @@ -11782,7 +11899,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updatePetAsAnimal.animal", "methodParameterSegments": [ { - "$id": "813", + "$id": "822", "kind": "method", "name": "animal", "serializedName": "animal", @@ -11831,13 +11948,13 @@ }, "parameters": [ { - "$ref": "813" + "$ref": "822" }, { - "$ref": "809" + "$ref": "818" }, { - "$ref": "811" + "$ref": "820" } ], "response": { @@ -11851,7 +11968,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updatePetAsAnimal" }, { - "$id": "814", + "$id": "823", "kind": "basic", "name": "updateDogAsAnimal", "accessibility": "public", @@ -11861,14 +11978,14 @@ ], "doc": "Update a dog as an animal", "operation": { - "$id": "815", + "$id": "824", "name": "updateDogAsAnimal", "resourceName": "AnimalOperations", "doc": "Update a dog as an animal", "accessibility": "public", "parameters": [ { - "$id": "816", + "$id": "825", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -11885,7 +12002,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updateDogAsAnimal.contentType", "methodParameterSegments": [ { - "$id": "817", + "$id": "826", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -11905,7 +12022,7 @@ ] }, { - "$id": "818", + "$id": "827", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -11921,7 +12038,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updateDogAsAnimal.accept", "methodParameterSegments": [ { - "$id": "819", + "$id": "828", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -11940,7 +12057,7 @@ ] }, { - "$id": "820", + "$id": "829", "kind": "body", "name": "animal", "serializedName": "animal", @@ -11959,7 +12076,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updateDogAsAnimal.animal", "methodParameterSegments": [ { - "$id": "821", + "$id": "830", "kind": "method", "name": "animal", "serializedName": "animal", @@ -12008,13 +12125,13 @@ }, "parameters": [ { - "$ref": "821" + "$ref": "830" }, { - "$ref": "817" + "$ref": "826" }, { - "$ref": "819" + "$ref": "828" } ], "response": { @@ -12030,12 +12147,12 @@ ], "parameters": [ { - "$id": "822", + "$id": "831", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "823", + "$id": "832", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -12063,13 +12180,13 @@ "isMultiServiceClient": false }, { - "$id": "824", + "$id": "833", "kind": "client", "name": "PetOperations", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "825", + "$id": "834", "kind": "basic", "name": "updatePetAsPet", "accessibility": "public", @@ -12079,14 +12196,14 @@ ], "doc": "Update a pet as a pet", "operation": { - "$id": "826", + "$id": "835", "name": "updatePetAsPet", "resourceName": "PetOperations", "doc": "Update a pet as a pet", "accessibility": "public", "parameters": [ { - "$id": "827", + "$id": "836", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -12103,7 +12220,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updatePetAsPet.contentType", "methodParameterSegments": [ { - "$id": "828", + "$id": "837", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -12123,7 +12240,7 @@ ] }, { - "$id": "829", + "$id": "838", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -12139,7 +12256,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updatePetAsPet.accept", "methodParameterSegments": [ { - "$id": "830", + "$id": "839", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -12158,7 +12275,7 @@ ] }, { - "$id": "831", + "$id": "840", "kind": "body", "name": "pet", "serializedName": "pet", @@ -12177,7 +12294,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updatePetAsPet.pet", "methodParameterSegments": [ { - "$id": "832", + "$id": "841", "kind": "method", "name": "pet", "serializedName": "pet", @@ -12226,13 +12343,13 @@ }, "parameters": [ { - "$ref": "832" + "$ref": "841" }, { - "$ref": "828" + "$ref": "837" }, { - "$ref": "830" + "$ref": "839" } ], "response": { @@ -12246,7 +12363,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updatePetAsPet" }, { - "$id": "833", + "$id": "842", "kind": "basic", "name": "updateDogAsPet", "accessibility": "public", @@ -12256,14 +12373,14 @@ ], "doc": "Update a dog as a pet", "operation": { - "$id": "834", + "$id": "843", "name": "updateDogAsPet", "resourceName": "PetOperations", "doc": "Update a dog as a pet", "accessibility": "public", "parameters": [ { - "$id": "835", + "$id": "844", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -12280,7 +12397,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updateDogAsPet.contentType", "methodParameterSegments": [ { - "$id": "836", + "$id": "845", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -12300,7 +12417,7 @@ ] }, { - "$id": "837", + "$id": "846", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -12316,7 +12433,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updateDogAsPet.accept", "methodParameterSegments": [ { - "$id": "838", + "$id": "847", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -12335,7 +12452,7 @@ ] }, { - "$id": "839", + "$id": "848", "kind": "body", "name": "pet", "serializedName": "pet", @@ -12354,7 +12471,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updateDogAsPet.pet", "methodParameterSegments": [ { - "$id": "840", + "$id": "849", "kind": "method", "name": "pet", "serializedName": "pet", @@ -12403,13 +12520,13 @@ }, "parameters": [ { - "$ref": "840" + "$ref": "849" }, { - "$ref": "836" + "$ref": "845" }, { - "$ref": "838" + "$ref": "847" } ], "response": { @@ -12425,12 +12542,12 @@ ], "parameters": [ { - "$id": "841", + "$id": "850", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "842", + "$id": "851", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -12458,13 +12575,13 @@ "isMultiServiceClient": false }, { - "$id": "843", + "$id": "852", "kind": "client", "name": "DogOperations", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "844", + "$id": "853", "kind": "basic", "name": "updateDogAsDog", "accessibility": "public", @@ -12474,14 +12591,14 @@ ], "doc": "Update a dog as a dog", "operation": { - "$id": "845", + "$id": "854", "name": "updateDogAsDog", "resourceName": "DogOperations", "doc": "Update a dog as a dog", "accessibility": "public", "parameters": [ { - "$id": "846", + "$id": "855", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -12498,7 +12615,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.DogOperations.updateDogAsDog.contentType", "methodParameterSegments": [ { - "$id": "847", + "$id": "856", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -12518,7 +12635,7 @@ ] }, { - "$id": "848", + "$id": "857", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -12534,7 +12651,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.DogOperations.updateDogAsDog.accept", "methodParameterSegments": [ { - "$id": "849", + "$id": "858", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -12553,7 +12670,7 @@ ] }, { - "$id": "850", + "$id": "859", "kind": "body", "name": "dog", "serializedName": "dog", @@ -12572,7 +12689,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.DogOperations.updateDogAsDog.dog", "methodParameterSegments": [ { - "$id": "851", + "$id": "860", "kind": "method", "name": "dog", "serializedName": "dog", @@ -12621,13 +12738,13 @@ }, "parameters": [ { - "$ref": "851" + "$ref": "860" }, { - "$ref": "847" + "$ref": "856" }, { - "$ref": "849" + "$ref": "858" } ], "response": { @@ -12643,12 +12760,12 @@ ], "parameters": [ { - "$id": "852", + "$id": "861", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "853", + "$id": "862", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -12676,13 +12793,13 @@ "isMultiServiceClient": false }, { - "$id": "854", + "$id": "863", "kind": "client", "name": "PlantOperations", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "855", + "$id": "864", "kind": "basic", "name": "getTree", "accessibility": "public", @@ -12692,14 +12809,14 @@ ], "doc": "Get a tree as a plant", "operation": { - "$id": "856", + "$id": "865", "name": "getTree", "resourceName": "PlantOperations", "doc": "Get a tree as a plant", "accessibility": "public", "parameters": [ { - "$id": "857", + "$id": "866", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -12715,7 +12832,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.getTree.accept", "methodParameterSegments": [ { - "$id": "858", + "$id": "867", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -12769,7 +12886,7 @@ }, "parameters": [ { - "$ref": "858" + "$ref": "867" } ], "response": { @@ -12783,7 +12900,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.getTree" }, { - "$id": "859", + "$id": "868", "kind": "basic", "name": "getTreeAsJson", "accessibility": "public", @@ -12793,14 +12910,14 @@ ], "doc": "Get a tree as a plant", "operation": { - "$id": "860", + "$id": "869", "name": "getTreeAsJson", "resourceName": "PlantOperations", "doc": "Get a tree as a plant", "accessibility": "public", "parameters": [ { - "$id": "861", + "$id": "870", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -12816,7 +12933,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.getTreeAsJson.accept", "methodParameterSegments": [ { - "$id": "862", + "$id": "871", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -12870,7 +12987,7 @@ }, "parameters": [ { - "$ref": "862" + "$ref": "871" } ], "response": { @@ -12884,7 +13001,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.getTreeAsJson" }, { - "$id": "863", + "$id": "872", "kind": "basic", "name": "updateTree", "accessibility": "public", @@ -12894,14 +13011,14 @@ ], "doc": "Update a tree as a plant", "operation": { - "$id": "864", + "$id": "873", "name": "updateTree", "resourceName": "PlantOperations", "doc": "Update a tree as a plant", "accessibility": "public", "parameters": [ { - "$id": "865", + "$id": "874", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -12917,7 +13034,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.updateTree.contentType", "methodParameterSegments": [ { - "$id": "866", + "$id": "875", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -12936,7 +13053,7 @@ ] }, { - "$id": "867", + "$id": "876", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -12952,7 +13069,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.updateTree.accept", "methodParameterSegments": [ { - "$id": "868", + "$id": "877", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -12971,7 +13088,7 @@ ] }, { - "$id": "869", + "$id": "878", "kind": "body", "name": "tree", "serializedName": "tree", @@ -12990,7 +13107,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.updateTree.tree", "methodParameterSegments": [ { - "$id": "870", + "$id": "879", "kind": "method", "name": "tree", "serializedName": "tree", @@ -13047,13 +13164,13 @@ }, "parameters": [ { - "$ref": "870" + "$ref": "879" }, { - "$ref": "866" + "$ref": "875" }, { - "$ref": "868" + "$ref": "877" } ], "response": { @@ -13067,7 +13184,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.updateTree" }, { - "$id": "871", + "$id": "880", "kind": "basic", "name": "updateTreeAsJson", "accessibility": "public", @@ -13077,14 +13194,14 @@ ], "doc": "Update a tree as a plant", "operation": { - "$id": "872", + "$id": "881", "name": "updateTreeAsJson", "resourceName": "PlantOperations", "doc": "Update a tree as a plant", "accessibility": "public", "parameters": [ { - "$id": "873", + "$id": "882", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -13100,7 +13217,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.updateTreeAsJson.contentType", "methodParameterSegments": [ { - "$id": "874", + "$id": "883", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -13119,7 +13236,7 @@ ] }, { - "$id": "875", + "$id": "884", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -13135,7 +13252,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.updateTreeAsJson.accept", "methodParameterSegments": [ { - "$id": "876", + "$id": "885", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -13154,7 +13271,7 @@ ] }, { - "$id": "877", + "$id": "886", "kind": "body", "name": "tree", "serializedName": "tree", @@ -13173,7 +13290,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PlantOperations.updateTreeAsJson.tree", "methodParameterSegments": [ { - "$id": "878", + "$id": "887", "kind": "method", "name": "tree", "serializedName": "tree", @@ -13230,13 +13347,13 @@ }, "parameters": [ { - "$ref": "878" + "$ref": "887" }, { - "$ref": "874" + "$ref": "883" }, { - "$ref": "876" + "$ref": "885" } ], "response": { @@ -13252,12 +13369,12 @@ ], "parameters": [ { - "$id": "879", + "$id": "888", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "880", + "$id": "889", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -13285,13 +13402,13 @@ "isMultiServiceClient": false }, { - "$id": "881", + "$id": "890", "kind": "client", "name": "Metrics", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "882", + "$id": "891", "kind": "basic", "name": "getWidgetMetrics", "accessibility": "public", @@ -13301,19 +13418,19 @@ ], "doc": "Get Widget metrics for given day of week", "operation": { - "$id": "883", + "$id": "892", "name": "getWidgetMetrics", "resourceName": "Metrics", "doc": "Get Widget metrics for given day of week", "accessibility": "public", "parameters": [ { - "$id": "884", + "$id": "893", "kind": "path", "name": "metricsNamespace", "serializedName": "metricsNamespace", "type": { - "$id": "885", + "$id": "894", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -13331,12 +13448,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.Metrics.getWidgetMetrics.metricsNamespace", "methodParameterSegments": [ { - "$id": "886", + "$id": "895", "kind": "method", "name": "metricsNamespace", "serializedName": "metricsNamespace", "type": { - "$id": "887", + "$id": "896", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -13354,7 +13471,7 @@ ] }, { - "$id": "888", + "$id": "897", "kind": "path", "name": "day", "serializedName": "day", @@ -13373,7 +13490,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.Metrics.getWidgetMetrics.day", "methodParameterSegments": [ { - "$id": "889", + "$id": "898", "kind": "method", "name": "day", "serializedName": "day", @@ -13392,7 +13509,7 @@ ] }, { - "$id": "890", + "$id": "899", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -13408,7 +13525,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.Metrics.getWidgetMetrics.accept", "methodParameterSegments": [ { - "$id": "891", + "$id": "900", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -13454,10 +13571,10 @@ }, "parameters": [ { - "$ref": "889" + "$ref": "898" }, { - "$ref": "891" + "$ref": "900" } ], "response": { @@ -13473,12 +13590,12 @@ ], "parameters": [ { - "$id": "892", + "$id": "901", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "893", + "$id": "902", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -13493,7 +13610,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.Metrics.sampleTypeSpecUrl" }, { - "$ref": "886" + "$ref": "895" } ], "initializedBy": 3, diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.RestClient.cs new file mode 100644 index 00000000000..70f2ab77344 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class EnumsOnly + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/enums-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/enums-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.cs index 326e87184ee..f5f02ca5c57 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.cs @@ -10,28 +10,146 @@ namespace _Type.Union { + /// Describe union of 2 different enums. public partial class EnumsOnly { - protected EnumsOnly() => throw null; + private readonly Uri _endpoint; - internal EnumsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of EnumsOnly for mocking. + protected EnumsOnly() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of EnumsOnly. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal EnumsOnly(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse6)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse6)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(EnumsOnlyCases prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(EnumsOnlyCases prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Send(EnumsOnlyCases prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest6 spreadModel = new SendRequest6(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task SendAsync(EnumsOnlyCases prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest6 spreadModel = new SendRequest6(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.RestClient.cs new file mode 100644 index 00000000000..7e11e9de0de --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class FloatsOnly + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/floats-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/floats-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.cs index 687ca26b9d4..a459270305d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.cs @@ -10,28 +10,140 @@ namespace _Type.Union { + /// Describe union of floats 1.1 | 2.2 | 3.3. public partial class FloatsOnly { - protected FloatsOnly() => throw null; + private readonly Uri _endpoint; - internal FloatsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of FloatsOnly for mocking. + protected FloatsOnly() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of FloatsOnly. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal FloatsOnly(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse4)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse4)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(GetResponseProp3 prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(GetResponseProp3 prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Send(GetResponseProp3 prop, CancellationToken cancellationToken = default) + { + SendRequest4 spreadModel = new SendRequest4(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task SendAsync(GetResponseProp3 prop, CancellationToken cancellationToken = default) + { + SendRequest4 spreadModel = new SendRequest4(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/Argument.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/Argument.cs new file mode 100644 index 00000000000..4c94ff7b6e5 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/Argument.cs @@ -0,0 +1,110 @@ +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace _Type.Union +{ + internal static partial class Argument + { + /// The value. + /// The name. + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + /// The value. + /// The minimum value. + /// The maximum value. + /// The name. + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + /// The value. + /// The name. + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CancellationTokenExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CancellationTokenExtensions.cs new file mode 100644 index 00000000000..fe421b047cc --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CancellationTokenExtensions.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; + +namespace _Type.Union +{ + internal static partial class CancellationTokenExtensions + { + public static RequestOptions ToRequestOptions(this CancellationToken cancellationToken) => cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingDictionary.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 00000000000..8e8a8f18106 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,186 @@ +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace _Type.Union +{ + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerDictionary == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + /// Gets the Keys. + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + /// Gets the Values. + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + /// Gets or sets the value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + /// Gets the Keys. + IEnumerable IReadOnlyDictionary.Keys => Keys; + + /// Gets the Values. + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + /// The item to search for. + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + /// The array to copy. + /// The index. + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + /// The item to remove. + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + /// The key. + /// The value to add. + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + /// The key to search for. + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + /// The key. + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + /// The key to search for. + /// The value. + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingList.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 00000000000..81edaef2cdf --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace _Type.Union +{ + internal partial class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + /// The inner list. + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + /// The inner list. + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerList == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureList().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + /// Gets or sets the value associated with the specified key. + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + /// The item. + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + /// The array to copy to. + /// The array index. + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + /// The item. + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + /// The item. + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + /// The inner list. + /// The item. + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + /// The inner list. + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientPipelineExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 00000000000..cbaf436cb30 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading.Tasks; + +namespace _Type.Union +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + await pipeline.SendAsync(message).ConfigureAwait(false); + + if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) + { + throw await ClientResultException.CreateAsync(message.Response).ConfigureAwait(false); + } + + PipelineResponse response = message.BufferResponse ? message.Response : message.ExtractResponse(); + return response; + } + + public static PipelineResponse ProcessMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + pipeline.Send(message); + + if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) + { + throw new ClientResultException(message.Response); + } + + PipelineResponse response = message.BufferResponse ? message.Response : message.ExtractResponse(); + return response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + PipelineResponse response = await pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return ClientResult.FromValue(true, response); + case >= 400 and < 500: + return ClientResult.FromValue(false, response); + default: + return new ErrorResult(response, new ClientResultException(response)); + } + } + + public static ClientResult ProcessHeadAsBoolMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + PipelineResponse response = pipeline.ProcessMessage(message, options); + switch (response.Status) + { + case >= 200 and < 300: + return ClientResult.FromValue(true, response); + case >= 400 and < 500: + return ClientResult.FromValue(false, response); + default: + return new ErrorResult(response, new ClientResultException(response)); + } + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientUriBuilder.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientUriBuilder.cs new file mode 100644 index 00000000000..516e23da549 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientUriBuilder.cs @@ -0,0 +1,181 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace _Type.Union +{ + internal partial class ClientUriBuilder + { + private UriBuilder _uriBuilder; + private StringBuilder _pathAndQuery; + private int _pathLength; + + public ClientUriBuilder() + { + } + + private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder(); + + private StringBuilder PathAndQuery => _pathAndQuery ??= new StringBuilder(); + + public void Reset(Uri uri) + { + _uriBuilder = new UriBuilder(uri); + PathAndQuery.Clear(); + PathAndQuery.Append(UriBuilder.Path); + _pathLength = PathAndQuery.Length; + PathAndQuery.Append(UriBuilder.Query); + } + + public void AppendPath(string value, bool escape) + { + if (escape) + { + value = Uri.EscapeDataString(value); + } + if (_pathLength > 0 && PathAndQuery[_pathLength - 1] == '/' && value[0] == '/') + { + PathAndQuery.Remove(_pathLength - 1, 1); + _pathLength = _pathLength - 1; + } + PathAndQuery.Insert(_pathLength, value); + _pathLength = _pathLength + value.Length; + } + + public void AppendPath(bool value, bool escape = false) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(float value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(double value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(int value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(byte[] value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); + + public void AppendPath(DateTimeOffset value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); + + public void AppendPath(TimeSpan value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); + + public void AppendPath(Guid value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(long value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPathDelimited(IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + AppendPath(string.Join(delimiter, stringValues), escape); + } + + public void AppendQuery(string name, string value, bool escape) + { + if (PathAndQuery.Length == _pathLength) + { + PathAndQuery.Append('?'); + } + if (PathAndQuery.Length > _pathLength && PathAndQuery[PathAndQuery.Length - 1] != '?') + { + PathAndQuery.Append('&'); + } + if (escape) + { + value = Uri.EscapeDataString(value); + } + PathAndQuery.Append(name); + PathAndQuery.Append('='); + PathAndQuery.Append(value); + } + + public void AppendQuery(string name, bool value, bool escape = false) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, float value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, DateTimeOffset value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); + + public void AppendQuery(string name, TimeSpan value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); + + public void AppendQuery(string name, double value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, decimal value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, int value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, long value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, TimeSpan value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, byte[] value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); + + public void AppendQuery(string name, Guid value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + + public void UpdateQuery(string name, string value) + { + if (PathAndQuery.Length == _pathLength) + { + AppendQuery(name, value, false); + } + else + { + int queryStartIndex = _pathLength + 1; + string searchPattern = name + "="; + string queryString = PathAndQuery.ToString(queryStartIndex, PathAndQuery.Length - queryStartIndex); + int paramStartIndex = -1; + if (queryString.StartsWith(searchPattern)) + { + paramStartIndex = 0; + } + if (paramStartIndex == -1) + { + int prefixedIndex = queryString.IndexOf("&" + searchPattern); + if (prefixedIndex >= 0) + { + paramStartIndex = prefixedIndex + 1; + } + } + if (paramStartIndex >= 0) + { + int valueStartIndex = paramStartIndex + searchPattern.Length; + int valueEndIndex = queryString.IndexOf('&', valueStartIndex); + if (valueEndIndex == -1) + { + valueEndIndex = queryString.Length; + } + int globalStart = queryStartIndex + valueStartIndex; + int globalEnd = queryStartIndex + valueEndIndex; + PathAndQuery.Remove(globalStart, globalEnd - globalStart); + PathAndQuery.Insert(globalStart, value); + } + else + { + AppendQuery(name, value, false); + } + } + } + + public Uri ToUri() + { + UriBuilder.Path = PathAndQuery.ToString(0, _pathLength); + if (PathAndQuery.Length > _pathLength) + { + UriBuilder.Query = PathAndQuery.ToString(_pathLength + 1, PathAndQuery.Length - _pathLength - 1); + } + if (PathAndQuery.Length == _pathLength) + { + UriBuilder.Query = ""; + } + return UriBuilder.Uri; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenMemberAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 00000000000..044dfe314c5 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSerializationAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 00000000000..aedb8b359b8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSuppressAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 00000000000..601ded913ab --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,26 @@ +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenTypeAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 00000000000..d7b56bdccdf --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ErrorResult.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 00000000000..1cfd4bc3bb7 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + internal partial class ErrorResult : ClientResult + { + private readonly PipelineResponse _response; + private readonly ClientResultException _exception; + + public ErrorResult(PipelineResponse response, ClientResultException exception) : base(default, response) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ModelSerializationExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 00000000000..b1dab60c152 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,265 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Runtime.InteropServices; +using System.Text.Json; + +namespace _Type.Union +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + Dictionary dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + List list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + public static BinaryData GetUtf8Bytes(this JsonElement element) + { +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/SerializationFormat.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 00000000000..2957f681312 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +namespace _Type.Union +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/TypeFormatters.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 00000000000..90ca993c473 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,178 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace _Type.Union +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.RestClient.cs new file mode 100644 index 00000000000..3b5137e244a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class IntsOnly + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/ints-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/ints-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.cs index d9e64843d11..1e67195b62b 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.cs @@ -10,28 +10,140 @@ namespace _Type.Union { + /// Describe union of integer 1 | 2 | 3. public partial class IntsOnly { - protected IntsOnly() => throw null; + private readonly Uri _endpoint; - internal IntsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of IntsOnly for mocking. + protected IntsOnly() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of IntsOnly. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal IntsOnly(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse3)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse3)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(GetResponseProp2 prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(GetResponseProp2 prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Send(GetResponseProp2 prop, CancellationToken cancellationToken = default) + { + SendRequest3 spreadModel = new SendRequest3(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task SendAsync(GetResponseProp2 prop, CancellationToken cancellationToken = default) + { + SendRequest3 spreadModel = new SendRequest3(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.RestClient.cs new file mode 100644 index 00000000000..b203b0b34e9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class MixedLiterals + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/mixed-literals", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/mixed-literals", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.cs index 7ee7a6ee49c..3b61e3a399b 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.cs @@ -10,28 +10,146 @@ namespace _Type.Union { + /// Describe union of floats "a" | 2 | 3.3. public partial class MixedLiterals { - protected MixedLiterals() => throw null; + private readonly Uri _endpoint; - internal MixedLiterals(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of MixedLiterals for mocking. + protected MixedLiterals() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of MixedLiterals. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal MixedLiterals(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse8)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse8)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(MixedLiteralsCases prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(MixedLiteralsCases prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Send(MixedLiteralsCases prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest8 spreadModel = new SendRequest8(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task SendAsync(MixedLiteralsCases prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest8 spreadModel = new SendRequest8(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.RestClient.cs new file mode 100644 index 00000000000..3f91f0b4dc2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class MixedTypes + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/mixed-types", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/mixed-types", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.cs index b7ae1cff2e4..942f8daa1d3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.cs @@ -10,28 +10,146 @@ namespace _Type.Union { + /// Describe union of floats "a" | 2 | 3.3. public partial class MixedTypes { - protected MixedTypes() => throw null; + private readonly Uri _endpoint; - internal MixedTypes(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of MixedTypes for mocking. + protected MixedTypes() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of MixedTypes. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal MixedTypes(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse9)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse9)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(MixedTypesCases prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(MixedTypesCases prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Send(MixedTypesCases prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest9 spreadModel = new SendRequest9(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task SendAsync(MixedTypesCases prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest9 spreadModel = new SendRequest9(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.Serialization.cs index 376f80256c6..674b11c943e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.Serialization.cs @@ -4,30 +4,136 @@ using System; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The Cat. public partial class Cat : IJsonModel { - internal Cat() => throw null; + /// Initializes a new instance of for deserialization. + internal Cat() + { + } - protected virtual Cat PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Cat PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeCat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Cat)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(Cat)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - Cat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + Cat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Cat)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - Cat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + Cat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual Cat JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Cat JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Cat)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCat(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Cat DeserializeCat(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Cat(name, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.cs index fe5cca7c7c0..5ad0b393d9b 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.cs @@ -2,16 +2,37 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The Cat. public partial class Cat { - public Cat(string name) => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// is null. + public Cat(string name) + { + Argument.AssertNotNull(name, nameof(name)); - public string Name + Name = name; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal Cat(string name, IDictionary additionalBinaryDataProperties) { - get => throw null; - set => throw null; + Name = name; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } + + /// Gets or sets the Name. + public string Name { get; set; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.Serialization.cs index 1391a71d84b..8fcd3193ed5 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.Serialization.cs @@ -4,30 +4,136 @@ using System; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The Dog. public partial class Dog : IJsonModel { - internal Dog() => throw null; + /// Initializes a new instance of for deserialization. + internal Dog() + { + } - protected virtual Dog PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Dog PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDog(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Dog)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(Dog)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - Dog IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + Dog IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Dog)} does not support writing '{format}' format."); + } + writer.WritePropertyName("bark"u8); + writer.WriteStringValue(Bark); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - Dog IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + Dog IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual Dog JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Dog JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Dog)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDog(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Dog DeserializeDog(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string bark = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("bark"u8)) + { + bark = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Dog(bark, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.cs index 1754f6b7635..a00fd9aa254 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.cs @@ -2,16 +2,37 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The Dog. public partial class Dog { - public Dog(string bark) => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// is null. + public Dog(string bark) + { + Argument.AssertNotNull(bark, nameof(bark)); - public string Bark + Bark = bark; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal Dog(string bark, IDictionary additionalBinaryDataProperties) { - get => throw null; - set => throw null; + Bark = bark; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } + + /// Gets or sets the Bark. + public string Bark { get; set; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.Serialization.cs index ff9d24c1364..7f5a11d2f92 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.Serialization.cs @@ -4,30 +4,144 @@ using System; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The EnumsOnlyCases. public partial class EnumsOnlyCases : IJsonModel { - internal EnumsOnlyCases() => throw null; + /// Initializes a new instance of for deserialization. + internal EnumsOnlyCases() + { + } - protected virtual EnumsOnlyCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EnumsOnlyCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEnumsOnlyCases(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EnumsOnlyCases)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(EnumsOnlyCases)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - EnumsOnlyCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + EnumsOnlyCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnumsOnlyCases)} does not support writing '{format}' format."); + } + writer.WritePropertyName("lr"u8); + writer.WriteStringValue(Lr.ToSerialString()); + writer.WritePropertyName("ud"u8); + writer.WriteStringValue(Ud.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - EnumsOnlyCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + EnumsOnlyCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual EnumsOnlyCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EnumsOnlyCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EnumsOnlyCases)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEnumsOnlyCases(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EnumsOnlyCases DeserializeEnumsOnlyCases(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EnumsOnlyCasesLr lr = default; + EnumsOnlyCasesUd ud = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("lr"u8)) + { + lr = prop.Value.GetString().ToEnumsOnlyCasesLr(); + continue; + } + if (prop.NameEquals("ud"u8)) + { + ud = prop.Value.GetString().ToEnumsOnlyCasesUd(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EnumsOnlyCases(lr, ud, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.cs index f70f5f7d7b4..6fbc23ffd72 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.cs @@ -2,22 +2,41 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The EnumsOnlyCases. public partial class EnumsOnlyCases { - public EnumsOnlyCases(EnumsOnlyCasesLr lr, EnumsOnlyCasesUd ud) => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; - public EnumsOnlyCasesLr Lr + /// Initializes a new instance of . + /// This should be receive/send the left variant. + /// This should be receive/send the up variant. + public EnumsOnlyCases(EnumsOnlyCasesLr lr, EnumsOnlyCasesUd ud) { - get => throw null; - set => throw null; + Lr = lr; + Ud = ud; } - public EnumsOnlyCasesUd Ud + /// Initializes a new instance of . + /// This should be receive/send the left variant. + /// This should be receive/send the up variant. + /// Keeps track of any properties unknown to the library. + internal EnumsOnlyCases(EnumsOnlyCasesLr lr, EnumsOnlyCasesUd ud, IDictionary additionalBinaryDataProperties) { - get => throw null; - set => throw null; + Lr = lr; + Ud = ud; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } + + /// This should be receive/send the left variant. + public EnumsOnlyCasesLr Lr { get; set; } + + /// This should be receive/send the up variant. + public EnumsOnlyCasesUd Ud { get; set; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.Serialization.cs new file mode 100644 index 00000000000..d7f98bb901a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.Serialization.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; + +namespace _Type.Union +{ + internal static partial class EnumsOnlyCasesLrExtensions + { + /// The value to serialize. + public static string ToSerialString(this EnumsOnlyCasesLr value) => value switch + { + EnumsOnlyCasesLr.Left => "left", + EnumsOnlyCasesLr.Right => "right", + EnumsOnlyCasesLr.Up => "up", + EnumsOnlyCasesLr.Down => "down", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EnumsOnlyCasesLr value.") + }; + + /// The value to deserialize. + public static EnumsOnlyCasesLr ToEnumsOnlyCasesLr(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "left")) + { + return EnumsOnlyCasesLr.Left; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "right")) + { + return EnumsOnlyCasesLr.Right; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "up")) + { + return EnumsOnlyCasesLr.Up; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "down")) + { + return EnumsOnlyCasesLr.Down; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EnumsOnlyCasesLr value."); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.cs index 27cb65862f7..24207fe0d94 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.cs @@ -4,6 +4,7 @@ namespace _Type.Union { + /// public enum EnumsOnlyCasesLr { /// Left. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.Serialization.cs new file mode 100644 index 00000000000..ee74820e099 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; + +namespace _Type.Union +{ + internal static partial class EnumsOnlyCasesUdExtensions + { + /// The value to serialize. + public static string ToSerialString(this EnumsOnlyCasesUd value) => value switch + { + EnumsOnlyCasesUd.Up => "up", + EnumsOnlyCasesUd.Down => "down", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EnumsOnlyCasesUd value.") + }; + + /// The value to deserialize. + public static EnumsOnlyCasesUd ToEnumsOnlyCasesUd(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "up")) + { + return EnumsOnlyCasesUd.Up; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "down")) + { + return EnumsOnlyCasesUd.Down; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EnumsOnlyCasesUd value."); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.cs index e58e353aae8..a8a4ad78173 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.cs @@ -4,6 +4,7 @@ namespace _Type.Union { + /// public enum EnumsOnlyCasesUd { /// Up. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.Serialization.cs index 9d2744ca516..27cde67bb98 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.Serialization.cs @@ -5,32 +5,144 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse. public partial class GetResponse : IJsonModel { - internal GetResponse() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse() + { + } - protected virtual GetResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteStringValue(Prop.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse DeserializeGetResponse(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GetResponseProp prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = prop0.Value.GetString().ToGetResponseProp(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.cs index 74aff777d1c..b3cd16348ea 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.cs @@ -2,10 +2,34 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The GetResponse. public partial class GetResponse { - public GetResponseProp Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse(GetResponseProp prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse(GetResponseProp prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public GetResponseProp Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.Serialization.cs index a8892f65c6f..0b78fab41f3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.Serialization.cs @@ -5,32 +5,144 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse1. public partial class GetResponse1 : IJsonModel { - internal GetResponse1() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse1() + { + } - protected virtual GetResponse1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse1(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse1)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse1)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse1(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse1(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse1(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse1)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteStringValue(Prop.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse1)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse1(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse1 DeserializeGetResponse1(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GetResponseProp1 prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = new GetResponseProp1(prop0.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse1(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.cs index 7477f04cb55..f1692689b4f 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.cs @@ -2,10 +2,34 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The GetResponse1. public partial class GetResponse1 { - public GetResponseProp1 Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse1(GetResponseProp1 prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse1(GetResponseProp1 prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public GetResponseProp1 Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.Serialization.cs index 95f5cd6f4f6..005b56521e9 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.Serialization.cs @@ -5,32 +5,144 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse2. public partial class GetResponse2 : IJsonModel { - internal GetResponse2() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse2() + { + } - protected virtual GetResponse2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse2(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse2)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse2)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse2(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse2(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse2(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse2)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteStringValue(Prop.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse2)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse2(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse2 DeserializeGetResponse2(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StringExtensibleNamedUnion prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = new StringExtensibleNamedUnion(prop0.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse2(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.cs index 780d585e5a6..d088b4846e4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.cs @@ -2,10 +2,34 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The GetResponse2. public partial class GetResponse2 { - public StringExtensibleNamedUnion Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse2(StringExtensibleNamedUnion prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse2(StringExtensibleNamedUnion prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public StringExtensibleNamedUnion Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.Serialization.cs index 9b5d45f0680..e73c98ad822 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.Serialization.cs @@ -5,32 +5,144 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse3. public partial class GetResponse3 : IJsonModel { - internal GetResponse3() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse3() + { + } - protected virtual GetResponse3 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse3 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse3(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse3)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse3)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse3(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse3(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse3(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse3)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteNumberValue((int)Prop); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse3 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse3 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse3)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse3(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse3 DeserializeGetResponse3(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GetResponseProp2 prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = prop0.Value.GetInt32().ToGetResponseProp2(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse3(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.cs index 628db49f452..9468d7c9d89 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.cs @@ -2,10 +2,34 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The GetResponse3. public partial class GetResponse3 { - public GetResponseProp2 Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse3(GetResponseProp2 prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse3(GetResponseProp2 prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public GetResponseProp2 Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.Serialization.cs index e33960ba0be..0797692888b 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.Serialization.cs @@ -5,32 +5,144 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse4. public partial class GetResponse4 : IJsonModel { - internal GetResponse4() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse4() + { + } - protected virtual GetResponse4 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse4 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse4(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse4)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse4)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse4 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse4 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse4(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse4(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse4(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse4)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteNumberValue(Prop.ToSerialSingle()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse4 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse4 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse4 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse4 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse4)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse4(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse4 DeserializeGetResponse4(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GetResponseProp3 prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = prop0.Value.GetSingle().ToGetResponseProp3(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse4(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.cs index 98a7b15d523..5894f1059eb 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.cs @@ -2,10 +2,34 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The GetResponse4. public partial class GetResponse4 { - public GetResponseProp3 Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse4(GetResponseProp3 prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse4(GetResponseProp3 prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public GetResponseProp3 Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.Serialization.cs index 9ef18e2e1e0..ec7706f6134 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.Serialization.cs @@ -5,32 +5,151 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse5. public partial class GetResponse5 : IJsonModel { - internal GetResponse5() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse5() + { + } - protected virtual GetResponse5 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse5 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse5(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse5)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse5)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse5 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse5 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse5(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse5(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse5(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse5)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Prop); +#else + using (JsonDocument document = JsonDocument.Parse(Prop)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse5 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse5 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse5 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse5 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse5)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse5(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse5 DeserializeGetResponse5(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = BinaryData.FromString(prop0.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse5(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.cs index caeec0431b1..04e4c65f91e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.cs @@ -3,11 +3,72 @@ #nullable disable using System; +using System.Collections.Generic; +using System.Text.Json; namespace _Type.Union { + /// The GetResponse5. public partial class GetResponse5 { - public BinaryData Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse5(BinaryData prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse5(BinaryData prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// Gets the Prop. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.Serialization.cs index d8d40f051ac..b7713be5cfe 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.Serialization.cs @@ -5,32 +5,144 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse6. public partial class GetResponse6 : IJsonModel { - internal GetResponse6() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse6() + { + } - protected virtual GetResponse6 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse6 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse6(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse6)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse6)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse6 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse6 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse6(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse6(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse6(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse6)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteObjectValue(Prop, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse6 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse6 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse6 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse6 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse6)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse6(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse6 DeserializeGetResponse6(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EnumsOnlyCases prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = EnumsOnlyCases.DeserializeEnumsOnlyCases(prop0.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse6(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.cs index f07f02a9b43..7dde2ad490a 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.cs @@ -2,10 +2,34 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The GetResponse6. public partial class GetResponse6 { - public EnumsOnlyCases Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse6(EnumsOnlyCases prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse6(EnumsOnlyCases prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public EnumsOnlyCases Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.Serialization.cs index 7fef9678a03..ba7a55b7e0f 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.Serialization.cs @@ -5,32 +5,144 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse7. public partial class GetResponse7 : IJsonModel { - internal GetResponse7() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse7() + { + } - protected virtual GetResponse7 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse7 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse7(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse7)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse7)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse7 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse7 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse7(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse7(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse7(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse7)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteObjectValue(Prop, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse7 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse7 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse7 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse7 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse7)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse7(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse7 DeserializeGetResponse7(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StringAndArrayCases prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = StringAndArrayCases.DeserializeStringAndArrayCases(prop0.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse7(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.cs index a96c8ca6b4d..3b1e3983314 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.cs @@ -2,10 +2,34 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The GetResponse7. public partial class GetResponse7 { - public StringAndArrayCases Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse7(StringAndArrayCases prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse7(StringAndArrayCases prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public StringAndArrayCases Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.Serialization.cs index 85c826e7d9e..556119b5fbd 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.Serialization.cs @@ -5,32 +5,144 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse8. public partial class GetResponse8 : IJsonModel { - internal GetResponse8() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse8() + { + } - protected virtual GetResponse8 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse8 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse8(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse8)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse8)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse8 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse8 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse8(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse8(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse8(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse8)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteObjectValue(Prop, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse8 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse8 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse8 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse8 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse8)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse8(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse8 DeserializeGetResponse8(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MixedLiteralsCases prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = MixedLiteralsCases.DeserializeMixedLiteralsCases(prop0.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse8(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.cs index d98e8de1c81..87d5cf38391 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.cs @@ -2,10 +2,34 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The GetResponse8. public partial class GetResponse8 { - public MixedLiteralsCases Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse8(MixedLiteralsCases prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse8(MixedLiteralsCases prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public MixedLiteralsCases Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.Serialization.cs index c6c7a43fdf1..7660e4a3c66 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.Serialization.cs @@ -5,32 +5,144 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The GetResponse9. public partial class GetResponse9 : IJsonModel { - internal GetResponse9() => throw null; + /// Initializes a new instance of for deserialization. + internal GetResponse9() + { + } - protected virtual GetResponse9 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetResponse9 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetResponse9(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetResponse9)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(GetResponse9)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - GetResponse9 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + GetResponse9 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - public static explicit operator GetResponse9(ClientResult result) => throw null; + /// The to deserialize the from. + public static explicit operator GetResponse9(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetResponse9(document.RootElement, ModelSerializationExtensions.WireOptions); + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse9)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteObjectValue(Prop, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - GetResponse9 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + GetResponse9 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual GetResponse9 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GetResponse9 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetResponse9)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetResponse9(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GetResponse9 DeserializeGetResponse9(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MixedTypesCases prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = MixedTypesCases.DeserializeMixedTypesCases(prop0.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new GetResponse9(prop, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.cs index 3edebb7b4d0..ff1364d442d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.cs @@ -2,10 +2,34 @@ #nullable disable +using System; +using System.Collections.Generic; + namespace _Type.Union { + /// The GetResponse9. public partial class GetResponse9 { - public MixedTypesCases Prop => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal GetResponse9(MixedTypesCases prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal GetResponse9(MixedTypesCases prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public MixedTypesCases Prop { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.Serialization.cs new file mode 100644 index 00000000000..f4b1a4e0a7d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.Serialization.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; + +namespace _Type.Union +{ + internal static partial class GetResponsePropExtensions + { + /// The value to serialize. + public static string ToSerialString(this GetResponseProp value) => value switch + { + GetResponseProp.A => "a", + GetResponseProp.B => "b", + GetResponseProp.C => "c", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp value.") + }; + + /// The value to deserialize. + public static GetResponseProp ToGetResponseProp(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "a")) + { + return GetResponseProp.A; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "b")) + { + return GetResponseProp.B; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "c")) + { + return GetResponseProp.C; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp value."); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.cs index 2440b719c44..3fa6e8be673 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.cs @@ -4,6 +4,7 @@ namespace _Type.Union { + /// public enum GetResponseProp { /// A. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp1.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp1.cs index 9260592f572..ddc1d67d79c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp1.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp1.cs @@ -7,30 +7,59 @@ namespace _Type.Union { + /// public readonly partial struct GetResponseProp1 : IEquatable { - public GetResponseProp1(string value) => throw null; + private readonly string _value; + private const string BValue = "b"; + private const string CValue = "c"; - public static GetResponseProp1 B => throw null; + /// Initializes a new instance of . + /// The value. + /// is null. + public GetResponseProp1(string value) + { + Argument.AssertNotNull(value, nameof(value)); - public static GetResponseProp1 C => throw null; + _value = value; + } - public static bool operator ==(GetResponseProp1 left, GetResponseProp1 right) => throw null; + /// Gets the B. + public static GetResponseProp1 B { get; } = new GetResponseProp1(BValue); - public static bool operator !=(GetResponseProp1 left, GetResponseProp1 right) => throw null; + /// Gets the C. + public static GetResponseProp1 C { get; } = new GetResponseProp1(CValue); - public static implicit operator GetResponseProp1(string value) => throw null; + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(GetResponseProp1 left, GetResponseProp1 right) => left.Equals(right); - public static implicit operator GetResponseProp1?(string value) => throw null; + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(GetResponseProp1 left, GetResponseProp1 right) => !left.Equals(right); + /// Converts a string to a . + /// The value. + public static implicit operator GetResponseProp1(string value) => new GetResponseProp1(value); + + /// Converts a string to a . + /// The value. + public static implicit operator GetResponseProp1?(string value) => value == null ? null : new GetResponseProp1(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => throw null; + public override bool Equals(object obj) => obj is GetResponseProp1 other && Equals(other); - public bool Equals(GetResponseProp1 other) => throw null; + /// + public bool Equals(GetResponseProp1 other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + /// [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => throw null; + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => throw null; + /// + public override string ToString() => _value; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.Serialization.cs new file mode 100644 index 00000000000..2398ba89264 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.Serialization.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +using System; + +namespace _Type.Union +{ + internal static partial class GetResponseProp2Extensions + { + /// The value to deserialize. + public static GetResponseProp2 ToGetResponseProp2(this int value) + { + if (value == 1) + { + return GetResponseProp2._1; + } + if (value == 2) + { + return GetResponseProp2._2; + } + if (value == 3) + { + return GetResponseProp2._3; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp2 value."); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.cs index f0738ab58e4..36a40c30d13 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.cs @@ -4,6 +4,7 @@ namespace _Type.Union { + /// public enum GetResponseProp2 { /// _1. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.Serialization.cs new file mode 100644 index 00000000000..b365a689de4 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.Serialization.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; + +namespace _Type.Union +{ + internal static partial class GetResponseProp3Extensions + { + /// The value to serialize. + public static float ToSerialSingle(this GetResponseProp3 value) => value switch + { + GetResponseProp3._11 => 1.1F, + GetResponseProp3._22 => 2.2F, + GetResponseProp3._33 => 3.3F, + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp3 value.") + }; + + /// The value to deserialize. + public static GetResponseProp3 ToGetResponseProp3(this float value) + { + if (value == 1.1F) + { + return GetResponseProp3._11; + } + if (value == 2.2F) + { + return GetResponseProp3._22; + } + if (value == 3.3F) + { + return GetResponseProp3._33; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp3 value."); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.cs index b5820868a73..f33a94513de 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.cs @@ -4,6 +4,7 @@ namespace _Type.Union { + /// public enum GetResponseProp3 { /// _11. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.Serialization.cs index 8115f8b6175..4b1b23f5e7d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.Serialization.cs @@ -4,30 +4,188 @@ using System; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The MixedLiteralsCases. public partial class MixedLiteralsCases : IJsonModel { - internal MixedLiteralsCases() => throw null; + /// Initializes a new instance of for deserialization. + internal MixedLiteralsCases() + { + } - protected virtual MixedLiteralsCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MixedLiteralsCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMixedLiteralsCases(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MixedLiteralsCases)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(MixedLiteralsCases)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - MixedLiteralsCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + MixedLiteralsCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MixedLiteralsCases)} does not support writing '{format}' format."); + } + writer.WritePropertyName("stringLiteral"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(StringLiteral); +#else + using (JsonDocument document = JsonDocument.Parse(StringLiteral)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("intLiteral"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(IntLiteral); +#else + using (JsonDocument document = JsonDocument.Parse(IntLiteral)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("floatLiteral"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(FloatLiteral); +#else + using (JsonDocument document = JsonDocument.Parse(FloatLiteral)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("booleanLiteral"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(BooleanLiteral); +#else + using (JsonDocument document = JsonDocument.Parse(BooleanLiteral)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - MixedLiteralsCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + MixedLiteralsCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual MixedLiteralsCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MixedLiteralsCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MixedLiteralsCases)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMixedLiteralsCases(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MixedLiteralsCases DeserializeMixedLiteralsCases(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData stringLiteral = default; + BinaryData intLiteral = default; + BinaryData floatLiteral = default; + BinaryData booleanLiteral = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("stringLiteral"u8)) + { + stringLiteral = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("intLiteral"u8)) + { + intLiteral = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("floatLiteral"u8)) + { + floatLiteral = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("booleanLiteral"u8)) + { + booleanLiteral = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MixedLiteralsCases(stringLiteral, intLiteral, floatLiteral, booleanLiteral, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.cs index 3861282b549..b608c06e983 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.cs @@ -3,35 +3,237 @@ #nullable disable using System; +using System.Collections.Generic; +using System.Text.Json; namespace _Type.Union { + /// The MixedLiteralsCases. public partial class MixedLiteralsCases { - public MixedLiteralsCases(BinaryData stringLiteral, BinaryData intLiteral, BinaryData floatLiteral, BinaryData booleanLiteral) => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; - public BinaryData StringLiteral + /// Initializes a new instance of . + /// This should be receive/send the "a" variant. + /// This should be receive/send the 2 variant. + /// This should be receive/send the 3.3 variant. + /// This should be receive/send the true variant. + /// , , or is null. + public MixedLiteralsCases(BinaryData stringLiteral, BinaryData intLiteral, BinaryData floatLiteral, BinaryData booleanLiteral) { - get => throw null; - set => throw null; - } + Argument.AssertNotNull(stringLiteral, nameof(stringLiteral)); + Argument.AssertNotNull(intLiteral, nameof(intLiteral)); + Argument.AssertNotNull(floatLiteral, nameof(floatLiteral)); + Argument.AssertNotNull(booleanLiteral, nameof(booleanLiteral)); - public BinaryData IntLiteral - { - get => throw null; - set => throw null; + StringLiteral = stringLiteral; + IntLiteral = intLiteral; + FloatLiteral = floatLiteral; + BooleanLiteral = booleanLiteral; } - public BinaryData FloatLiteral + /// Initializes a new instance of . + /// This should be receive/send the "a" variant. + /// This should be receive/send the 2 variant. + /// This should be receive/send the 3.3 variant. + /// This should be receive/send the true variant. + /// Keeps track of any properties unknown to the library. + internal MixedLiteralsCases(BinaryData stringLiteral, BinaryData intLiteral, BinaryData floatLiteral, BinaryData booleanLiteral, IDictionary additionalBinaryDataProperties) { - get => throw null; - set => throw null; + StringLiteral = stringLiteral; + IntLiteral = intLiteral; + FloatLiteral = floatLiteral; + BooleanLiteral = booleanLiteral; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public BinaryData BooleanLiteral - { - get => throw null; - set => throw null; - } + /// + /// This should be receive/send the "a" variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// "a". + /// + /// + /// 2. + /// + /// + /// 3.3. + /// + /// + /// True. + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData StringLiteral { get; set; } + + /// + /// This should be receive/send the 2 variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// "a". + /// + /// + /// 2. + /// + /// + /// 3.3. + /// + /// + /// True. + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData IntLiteral { get; set; } + + /// + /// This should be receive/send the 3.3 variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// "a". + /// + /// + /// 2. + /// + /// + /// 3.3. + /// + /// + /// True. + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData FloatLiteral { get; set; } + + /// + /// This should be receive/send the true variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// "a". + /// + /// + /// 2. + /// + /// + /// 3.3. + /// + /// + /// True. + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData BooleanLiteral { get; set; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.Serialization.cs index f2ffbc26a5b..a0bcdb74419 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.Serialization.cs @@ -4,30 +4,231 @@ using System; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The MixedTypesCases. public partial class MixedTypesCases : IJsonModel { - internal MixedTypesCases() => throw null; + /// Initializes a new instance of for deserialization. + internal MixedTypesCases() + { + } - protected virtual MixedTypesCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MixedTypesCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMixedTypesCases(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MixedTypesCases)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(MixedTypesCases)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - MixedTypesCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + MixedTypesCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MixedTypesCases)} does not support writing '{format}' format."); + } + writer.WritePropertyName("model"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Model); +#else + using (JsonDocument document = JsonDocument.Parse(Model)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("literal"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Literal); +#else + using (JsonDocument document = JsonDocument.Parse(Literal)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("int"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Int); +#else + using (JsonDocument document = JsonDocument.Parse(Int)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("boolean"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Boolean); +#else + using (JsonDocument document = JsonDocument.Parse(Boolean)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("array"u8); + writer.WriteStartArray(); + foreach (BinaryData item in Array) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item); +#else + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - MixedTypesCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + MixedTypesCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual MixedTypesCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MixedTypesCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MixedTypesCases)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMixedTypesCases(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MixedTypesCases DeserializeMixedTypesCases(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData model = default; + BinaryData literal = default; + BinaryData @int = default; + BinaryData boolean = default; + IList array = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("model"u8)) + { + model = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("literal"u8)) + { + literal = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("int"u8)) + { + @int = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("boolean"u8)) + { + boolean = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("array"u8)) + { + List array0 = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array0.Add(null); + } + else + { + array0.Add(BinaryData.FromString(item.GetRawText())); + } + } + array = array0; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MixedTypesCases( + model, + literal, + @int, + boolean, + array, + additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.cs index 7d4dfca9317..a39ed7f3ae7 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.cs @@ -4,37 +4,289 @@ using System; using System.Collections.Generic; +using System.Linq; +using System.Text.Json; namespace _Type.Union { + /// The MixedTypesCases. public partial class MixedTypesCases { - public MixedTypesCases(BinaryData model, BinaryData literal, BinaryData @int, BinaryData boolean, IEnumerable array) => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; - public BinaryData Model + /// Initializes a new instance of . + /// This should be receive/send the Cat variant. + /// This should be receive/send the "a" variant. + /// This should be receive/send the int variant. + /// This should be receive/send the boolean variant. + /// This should be receive/send 4 element with Cat, "a", int, and boolean. + /// , , , or is null. + public MixedTypesCases(BinaryData model, BinaryData literal, BinaryData @int, BinaryData boolean, IEnumerable array) { - get => throw null; - set => throw null; - } + Argument.AssertNotNull(model, nameof(model)); + Argument.AssertNotNull(literal, nameof(literal)); + Argument.AssertNotNull(@int, nameof(@int)); + Argument.AssertNotNull(boolean, nameof(boolean)); + Argument.AssertNotNull(array, nameof(array)); - public BinaryData Literal - { - get => throw null; - set => throw null; + Model = model; + Literal = literal; + Int = @int; + Boolean = boolean; + Array = array.ToList(); } - public BinaryData Int + /// Initializes a new instance of . + /// This should be receive/send the Cat variant. + /// This should be receive/send the "a" variant. + /// This should be receive/send the int variant. + /// This should be receive/send the boolean variant. + /// This should be receive/send 4 element with Cat, "a", int, and boolean. + /// Keeps track of any properties unknown to the library. + internal MixedTypesCases(BinaryData model, BinaryData literal, BinaryData @int, BinaryData boolean, IList array, IDictionary additionalBinaryDataProperties) { - get => throw null; - set => throw null; + Model = model; + Literal = literal; + Int = @int; + Boolean = boolean; + Array = array; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - public BinaryData Boolean - { - get => throw null; - set => throw null; - } + /// + /// This should be receive/send the Cat variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// "a". + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData Model { get; set; } + + /// + /// This should be receive/send the "a" variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// "a". + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData Literal { get; set; } + + /// + /// This should be receive/send the int variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// "a". + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData Int { get; set; } + + /// + /// This should be receive/send the boolean variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// "a". + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData Boolean { get; set; } - public IList Array => throw null; + /// + /// This should be receive/send 4 element with Cat, "a", int, and boolean + /// To assign an object to the element of this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// "a". + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IList Array { get; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.Serialization.cs new file mode 100644 index 00000000000..37f9fdc0671 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest. + internal partial class SendRequest : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest sendRequest) + { + if (sendRequest == null) + { + return null; + } + return BinaryContent.Create(sendRequest, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteStringValue(Prop.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest DeserializeSendRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GetResponseProp prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = prop0.Value.GetString().ToGetResponseProp(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.cs new file mode 100644 index 00000000000..167e9538d9c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Union +{ + /// The SendRequest. + internal partial class SendRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest(GetResponseProp prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest(GetResponseProp prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public GetResponseProp Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.Serialization.cs new file mode 100644 index 00000000000..5dc71eac6e3 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest1. + internal partial class SendRequest1 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest1() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest1(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest1)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest1)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest1 sendRequest1) + { + if (sendRequest1 == null) + { + return null; + } + return BinaryContent.Create(sendRequest1, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest1)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteStringValue(Prop.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest1)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest1(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest1 DeserializeSendRequest1(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GetResponseProp1 prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = new GetResponseProp1(prop0.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest1(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.cs new file mode 100644 index 00000000000..991287c2c5f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Union +{ + /// The SendRequest1. + internal partial class SendRequest1 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest1(GetResponseProp1 prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest1(GetResponseProp1 prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public GetResponseProp1 Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.Serialization.cs new file mode 100644 index 00000000000..d50da670138 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest2. + internal partial class SendRequest2 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest2() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest2(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest2)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest2)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest2 sendRequest2) + { + if (sendRequest2 == null) + { + return null; + } + return BinaryContent.Create(sendRequest2, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest2)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteStringValue(Prop.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest2)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest2(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest2 DeserializeSendRequest2(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StringExtensibleNamedUnion prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = new StringExtensibleNamedUnion(prop0.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest2(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.cs new file mode 100644 index 00000000000..8d937641568 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Union +{ + /// The SendRequest2. + internal partial class SendRequest2 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest2(StringExtensibleNamedUnion prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest2(StringExtensibleNamedUnion prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public StringExtensibleNamedUnion Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.Serialization.cs new file mode 100644 index 00000000000..02a6cab4a44 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest3. + internal partial class SendRequest3 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest3() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest3 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest3(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest3)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest3)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest3 sendRequest3) + { + if (sendRequest3 == null) + { + return null; + } + return BinaryContent.Create(sendRequest3, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest3)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteNumberValue((int)Prop); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest3 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest3)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest3(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest3 DeserializeSendRequest3(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GetResponseProp2 prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = prop0.Value.GetInt32().ToGetResponseProp2(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest3(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.cs new file mode 100644 index 00000000000..ffca6bbe029 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Union +{ + /// The SendRequest3. + internal partial class SendRequest3 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest3(GetResponseProp2 prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest3(GetResponseProp2 prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public GetResponseProp2 Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.Serialization.cs new file mode 100644 index 00000000000..e0e3c910fc7 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest4. + internal partial class SendRequest4 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest4() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest4 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest4(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest4)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest4)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest4 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest4 sendRequest4) + { + if (sendRequest4 == null) + { + return null; + } + return BinaryContent.Create(sendRequest4, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest4)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteNumberValue(Prop.ToSerialSingle()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest4 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest4 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest4)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest4(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest4 DeserializeSendRequest4(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GetResponseProp3 prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = prop0.Value.GetSingle().ToGetResponseProp3(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest4(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.cs new file mode 100644 index 00000000000..fd0ce88bd08 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Union +{ + /// The SendRequest4. + internal partial class SendRequest4 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest4(GetResponseProp3 prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest4(GetResponseProp3 prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public GetResponseProp3 Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.Serialization.cs new file mode 100644 index 00000000000..269b595553e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.Serialization.cs @@ -0,0 +1,157 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest5. + internal partial class SendRequest5 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest5() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest5 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest5(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest5)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest5)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest5 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest5 sendRequest5) + { + if (sendRequest5 == null) + { + return null; + } + return BinaryContent.Create(sendRequest5, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest5)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Prop); +#else + using (JsonDocument document = JsonDocument.Parse(Prop)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest5 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest5 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest5)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest5(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest5 DeserializeSendRequest5(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = BinaryData.FromString(prop0.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest5(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.cs new file mode 100644 index 00000000000..80c0ab8c08b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.cs @@ -0,0 +1,74 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest5. + internal partial class SendRequest5 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest5(BinaryData prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest5(BinaryData prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// Gets the Prop. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.Serialization.cs new file mode 100644 index 00000000000..86cc6ac0d75 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest6. + internal partial class SendRequest6 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest6() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest6 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest6(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest6)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest6)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest6 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest6 sendRequest6) + { + if (sendRequest6 == null) + { + return null; + } + return BinaryContent.Create(sendRequest6, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest6)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteObjectValue(Prop, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest6 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest6 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest6)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest6(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest6 DeserializeSendRequest6(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EnumsOnlyCases prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = EnumsOnlyCases.DeserializeEnumsOnlyCases(prop0.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest6(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.cs new file mode 100644 index 00000000000..6d9841ad267 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Union +{ + /// The SendRequest6. + internal partial class SendRequest6 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest6(EnumsOnlyCases prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest6(EnumsOnlyCases prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public EnumsOnlyCases Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.Serialization.cs new file mode 100644 index 00000000000..dc694486107 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest7. + internal partial class SendRequest7 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest7() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest7 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest7(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest7)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest7)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest7 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest7 sendRequest7) + { + if (sendRequest7 == null) + { + return null; + } + return BinaryContent.Create(sendRequest7, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest7)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteObjectValue(Prop, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest7 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest7 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest7)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest7(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest7 DeserializeSendRequest7(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StringAndArrayCases prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = StringAndArrayCases.DeserializeStringAndArrayCases(prop0.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest7(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.cs new file mode 100644 index 00000000000..f746cfb6b13 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Union +{ + /// The SendRequest7. + internal partial class SendRequest7 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest7(StringAndArrayCases prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest7(StringAndArrayCases prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public StringAndArrayCases Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.Serialization.cs new file mode 100644 index 00000000000..9bcf588a6ab --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest8. + internal partial class SendRequest8 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest8() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest8 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest8(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest8)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest8)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest8 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest8 sendRequest8) + { + if (sendRequest8 == null) + { + return null; + } + return BinaryContent.Create(sendRequest8, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest8)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteObjectValue(Prop, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest8 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest8 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest8)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest8(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest8 DeserializeSendRequest8(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MixedLiteralsCases prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = MixedLiteralsCases.DeserializeMixedLiteralsCases(prop0.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest8(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.cs new file mode 100644 index 00000000000..ef2c2ea1b53 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Union +{ + /// The SendRequest8. + internal partial class SendRequest8 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest8(MixedLiteralsCases prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest8(MixedLiteralsCases prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public MixedLiteralsCases Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.Serialization.cs new file mode 100644 index 00000000000..13abcda2dd8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace _Type.Union +{ + /// The SendRequest9. + internal partial class SendRequest9 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SendRequest9() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SendRequest9 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSendRequest9(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SendRequest9)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(SendRequest9)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + SendRequest9 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(SendRequest9 sendRequest9) + { + if (sendRequest9 == null) + { + return null; + } + return BinaryContent.Create(sendRequest9, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest9)} does not support writing '{format}' format."); + } + writer.WritePropertyName("prop"u8); + writer.WriteObjectValue(Prop, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SendRequest9 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SendRequest9 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SendRequest9)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSendRequest9(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SendRequest9 DeserializeSendRequest9(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MixedTypesCases prop = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop0 in element.EnumerateObject()) + { + if (prop0.NameEquals("prop"u8)) + { + prop = MixedTypesCases.DeserializeMixedTypesCases(prop0.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + return new SendRequest9(prop, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.cs new file mode 100644 index 00000000000..3629eace1cb --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Union +{ + /// The SendRequest9. + internal partial class SendRequest9 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal SendRequest9(MixedTypesCases prop) + { + Prop = prop; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal SendRequest9(MixedTypesCases prop, IDictionary additionalBinaryDataProperties) + { + Prop = prop; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Prop. + public MixedTypesCases Prop { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.Serialization.cs index cfe41e6c340..b0d2c32ffe7 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.Serialization.cs @@ -4,30 +4,158 @@ using System; using System.ClientModel.Primitives; +using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { + /// The StringAndArrayCases. public partial class StringAndArrayCases : IJsonModel { - internal StringAndArrayCases() => throw null; + /// Initializes a new instance of for deserialization. + internal StringAndArrayCases() + { + } - protected virtual StringAndArrayCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StringAndArrayCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeStringAndArrayCases(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StringAndArrayCases)} does not support reading '{options.Format}' format."); + } + } - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); + default: + throw new FormatException($"The model {nameof(StringAndArrayCases)} does not support writing '{options.Format}' format."); + } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - StringAndArrayCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + /// The data to parse. + /// The client options for reading and writing models. + StringAndArrayCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StringAndArrayCases)} does not support writing '{format}' format."); + } + writer.WritePropertyName("string"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(String); +#else + using (JsonDocument document = JsonDocument.Parse(String)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("array"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Array); +#else + using (JsonDocument document = JsonDocument.Parse(Array)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } - StringAndArrayCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + StringAndArrayCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - protected virtual StringAndArrayCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StringAndArrayCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StringAndArrayCases)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStringAndArrayCases(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StringAndArrayCases DeserializeStringAndArrayCases(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData @string = default; + BinaryData array = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("string"u8)) + { + @string = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("array"u8)) + { + array = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StringAndArrayCases(@string, array, additionalBinaryDataProperties); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.cs index a6f84c36aca..4793dfc8bc8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.cs @@ -3,23 +3,121 @@ #nullable disable using System; +using System.Collections.Generic; +using System.Text.Json; namespace _Type.Union { + /// The StringAndArrayCases. public partial class StringAndArrayCases { - public StringAndArrayCases(BinaryData @string, BinaryData array) => throw null; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; - public BinaryData String + /// Initializes a new instance of . + /// This should be receive/send the string variant. + /// This should be receive/send the array variant. + /// or is null. + public StringAndArrayCases(BinaryData @string, BinaryData array) { - get => throw null; - set => throw null; + Argument.AssertNotNull(@string, nameof(@string)); + Argument.AssertNotNull(array, nameof(array)); + + String = @string; + Array = array; } - public BinaryData Array + /// Initializes a new instance of . + /// This should be receive/send the string variant. + /// This should be receive/send the array variant. + /// Keeps track of any properties unknown to the library. + internal StringAndArrayCases(BinaryData @string, BinaryData array, IDictionary additionalBinaryDataProperties) { - get => throw null; - set => throw null; + String = @string; + Array = array; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } + + /// + /// This should be receive/send the string variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData String { get; set; } + + /// + /// This should be receive/send the array variant + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo"). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\""). + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }). + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}"). + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData Array { get; set; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringExtensibleNamedUnion.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringExtensibleNamedUnion.cs index 4cac1e8e32f..b2f5f6a76bf 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringExtensibleNamedUnion.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringExtensibleNamedUnion.cs @@ -7,30 +7,59 @@ namespace _Type.Union { + /// public readonly partial struct StringExtensibleNamedUnion : IEquatable { - public StringExtensibleNamedUnion(string value) => throw null; + private readonly string _value; + private const string OptionBValue = "b"; + private const string CValue = "c"; - public static StringExtensibleNamedUnion OptionB => throw null; + /// Initializes a new instance of . + /// The value. + /// is null. + public StringExtensibleNamedUnion(string value) + { + Argument.AssertNotNull(value, nameof(value)); - public static StringExtensibleNamedUnion C => throw null; + _value = value; + } - public static bool operator ==(StringExtensibleNamedUnion left, StringExtensibleNamedUnion right) => throw null; + /// Gets the OptionB. + public static StringExtensibleNamedUnion OptionB { get; } = new StringExtensibleNamedUnion(OptionBValue); - public static bool operator !=(StringExtensibleNamedUnion left, StringExtensibleNamedUnion right) => throw null; + /// Gets the C. + public static StringExtensibleNamedUnion C { get; } = new StringExtensibleNamedUnion(CValue); - public static implicit operator StringExtensibleNamedUnion(string value) => throw null; + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(StringExtensibleNamedUnion left, StringExtensibleNamedUnion right) => left.Equals(right); - public static implicit operator StringExtensibleNamedUnion?(string value) => throw null; + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(StringExtensibleNamedUnion left, StringExtensibleNamedUnion right) => !left.Equals(right); + /// Converts a string to a . + /// The value. + public static implicit operator StringExtensibleNamedUnion(string value) => new StringExtensibleNamedUnion(value); + + /// Converts a string to a . + /// The value. + public static implicit operator StringExtensibleNamedUnion?(string value) => value == null ? null : new StringExtensibleNamedUnion(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => throw null; + public override bool Equals(object obj) => obj is StringExtensibleNamedUnion other && Equals(other); - public bool Equals(StringExtensibleNamedUnion other) => throw null; + /// + public bool Equals(StringExtensibleNamedUnion other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + /// [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => throw null; + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => throw null; + /// + public override string ToString() => _value; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/_TypeUnionContext.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/_TypeUnionContext.cs index 60e51e84695..755c563bcf9 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/_TypeUnionContext.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/_TypeUnionContext.cs @@ -6,6 +6,10 @@ namespace _Type.Union { + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// [ModelReaderWriterBuildable(typeof(Cat))] [ModelReaderWriterBuildable(typeof(Dog))] [ModelReaderWriterBuildable(typeof(EnumsOnlyCases))] @@ -21,6 +25,16 @@ namespace _Type.Union [ModelReaderWriterBuildable(typeof(GetResponse9))] [ModelReaderWriterBuildable(typeof(MixedLiteralsCases))] [ModelReaderWriterBuildable(typeof(MixedTypesCases))] + [ModelReaderWriterBuildable(typeof(SendRequest))] + [ModelReaderWriterBuildable(typeof(SendRequest1))] + [ModelReaderWriterBuildable(typeof(SendRequest2))] + [ModelReaderWriterBuildable(typeof(SendRequest3))] + [ModelReaderWriterBuildable(typeof(SendRequest4))] + [ModelReaderWriterBuildable(typeof(SendRequest5))] + [ModelReaderWriterBuildable(typeof(SendRequest6))] + [ModelReaderWriterBuildable(typeof(SendRequest7))] + [ModelReaderWriterBuildable(typeof(SendRequest8))] + [ModelReaderWriterBuildable(typeof(SendRequest9))] [ModelReaderWriterBuildable(typeof(StringAndArrayCases))] public partial class _TypeUnionContext : ModelReaderWriterContext { diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.RestClient.cs new file mode 100644 index 00000000000..662a9e02444 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class ModelsOnly + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/models-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/models-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.cs index ebb37812dc0..eba7c2ae51c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.cs @@ -10,28 +10,146 @@ namespace _Type.Union { + /// Describe union of models. public partial class ModelsOnly { - protected ModelsOnly() => throw null; + private readonly Uri _endpoint; - internal ModelsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of ModelsOnly for mocking. + protected ModelsOnly() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of ModelsOnly. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelsOnly(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse5)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse5)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(BinaryData prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(BinaryData prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Send(BinaryData prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest5 spreadModel = new SendRequest5(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task SendAsync(BinaryData prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest5 spreadModel = new SendRequest5(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.RestClient.cs new file mode 100644 index 00000000000..0b016492b1b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class StringAndArray + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/string-and-array", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/string-and-array", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.cs index 0a470dd358d..d718de7d41f 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.cs @@ -10,28 +10,146 @@ namespace _Type.Union { + /// Describe union of a string and an array of strings. public partial class StringAndArray { - protected StringAndArray() => throw null; + private readonly Uri _endpoint; - internal StringAndArray(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of StringAndArray for mocking. + protected StringAndArray() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of StringAndArray. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal StringAndArray(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse7)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse7)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(StringAndArrayCases prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(StringAndArrayCases prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Send(StringAndArrayCases prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest7 spreadModel = new SendRequest7(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task SendAsync(StringAndArrayCases prop, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(prop, nameof(prop)); + + SendRequest7 spreadModel = new SendRequest7(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.RestClient.cs new file mode 100644 index 00000000000..8afb51d8888 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class StringExtensible + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/string-extensible", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/string-extensible", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.cs index c6d886ad068..83de07b6630 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.cs @@ -10,28 +10,140 @@ namespace _Type.Union { + /// Describe union of string string | "b" | "c". public partial class StringExtensible { - protected StringExtensible() => throw null; + private readonly Uri _endpoint; - internal StringExtensible(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of StringExtensible for mocking. + protected StringExtensible() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of StringExtensible. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal StringExtensible(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse1)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse1)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(GetResponseProp1 prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(GetResponseProp1 prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Send(GetResponseProp1 prop, CancellationToken cancellationToken = default) + { + SendRequest1 spreadModel = new SendRequest1(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task SendAsync(GetResponseProp1 prop, CancellationToken cancellationToken = default) + { + SendRequest1 spreadModel = new SendRequest1(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.RestClient.cs new file mode 100644 index 00000000000..95ab027470b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class StringExtensibleNamed + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/string-extensible-named", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/string-extensible-named", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.cs index 85a4d399263..573aa63e8f1 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.cs @@ -10,28 +10,140 @@ namespace _Type.Union { + /// Describe union of string string | "b" | "c" but where the union is named and some of the variants are named. public partial class StringExtensibleNamed { - protected StringExtensibleNamed() => throw null; + private readonly Uri _endpoint; - internal StringExtensibleNamed(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of StringExtensibleNamed for mocking. + protected StringExtensibleNamed() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of StringExtensibleNamed. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal StringExtensibleNamed(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse2)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse2)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(StringExtensibleNamedUnion prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(StringExtensibleNamedUnion prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Send(StringExtensibleNamedUnion prop, CancellationToken cancellationToken = default) + { + SendRequest2 spreadModel = new SendRequest2(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task SendAsync(StringExtensibleNamedUnion prop, CancellationToken cancellationToken = default) + { + SendRequest2 spreadModel = new SendRequest2(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.RestClient.cs new file mode 100644 index 00000000000..53d7856cfd8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace _Type.Union +{ + /// + public partial class StringsOnly + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/strings-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/type/union/strings-only", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.cs index fb8ec122f24..dd4c7aa12e9 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.cs @@ -10,28 +10,140 @@ namespace _Type.Union { + /// Describe union of string "a" | "b" | "c". public partial class StringsOnly { - protected StringsOnly() => throw null; + private readonly Uri _endpoint; - internal StringsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; + /// Initializes a new instance of StringsOnly for mocking. + protected StringsOnly() + { + } - public ClientPipeline Pipeline => throw null; + /// Initializes a new instance of StringsOnly. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal StringsOnly(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } - public virtual ClientResult Get(RequestOptions options) => throw null; + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } - public virtual Task GetAsync(RequestOptions options) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetResponse)result, result.GetRawResponse()); + } - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetResponse)result, result.GetRawResponse()); + } - public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); - public virtual ClientResult Send(GetResponseProp prop, CancellationToken cancellationToken = default) => throw null; + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } - public virtual Task SendAsync(GetResponseProp prop, CancellationToken cancellationToken = default) => throw null; + /// + /// [Protocol Method] Send + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSendRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Send(GetResponseProp prop, CancellationToken cancellationToken = default) + { + SendRequest spreadModel = new SendRequest(prop, default); + return Send(spreadModel, cancellationToken.ToRequestOptions()); + } + + /// Send. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task SendAsync(GetResponseProp prop, CancellationToken cancellationToken = default) + { + SendRequest spreadModel = new SendRequest(prop, default); + return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/TypeUnionModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/TypeUnionModelFactory.cs index 94c8fc67c26..dbb8febbd29 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/TypeUnionModelFactory.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/TypeUnionModelFactory.cs @@ -4,41 +4,156 @@ using System; using System.Collections.Generic; +using System.Linq; namespace _Type.Union { + /// A factory class for creating instances of the models for mocking. public static partial class TypeUnionModelFactory { - public static GetResponse GetResponse(GetResponseProp prop = default) => throw null; - - public static GetResponse1 GetResponse1(GetResponseProp1 prop = default) => throw null; - - public static GetResponse2 GetResponse2(StringExtensibleNamedUnion prop = default) => throw null; - - public static GetResponse3 GetResponse3(GetResponseProp2 prop = default) => throw null; - - public static GetResponse4 GetResponse4(GetResponseProp3 prop = default) => throw null; - - public static GetResponse5 GetResponse5(BinaryData prop = default) => throw null; - - public static Cat Cat(string name = default) => throw null; - - public static Dog Dog(string bark = default) => throw null; - - public static GetResponse6 GetResponse6(EnumsOnlyCases prop = default) => throw null; - - public static EnumsOnlyCases EnumsOnlyCases(EnumsOnlyCasesLr lr = default, EnumsOnlyCasesUd ud = default) => throw null; - - public static GetResponse7 GetResponse7(StringAndArrayCases prop = default) => throw null; - - public static StringAndArrayCases StringAndArrayCases(BinaryData @string = default, BinaryData array = default) => throw null; - - public static GetResponse8 GetResponse8(MixedLiteralsCases prop = default) => throw null; - - public static MixedLiteralsCases MixedLiteralsCases(BinaryData stringLiteral = default, BinaryData intLiteral = default, BinaryData floatLiteral = default, BinaryData booleanLiteral = default) => throw null; - - public static GetResponse9 GetResponse9(MixedTypesCases prop = default) => throw null; - - public static MixedTypesCases MixedTypesCases(BinaryData model = default, BinaryData literal = default, BinaryData @int = default, BinaryData boolean = default, IEnumerable array = default) => throw null; + /// The GetResponse. + /// + /// A new instance for mocking. + public static GetResponse GetResponse(GetResponseProp prop = default) + { + return new GetResponse(prop, additionalBinaryDataProperties: null); + } + + /// The GetResponse1. + /// + /// A new instance for mocking. + public static GetResponse1 GetResponse1(GetResponseProp1 prop = default) + { + return new GetResponse1(prop, additionalBinaryDataProperties: null); + } + + /// The GetResponse2. + /// + /// A new instance for mocking. + public static GetResponse2 GetResponse2(StringExtensibleNamedUnion prop = default) + { + return new GetResponse2(prop, additionalBinaryDataProperties: null); + } + + /// The GetResponse3. + /// + /// A new instance for mocking. + public static GetResponse3 GetResponse3(GetResponseProp2 prop = default) + { + return new GetResponse3(prop, additionalBinaryDataProperties: null); + } + + /// The GetResponse4. + /// + /// A new instance for mocking. + public static GetResponse4 GetResponse4(GetResponseProp3 prop = default) + { + return new GetResponse4(prop, additionalBinaryDataProperties: null); + } + + /// The GetResponse5. + /// + /// A new instance for mocking. + public static GetResponse5 GetResponse5(BinaryData prop = default) + { + return new GetResponse5(prop, additionalBinaryDataProperties: null); + } + + /// The Cat. + /// + /// A new instance for mocking. + public static Cat Cat(string name = default) + { + return new Cat(name, additionalBinaryDataProperties: null); + } + + /// The Dog. + /// + /// A new instance for mocking. + public static Dog Dog(string bark = default) + { + return new Dog(bark, additionalBinaryDataProperties: null); + } + + /// The GetResponse6. + /// + /// A new instance for mocking. + public static GetResponse6 GetResponse6(EnumsOnlyCases prop = default) + { + return new GetResponse6(prop, additionalBinaryDataProperties: null); + } + + /// The EnumsOnlyCases. + /// This should be receive/send the left variant. + /// This should be receive/send the up variant. + /// A new instance for mocking. + public static EnumsOnlyCases EnumsOnlyCases(EnumsOnlyCasesLr lr = default, EnumsOnlyCasesUd ud = default) + { + return new EnumsOnlyCases(lr, ud, additionalBinaryDataProperties: null); + } + + /// The GetResponse7. + /// + /// A new instance for mocking. + public static GetResponse7 GetResponse7(StringAndArrayCases prop = default) + { + return new GetResponse7(prop, additionalBinaryDataProperties: null); + } + + /// The StringAndArrayCases. + /// This should be receive/send the string variant. + /// This should be receive/send the array variant. + /// A new instance for mocking. + public static StringAndArrayCases StringAndArrayCases(BinaryData @string = default, BinaryData array = default) + { + return new StringAndArrayCases(@string, array, additionalBinaryDataProperties: null); + } + + /// The GetResponse8. + /// + /// A new instance for mocking. + public static GetResponse8 GetResponse8(MixedLiteralsCases prop = default) + { + return new GetResponse8(prop, additionalBinaryDataProperties: null); + } + + /// The MixedLiteralsCases. + /// This should be receive/send the "a" variant. + /// This should be receive/send the 2 variant. + /// This should be receive/send the 3.3 variant. + /// This should be receive/send the true variant. + /// A new instance for mocking. + public static MixedLiteralsCases MixedLiteralsCases(BinaryData stringLiteral = default, BinaryData intLiteral = default, BinaryData floatLiteral = default, BinaryData booleanLiteral = default) + { + return new MixedLiteralsCases(stringLiteral, intLiteral, floatLiteral, booleanLiteral, additionalBinaryDataProperties: null); + } + + /// The GetResponse9. + /// + /// A new instance for mocking. + public static GetResponse9 GetResponse9(MixedTypesCases prop = default) + { + return new GetResponse9(prop, additionalBinaryDataProperties: null); + } + + /// The MixedTypesCases. + /// This should be receive/send the Cat variant. + /// This should be receive/send the "a" variant. + /// This should be receive/send the int variant. + /// This should be receive/send the boolean variant. + /// This should be receive/send 4 element with Cat, "a", int, and boolean. + /// A new instance for mocking. + public static MixedTypesCases MixedTypesCases(BinaryData model = default, BinaryData literal = default, BinaryData @int = default, BinaryData boolean = default, IEnumerable array = default) + { + array ??= new ChangeTrackingList(); + + return new MixedTypesCases( + model, + literal, + @int, + boolean, + array.ToList(), + additionalBinaryDataProperties: null); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.RestClient.cs new file mode 100644 index 00000000000..013f0f1fac7 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.RestClient.cs @@ -0,0 +1,11 @@ +// + +#nullable disable + +namespace _Type.Union +{ + /// + public partial class UnionClient + { + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.cs index 48df18bf7cc..ce12a705610 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.cs @@ -5,40 +5,127 @@ using System; using System.ClientModel.Primitives; using System.Diagnostics.CodeAnalysis; +using System.Threading; namespace _Type.Union { + /// Describe scenarios for various combinations of unions. public partial class UnionClient { - public UnionClient() : this(new Uri("http://localhost:3000"), new UnionClientOptions()) => throw null; - - internal UnionClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, UnionClientOptions options) => throw null; - - public UnionClient(Uri endpoint, UnionClientOptions options) : this(null, endpoint, options) => throw null; - + private readonly Uri _endpoint; + private StringsOnly _cachedStringsOnly; + private StringExtensible _cachedStringExtensible; + private StringExtensibleNamed _cachedStringExtensibleNamed; + private IntsOnly _cachedIntsOnly; + private FloatsOnly _cachedFloatsOnly; + private ModelsOnly _cachedModelsOnly; + private EnumsOnly _cachedEnumsOnly; + private StringAndArray _cachedStringAndArray; + private MixedLiterals _cachedMixedLiterals; + private MixedTypes _cachedMixedTypes; + + /// Initializes a new instance of UnionClient. + public UnionClient() : this(new Uri("http://localhost:3000"), new UnionClientOptions()) + { + } + + /// Initializes a new instance of UnionClient. + /// The authentication policy to use for pipeline creation. + /// Service endpoint. + /// The options for configuring the client. + internal UnionClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, UnionClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + + options ??= new UnionClientOptions(); + + _endpoint = endpoint; + if (authenticationPolicy != null) + { + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(UnionClient).Assembly), authenticationPolicy }, Array.Empty()); + } + else + { + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(UnionClient).Assembly) }, Array.Empty()); + } + } + + /// Initializes a new instance of UnionClient. + /// Service endpoint. + /// The options for configuring the client. + /// is null. + public UnionClient(Uri endpoint, UnionClientOptions options) : this(null, endpoint, options) + { + } + + /// Initializes a new instance of UnionClient from a . + /// The settings for UnionClient. [Experimental("SCME0002")] - public UnionClient(UnionClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Endpoint, settings?.Options) => throw null; - - public ClientPipeline Pipeline => throw null; - - public virtual StringsOnly GetStringsOnlyClient() => throw null; - - public virtual StringExtensible GetStringExtensibleClient() => throw null; - - public virtual StringExtensibleNamed GetStringExtensibleNamedClient() => throw null; - - public virtual IntsOnly GetIntsOnlyClient() => throw null; - - public virtual FloatsOnly GetFloatsOnlyClient() => throw null; - - public virtual ModelsOnly GetModelsOnlyClient() => throw null; - - public virtual EnumsOnly GetEnumsOnlyClient() => throw null; - - public virtual StringAndArray GetStringAndArrayClient() => throw null; - - public virtual MixedLiterals GetMixedLiteralsClient() => throw null; - - public virtual MixedTypes GetMixedTypesClient() => throw null; + public UnionClient(UnionClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Endpoint, settings?.Options) + { + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// Initializes a new instance of StringsOnly. + public virtual StringsOnly GetStringsOnlyClient() + { + return Volatile.Read(ref _cachedStringsOnly) ?? Interlocked.CompareExchange(ref _cachedStringsOnly, new StringsOnly(Pipeline, _endpoint), null) ?? _cachedStringsOnly; + } + + /// Initializes a new instance of StringExtensible. + public virtual StringExtensible GetStringExtensibleClient() + { + return Volatile.Read(ref _cachedStringExtensible) ?? Interlocked.CompareExchange(ref _cachedStringExtensible, new StringExtensible(Pipeline, _endpoint), null) ?? _cachedStringExtensible; + } + + /// Initializes a new instance of StringExtensibleNamed. + public virtual StringExtensibleNamed GetStringExtensibleNamedClient() + { + return Volatile.Read(ref _cachedStringExtensibleNamed) ?? Interlocked.CompareExchange(ref _cachedStringExtensibleNamed, new StringExtensibleNamed(Pipeline, _endpoint), null) ?? _cachedStringExtensibleNamed; + } + + /// Initializes a new instance of IntsOnly. + public virtual IntsOnly GetIntsOnlyClient() + { + return Volatile.Read(ref _cachedIntsOnly) ?? Interlocked.CompareExchange(ref _cachedIntsOnly, new IntsOnly(Pipeline, _endpoint), null) ?? _cachedIntsOnly; + } + + /// Initializes a new instance of FloatsOnly. + public virtual FloatsOnly GetFloatsOnlyClient() + { + return Volatile.Read(ref _cachedFloatsOnly) ?? Interlocked.CompareExchange(ref _cachedFloatsOnly, new FloatsOnly(Pipeline, _endpoint), null) ?? _cachedFloatsOnly; + } + + /// Initializes a new instance of ModelsOnly. + public virtual ModelsOnly GetModelsOnlyClient() + { + return Volatile.Read(ref _cachedModelsOnly) ?? Interlocked.CompareExchange(ref _cachedModelsOnly, new ModelsOnly(Pipeline, _endpoint), null) ?? _cachedModelsOnly; + } + + /// Initializes a new instance of EnumsOnly. + public virtual EnumsOnly GetEnumsOnlyClient() + { + return Volatile.Read(ref _cachedEnumsOnly) ?? Interlocked.CompareExchange(ref _cachedEnumsOnly, new EnumsOnly(Pipeline, _endpoint), null) ?? _cachedEnumsOnly; + } + + /// Initializes a new instance of StringAndArray. + public virtual StringAndArray GetStringAndArrayClient() + { + return Volatile.Read(ref _cachedStringAndArray) ?? Interlocked.CompareExchange(ref _cachedStringAndArray, new StringAndArray(Pipeline, _endpoint), null) ?? _cachedStringAndArray; + } + + /// Initializes a new instance of MixedLiterals. + public virtual MixedLiterals GetMixedLiteralsClient() + { + return Volatile.Read(ref _cachedMixedLiterals) ?? Interlocked.CompareExchange(ref _cachedMixedLiterals, new MixedLiterals(Pipeline, _endpoint), null) ?? _cachedMixedLiterals; + } + + /// Initializes a new instance of MixedTypes. + public virtual MixedTypes GetMixedTypesClient() + { + return Volatile.Read(ref _cachedMixedTypes) ?? Interlocked.CompareExchange(ref _cachedMixedTypes, new MixedTypes(Pipeline, _endpoint), null) ?? _cachedMixedTypes; + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientOptions.cs index 9352bd0c9c3..8a08b8872de 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientOptions.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientOptions.cs @@ -8,11 +8,23 @@ namespace _Type.Union { + /// Client options for . public partial class UnionClientOptions : ClientPipelineOptions { - public UnionClientOptions() => throw null; + /// Initializes a new instance of UnionClientOptions. + public UnionClientOptions() + { + } + /// Initializes a new instance of UnionClientOptions from configuration. + /// The configuration section. [Experimental("SCME0002")] - internal UnionClientOptions(IConfigurationSection section) : base(section) => throw null; + internal UnionClientOptions(IConfigurationSection section) : base(section) + { + if (section is null || !section.Exists()) + { + return; + } + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientSettings.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientSettings.cs index 71defed8463..d6cfaa81214 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientSettings.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientSettings.cs @@ -9,21 +9,29 @@ namespace _Type.Union { + /// Represents the settings used to configure a that can be loaded from an . [Experimental("SCME0002")] public partial class UnionClientSettings : ClientSettings { - public Uri Endpoint - { - get => throw null; - set => throw null; - } + /// Gets or sets the Endpoint. + public Uri Endpoint { get; set; } - public UnionClientOptions Options + /// Gets or sets the Options. + public UnionClientOptions Options { get; set; } + + /// Binds configuration values from the given section. + /// The configuration section. + protected override void BindCore(IConfigurationSection section) { - get => throw null; - set => throw null; + if (Uri.TryCreate(section["Endpoint"], UriKind.Absolute, out Uri endpoint)) + { + Endpoint = endpoint; + } + IConfigurationSection optionsSection = section.GetSection("Options"); + if (optionsSection.Exists()) + { + Options = new UnionClientOptions(optionsSection); + } } - - protected override void BindCore(IConfigurationSection section) => throw null; } } From fe2c1471b4e7275debb7b047979533419f111635 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 17:24:58 +0000 Subject: [PATCH 05/16] fix: properly regenerate all test projects with Stub plugin, remove spurious README.md Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/1b82cdb2-3c40-4ccf-adc2-308467b343aa Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- packages/http-client-csharp/README.md | 184 ----------- .../src/Generated/EnumsOnly.RestClient.cs | 45 --- .../type/union/src/Generated/EnumsOnly.cs | 140 +-------- .../src/Generated/FloatsOnly.RestClient.cs | 45 --- .../type/union/src/Generated/FloatsOnly.cs | 134 +------- .../union/src/Generated/Internal/Argument.cs | 110 ------- .../Internal/CancellationTokenExtensions.cs | 14 - .../Internal/ChangeTrackingDictionary.cs | 186 ----------- .../Generated/Internal/ChangeTrackingList.cs | 165 ---------- .../Internal/ClientPipelineExtensions.cs | 67 ---- .../Generated/Internal/ClientUriBuilder.cs | 181 ----------- .../Internal/CodeGenMemberAttribute.cs | 17 -- .../Internal/CodeGenSerializationAttribute.cs | 45 --- .../Internal/CodeGenSuppressAttribute.cs | 26 -- .../Internal/CodeGenTypeAttribute.cs | 21 -- .../src/Generated/Internal/ErrorResult.cs | 24 -- .../Internal/ModelSerializationExtensions.cs | 265 ---------------- .../Generated/Internal/SerializationFormat.cs | 46 --- .../src/Generated/Internal/TypeFormatters.cs | 178 ----------- .../src/Generated/IntsOnly.RestClient.cs | 45 --- .../http/type/union/src/Generated/IntsOnly.cs | 134 +------- .../src/Generated/MixedLiterals.RestClient.cs | 45 --- .../type/union/src/Generated/MixedLiterals.cs | 140 +-------- .../src/Generated/MixedTypes.RestClient.cs | 45 --- .../type/union/src/Generated/MixedTypes.cs | 140 +-------- .../src/Generated/Models/Cat.Serialization.cs | 126 +------- .../type/union/src/Generated/Models/Cat.cs | 29 +- .../src/Generated/Models/Dog.Serialization.cs | 126 +------- .../type/union/src/Generated/Models/Dog.cs | 29 +- .../Models/EnumsOnlyCases.Serialization.cs | 134 +------- .../src/Generated/Models/EnumsOnlyCases.cs | 33 +- .../Models/EnumsOnlyCasesLr.Serialization.cs | 43 --- .../src/Generated/Models/EnumsOnlyCasesLr.cs | 1 - .../Models/EnumsOnlyCasesUd.Serialization.cs | 33 -- .../src/Generated/Models/EnumsOnlyCasesUd.cs | 1 - .../Models/GetResponse.Serialization.cs | 134 +------- .../union/src/Generated/Models/GetResponse.cs | 26 +- .../Models/GetResponse1.Serialization.cs | 134 +------- .../src/Generated/Models/GetResponse1.cs | 26 +- .../Models/GetResponse2.Serialization.cs | 134 +------- .../src/Generated/Models/GetResponse2.cs | 26 +- .../Models/GetResponse3.Serialization.cs | 134 +------- .../src/Generated/Models/GetResponse3.cs | 26 +- .../Models/GetResponse4.Serialization.cs | 134 +------- .../src/Generated/Models/GetResponse4.cs | 26 +- .../Models/GetResponse5.Serialization.cs | 141 +-------- .../src/Generated/Models/GetResponse5.cs | 63 +--- .../Models/GetResponse6.Serialization.cs | 134 +------- .../src/Generated/Models/GetResponse6.cs | 26 +- .../Models/GetResponse7.Serialization.cs | 134 +------- .../src/Generated/Models/GetResponse7.cs | 26 +- .../Models/GetResponse8.Serialization.cs | 134 +------- .../src/Generated/Models/GetResponse8.cs | 26 +- .../Models/GetResponse9.Serialization.cs | 134 +------- .../src/Generated/Models/GetResponse9.cs | 26 +- .../Models/GetResponseProp.Serialization.cs | 38 --- .../src/Generated/Models/GetResponseProp.cs | 1 - .../src/Generated/Models/GetResponseProp1.cs | 51 +--- .../Models/GetResponseProp2.Serialization.cs | 29 -- .../src/Generated/Models/GetResponseProp2.cs | 1 - .../Models/GetResponseProp3.Serialization.cs | 38 --- .../src/Generated/Models/GetResponseProp3.cs | 1 - .../MixedLiteralsCases.Serialization.cs | 178 +---------- .../Generated/Models/MixedLiteralsCases.cs | 236 ++------------ .../Models/MixedTypesCases.Serialization.cs | 221 +------------- .../src/Generated/Models/MixedTypesCases.cs | 288 ++---------------- .../Models/SendRequest.Serialization.cs | 150 --------- .../union/src/Generated/Models/SendRequest.cs | 35 --- .../Models/SendRequest1.Serialization.cs | 150 --------- .../src/Generated/Models/SendRequest1.cs | 35 --- .../Models/SendRequest2.Serialization.cs | 150 --------- .../src/Generated/Models/SendRequest2.cs | 35 --- .../Models/SendRequest3.Serialization.cs | 150 --------- .../src/Generated/Models/SendRequest3.cs | 35 --- .../Models/SendRequest4.Serialization.cs | 150 --------- .../src/Generated/Models/SendRequest4.cs | 35 --- .../Models/SendRequest5.Serialization.cs | 157 ---------- .../src/Generated/Models/SendRequest5.cs | 74 ----- .../Models/SendRequest6.Serialization.cs | 150 --------- .../src/Generated/Models/SendRequest6.cs | 35 --- .../Models/SendRequest7.Serialization.cs | 150 --------- .../src/Generated/Models/SendRequest7.cs | 35 --- .../Models/SendRequest8.Serialization.cs | 150 --------- .../src/Generated/Models/SendRequest8.cs | 35 --- .../Models/SendRequest9.Serialization.cs | 150 --------- .../src/Generated/Models/SendRequest9.cs | 35 --- .../StringAndArrayCases.Serialization.cs | 148 +-------- .../Generated/Models/StringAndArrayCases.cs | 112 +------ .../Models/StringExtensibleNamedUnion.cs | 51 +--- .../src/Generated/Models/_TypeUnionContext.cs | 14 - .../src/Generated/ModelsOnly.RestClient.cs | 45 --- .../type/union/src/Generated/ModelsOnly.cs | 140 +-------- .../Generated/StringAndArray.RestClient.cs | 45 --- .../union/src/Generated/StringAndArray.cs | 140 +-------- .../Generated/StringExtensible.RestClient.cs | 45 --- .../union/src/Generated/StringExtensible.cs | 134 +------- .../StringExtensibleNamed.RestClient.cs | 45 --- .../src/Generated/StringExtensibleNamed.cs | 134 +------- .../src/Generated/StringsOnly.RestClient.cs | 45 --- .../type/union/src/Generated/StringsOnly.cs | 134 +------- .../src/Generated/TypeUnionModelFactory.cs | 177 ++--------- .../src/Generated/UnionClient.RestClient.cs | 11 - .../type/union/src/Generated/UnionClient.cs | 145 ++------- .../union/src/Generated/UnionClientOptions.cs | 16 +- .../src/Generated/UnionClientSettings.cs | 28 +- 105 files changed, 441 insertions(+), 8787 deletions(-) delete mode 100644 packages/http-client-csharp/README.md delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/Argument.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CancellationTokenExtensions.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingDictionary.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingList.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientPipelineExtensions.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientUriBuilder.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenMemberAttribute.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSerializationAttribute.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSuppressAttribute.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenTypeAttribute.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ErrorResult.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ModelSerializationExtensions.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/SerializationFormat.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/TypeFormatters.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.RestClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.RestClient.cs diff --git a/packages/http-client-csharp/README.md b/packages/http-client-csharp/README.md deleted file mode 100644 index 2acc3d7cbaf..00000000000 --- a/packages/http-client-csharp/README.md +++ /dev/null @@ -1,184 +0,0 @@ -# @typespec/http-client-csharp - -TypeSpec library for emitting Http Client libraries for C#. - -## Install - -```bash -npm install @typespec/http-client-csharp -``` - -## Usage - -### Prerequisite - -- Install [Node.js](https://nodejs.org/download/) 20 or above. (Verify by running `node --version`) -- Install [**.NET 8.0 SDK**](https://dotnet.microsoft.com/download/dotnet/8.0) for your specific platform. (or a higher version) - -### Customizing Generated Code - -For detailed instructions on how to customize the generated C# code, see the [Customization Guide](https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/.tspd/docs/customization.md). - -## Emitter usage - -1. Via the command line - -```bash -tsp compile . --emit=@typespec/http-client-csharp -``` - -2. Via the config - -```yaml -emit: - - "@typespec/http-client-csharp" -``` - -The config can be extended with options as follows: - -```yaml -emit: - - "@typespec/http-client-csharp" -options: - "@typespec/http-client-csharp": - option: value -``` - -## Emitter options - -### `emitter-output-dir` - -**Type:** `absolutePath` - -Defines the emitter output directory. Defaults to `{output-dir}/@typespec/http-client-csharp` -See [Configuring output directory for more info](https://typespec.io/docs/handbook/configuration/configuration/#configuring-output-directory) - -### `api-version` - -**Type:** `string` - -For TypeSpec files using the [`@versioned`](https://typespec.io/docs/libraries/versioning/reference/decorators/#@TypeSpec.Versioning.versioned) decorator, set this option to the version that should be used to generate against. - -### `generate-protocol-methods` - -**Type:** `boolean` - -Set to `false` to skip generation of protocol methods. The default value is `true`. - -### `generate-convenience-methods` - -**Type:** `boolean` - -Set to `false` to skip generation of convenience methods. The default value is `true`. - -### `unreferenced-types-handling` - -**Type:** `"removeOrInternalize" | "internalize" | "keepAll"` - -Defines the strategy on how to handle unreferenced types. The default value is `removeOrInternalize`. - -### `new-project` - -**Type:** `boolean` - -Set to `true` to overwrite the csproj if it already exists. The default value is `false`. - -### `save-inputs` - -**Type:** `boolean` - -Set to `true` to save the `tspCodeModel.json` and `Configuration.json` files that are emitted and used as inputs to the generator. The default value is `false`. - -### `package-name` - -**Type:** `string` - -Define the package name. If not specified, the first namespace defined in the TypeSpec is used as the package name. - -### `debug` - -**Type:** `boolean` - -Set to `true` to automatically attempt to attach to a debugger when executing the C# generator. The default value is `false`. - -### `logLevel` - -**Type:** `"info" | "debug" | "verbose"` - -Set the log level for which to collect traces. The default value is `info`. - -### `disable-xml-docs` - -**Type:** `boolean` - -Set to `true` to disable XML documentation generation. The default value is `false`. - -### `generator-name` - -**Type:** `string` - -The name of the generator. By default this is set to `ScmCodeModelGenerator`. Generator authors can set this to the name of a generator that inherits from `ScmCodeModelGenerator`. - -### `emitter-extension-path` - -**Type:** `string` - -Allows emitter authors to specify the path to a custom emitter package, allowing you to extend the emitter behavior. This should be set to `import.meta.url` if you are using a custom emitter. - -### `plugins` - -**Type:** `array` - -Paths to generator plugin assemblies (DLLs) or directories containing plugin assemblies. Each plugin must contain a class that extends GeneratorPlugin. - -### `license` - -**Type:** `object` - -License information for the generated client code. - -### `sdk-context-options` - -**Type:** `object` - -The SDK context options that implement the `CreateSdkContextOptions` interface from the [`@azure-tools/typespec-client-generator-core`](https://www.npmjs.com/package/@azure-tools/typespec-client-generator-core) package to be used by the CSharp emitter. - -## Decorators - -### TypeSpec.HttpClient.CSharp - -- [`@dynamicModel`](#@dynamicmodel) - -#### `@dynamicModel` - -Marks a model or namespace as dynamic, indicating it should generate dynamic model code. -Can be applied to Model or Namespace types. - -```typespec -@TypeSpec.HttpClient.CSharp.dynamicModel -``` - -##### Target - -`Model | Namespace` - -##### Parameters - -None - -##### Examples - -```tsp -@dynamicModel -model Pet { - name: string; - kind: string; -} - -@dynamicModel -namespace PetStore { - model Dog extends Pet { - breed: string; - } -} -``` diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.RestClient.cs deleted file mode 100644 index 70f2ab77344..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class EnumsOnly - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/enums-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/enums-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.cs index f5f02ca5c57..326e87184ee 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/EnumsOnly.cs @@ -10,146 +10,28 @@ namespace _Type.Union { - /// Describe union of 2 different enums. public partial class EnumsOnly { - private readonly Uri _endpoint; + protected EnumsOnly() => throw null; - /// Initializes a new instance of EnumsOnly for mocking. - protected EnumsOnly() - { - } + internal EnumsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of EnumsOnly. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal EnumsOnly(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse6)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse6)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(EnumsOnlyCases prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual ClientResult Send(EnumsOnlyCases prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest6 spreadModel = new SendRequest6(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual async Task SendAsync(EnumsOnlyCases prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest6 spreadModel = new SendRequest6(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(EnumsOnlyCases prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.RestClient.cs deleted file mode 100644 index 7e11e9de0de..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class FloatsOnly - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/floats-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/floats-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.cs index a459270305d..687ca26b9d4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/FloatsOnly.cs @@ -10,140 +10,28 @@ namespace _Type.Union { - /// Describe union of floats 1.1 | 2.2 | 3.3. public partial class FloatsOnly { - private readonly Uri _endpoint; + protected FloatsOnly() => throw null; - /// Initializes a new instance of FloatsOnly for mocking. - protected FloatsOnly() - { - } + internal FloatsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of FloatsOnly. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal FloatsOnly(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse4)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse4)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(GetResponseProp3 prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Send(GetResponseProp3 prop, CancellationToken cancellationToken = default) - { - SendRequest4 spreadModel = new SendRequest4(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task SendAsync(GetResponseProp3 prop, CancellationToken cancellationToken = default) - { - SendRequest4 spreadModel = new SendRequest4(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(GetResponseProp3 prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/Argument.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/Argument.cs deleted file mode 100644 index 4c94ff7b6e5..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/Argument.cs +++ /dev/null @@ -1,110 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; - -namespace _Type.Union -{ - internal static partial class Argument - { - /// The value. - /// The name. - public static void AssertNotNull(T value, string name) - { - if (value is null) - { - throw new ArgumentNullException(name); - } - } - - /// The value. - /// The name. - public static void AssertNotNull(T? value, string name) - where T : struct - { - if (!value.HasValue) - { - throw new ArgumentNullException(name); - } - } - - /// The value. - /// The name. - public static void AssertNotNullOrEmpty(IEnumerable value, string name) - { - if (value is null) - { - throw new ArgumentNullException(name); - } - if (value is ICollection collectionOfT && collectionOfT.Count == 0) - { - throw new ArgumentException("Value cannot be an empty collection.", name); - } - if (value is ICollection collection && collection.Count == 0) - { - throw new ArgumentException("Value cannot be an empty collection.", name); - } - using IEnumerator e = value.GetEnumerator(); - if (!e.MoveNext()) - { - throw new ArgumentException("Value cannot be an empty collection.", name); - } - } - - /// The value. - /// The name. - public static void AssertNotNullOrEmpty(string value, string name) - { - if (value is null) - { - throw new ArgumentNullException(name); - } - if (value.Length == 0) - { - throw new ArgumentException("Value cannot be an empty string.", name); - } - } - - /// The value. - /// The name. - public static void AssertNotNullOrWhiteSpace(string value, string name) - { - if (value is null) - { - throw new ArgumentNullException(name); - } - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); - } - } - - /// The value. - /// The minimum value. - /// The maximum value. - /// The name. - public static void AssertInRange(T value, T minimum, T maximum, string name) - where T : notnull, IComparable - { - if (minimum.CompareTo(value) > 0) - { - throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); - } - if (maximum.CompareTo(value) < 0) - { - throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); - } - } - - /// The value. - /// The name. - public static string CheckNotNullOrEmpty(string value, string name) - { - AssertNotNullOrEmpty(value, name); - return value; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CancellationTokenExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CancellationTokenExtensions.cs deleted file mode 100644 index fe421b047cc..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CancellationTokenExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -// - -#nullable disable - -using System.ClientModel.Primitives; -using System.Threading; - -namespace _Type.Union -{ - internal static partial class CancellationTokenExtensions - { - public static RequestOptions ToRequestOptions(this CancellationToken cancellationToken) => cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingDictionary.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingDictionary.cs deleted file mode 100644 index 8e8a8f18106..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingDictionary.cs +++ /dev/null @@ -1,186 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; - -namespace _Type.Union -{ - internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary - where TKey : notnull - { - private IDictionary _innerDictionary; - - public ChangeTrackingDictionary() - { - } - - /// The inner dictionary. - public ChangeTrackingDictionary(IDictionary dictionary) - { - if (dictionary == null) - { - return; - } - _innerDictionary = new Dictionary(dictionary); - } - - /// The inner dictionary. - public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) - { - if (dictionary == null) - { - return; - } - _innerDictionary = new Dictionary(); - foreach (var pair in dictionary) - { - _innerDictionary.Add(pair); - } - } - - /// Gets the IsUndefined. - public bool IsUndefined => _innerDictionary == null; - - /// Gets the Count. - public int Count => IsUndefined ? 0 : EnsureDictionary().Count; - - /// Gets the IsReadOnly. - public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; - - /// Gets the Keys. - public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; - - /// Gets the Values. - public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; - - /// Gets or sets the value associated with the specified key. - public TValue this[TKey key] - { - get - { - if (IsUndefined) - { - throw new KeyNotFoundException(nameof(key)); - } - return EnsureDictionary()[key]; - } - set - { - EnsureDictionary()[key] = value; - } - } - - /// Gets the Keys. - IEnumerable IReadOnlyDictionary.Keys => Keys; - - /// Gets the Values. - IEnumerable IReadOnlyDictionary.Values => Values; - - public IEnumerator> GetEnumerator() - { - if (IsUndefined) - { - IEnumerator> enumerateEmpty() - { - yield break; - } - return enumerateEmpty(); - } - return EnsureDictionary().GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - /// The item to add. - public void Add(KeyValuePair item) - { - EnsureDictionary().Add(item); - } - - public void Clear() - { - EnsureDictionary().Clear(); - } - - /// The item to search for. - public bool Contains(KeyValuePair item) - { - if (IsUndefined) - { - return false; - } - return EnsureDictionary().Contains(item); - } - - /// The array to copy. - /// The index. - public void CopyTo(KeyValuePair[] array, int index) - { - if (IsUndefined) - { - return; - } - EnsureDictionary().CopyTo(array, index); - } - - /// The item to remove. - public bool Remove(KeyValuePair item) - { - if (IsUndefined) - { - return false; - } - return EnsureDictionary().Remove(item); - } - - /// The key. - /// The value to add. - public void Add(TKey key, TValue value) - { - EnsureDictionary().Add(key, value); - } - - /// The key to search for. - public bool ContainsKey(TKey key) - { - if (IsUndefined) - { - return false; - } - return EnsureDictionary().ContainsKey(key); - } - - /// The key. - public bool Remove(TKey key) - { - if (IsUndefined) - { - return false; - } - return EnsureDictionary().Remove(key); - } - - /// The key to search for. - /// The value. - public bool TryGetValue(TKey key, out TValue value) - { - if (IsUndefined) - { - value = default; - return false; - } - return EnsureDictionary().TryGetValue(key, out value); - } - - public IDictionary EnsureDictionary() - { - return _innerDictionary ??= new Dictionary(); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingList.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingList.cs deleted file mode 100644 index 81edaef2cdf..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ChangeTrackingList.cs +++ /dev/null @@ -1,165 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; - -namespace _Type.Union -{ - internal partial class ChangeTrackingList : IList, IReadOnlyList - { - private IList _innerList; - - public ChangeTrackingList() - { - } - - /// The inner list. - public ChangeTrackingList(IList innerList) - { - if (innerList != null) - { - _innerList = innerList; - } - } - - /// The inner list. - public ChangeTrackingList(IReadOnlyList innerList) - { - if (innerList != null) - { - _innerList = innerList.ToList(); - } - } - - /// Gets the IsUndefined. - public bool IsUndefined => _innerList == null; - - /// Gets the Count. - public int Count => IsUndefined ? 0 : EnsureList().Count; - - /// Gets the IsReadOnly. - public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; - - /// Gets or sets the value associated with the specified key. - public T this[int index] - { - get - { - if (IsUndefined) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - return EnsureList()[index]; - } - set - { - if (IsUndefined) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - EnsureList()[index] = value; - } - } - - public void Reset() - { - _innerList = null; - } - - public IEnumerator GetEnumerator() - { - if (IsUndefined) - { - IEnumerator enumerateEmpty() - { - yield break; - } - return enumerateEmpty(); - } - return EnsureList().GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - /// The item to add. - public void Add(T item) - { - EnsureList().Add(item); - } - - public void Clear() - { - EnsureList().Clear(); - } - - /// The item. - public bool Contains(T item) - { - if (IsUndefined) - { - return false; - } - return EnsureList().Contains(item); - } - - /// The array to copy to. - /// The array index. - public void CopyTo(T[] array, int arrayIndex) - { - if (IsUndefined) - { - return; - } - EnsureList().CopyTo(array, arrayIndex); - } - - /// The item. - public bool Remove(T item) - { - if (IsUndefined) - { - return false; - } - return EnsureList().Remove(item); - } - - /// The item. - public int IndexOf(T item) - { - if (IsUndefined) - { - return -1; - } - return EnsureList().IndexOf(item); - } - - /// The inner list. - /// The item. - public void Insert(int index, T item) - { - EnsureList().Insert(index, item); - } - - /// The inner list. - public void RemoveAt(int index) - { - if (IsUndefined) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - EnsureList().RemoveAt(index); - } - - public IList EnsureList() - { - return _innerList ??= new List(); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientPipelineExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientPipelineExtensions.cs deleted file mode 100644 index cbaf436cb30..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientPipelineExtensions.cs +++ /dev/null @@ -1,67 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Threading.Tasks; - -namespace _Type.Union -{ - internal static partial class ClientPipelineExtensions - { - public static async ValueTask ProcessMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) - { - await pipeline.SendAsync(message).ConfigureAwait(false); - - if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) - { - throw await ClientResultException.CreateAsync(message.Response).ConfigureAwait(false); - } - - PipelineResponse response = message.BufferResponse ? message.Response : message.ExtractResponse(); - return response; - } - - public static PipelineResponse ProcessMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) - { - pipeline.Send(message); - - if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) - { - throw new ClientResultException(message.Response); - } - - PipelineResponse response = message.BufferResponse ? message.Response : message.ExtractResponse(); - return response; - } - - public static async ValueTask> ProcessHeadAsBoolMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) - { - PipelineResponse response = await pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - switch (response.Status) - { - case >= 200 and < 300: - return ClientResult.FromValue(true, response); - case >= 400 and < 500: - return ClientResult.FromValue(false, response); - default: - return new ErrorResult(response, new ClientResultException(response)); - } - } - - public static ClientResult ProcessHeadAsBoolMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) - { - PipelineResponse response = pipeline.ProcessMessage(message, options); - switch (response.Status) - { - case >= 200 and < 300: - return ClientResult.FromValue(true, response); - case >= 400 and < 500: - return ClientResult.FromValue(false, response); - default: - return new ErrorResult(response, new ClientResultException(response)); - } - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientUriBuilder.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientUriBuilder.cs deleted file mode 100644 index 516e23da549..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ClientUriBuilder.cs +++ /dev/null @@ -1,181 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace _Type.Union -{ - internal partial class ClientUriBuilder - { - private UriBuilder _uriBuilder; - private StringBuilder _pathAndQuery; - private int _pathLength; - - public ClientUriBuilder() - { - } - - private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder(); - - private StringBuilder PathAndQuery => _pathAndQuery ??= new StringBuilder(); - - public void Reset(Uri uri) - { - _uriBuilder = new UriBuilder(uri); - PathAndQuery.Clear(); - PathAndQuery.Append(UriBuilder.Path); - _pathLength = PathAndQuery.Length; - PathAndQuery.Append(UriBuilder.Query); - } - - public void AppendPath(string value, bool escape) - { - if (escape) - { - value = Uri.EscapeDataString(value); - } - if (_pathLength > 0 && PathAndQuery[_pathLength - 1] == '/' && value[0] == '/') - { - PathAndQuery.Remove(_pathLength - 1, 1); - _pathLength = _pathLength - 1; - } - PathAndQuery.Insert(_pathLength, value); - _pathLength = _pathLength + value.Length; - } - - public void AppendPath(bool value, bool escape = false) => AppendPath(TypeFormatters.ConvertToString(value), escape); - - public void AppendPath(float value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - - public void AppendPath(double value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - - public void AppendPath(int value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - - public void AppendPath(byte[] value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); - - public void AppendPath(DateTimeOffset value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); - - public void AppendPath(TimeSpan value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); - - public void AppendPath(Guid value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - - public void AppendPath(long value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - - public void AppendPathDelimited(IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) - { - delimiter ??= ","; - IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); - AppendPath(string.Join(delimiter, stringValues), escape); - } - - public void AppendQuery(string name, string value, bool escape) - { - if (PathAndQuery.Length == _pathLength) - { - PathAndQuery.Append('?'); - } - if (PathAndQuery.Length > _pathLength && PathAndQuery[PathAndQuery.Length - 1] != '?') - { - PathAndQuery.Append('&'); - } - if (escape) - { - value = Uri.EscapeDataString(value); - } - PathAndQuery.Append(name); - PathAndQuery.Append('='); - PathAndQuery.Append(value); - } - - public void AppendQuery(string name, bool value, bool escape = false) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - - public void AppendQuery(string name, float value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - - public void AppendQuery(string name, DateTimeOffset value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); - - public void AppendQuery(string name, TimeSpan value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); - - public void AppendQuery(string name, double value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - - public void AppendQuery(string name, decimal value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - - public void AppendQuery(string name, int value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - - public void AppendQuery(string name, long value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - - public void AppendQuery(string name, TimeSpan value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - - public void AppendQuery(string name, byte[] value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); - - public void AppendQuery(string name, Guid value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - - public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) - { - delimiter ??= ","; - IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); - AppendQuery(name, string.Join(delimiter, stringValues), escape); - } - - public void UpdateQuery(string name, string value) - { - if (PathAndQuery.Length == _pathLength) - { - AppendQuery(name, value, false); - } - else - { - int queryStartIndex = _pathLength + 1; - string searchPattern = name + "="; - string queryString = PathAndQuery.ToString(queryStartIndex, PathAndQuery.Length - queryStartIndex); - int paramStartIndex = -1; - if (queryString.StartsWith(searchPattern)) - { - paramStartIndex = 0; - } - if (paramStartIndex == -1) - { - int prefixedIndex = queryString.IndexOf("&" + searchPattern); - if (prefixedIndex >= 0) - { - paramStartIndex = prefixedIndex + 1; - } - } - if (paramStartIndex >= 0) - { - int valueStartIndex = paramStartIndex + searchPattern.Length; - int valueEndIndex = queryString.IndexOf('&', valueStartIndex); - if (valueEndIndex == -1) - { - valueEndIndex = queryString.Length; - } - int globalStart = queryStartIndex + valueStartIndex; - int globalEnd = queryStartIndex + valueEndIndex; - PathAndQuery.Remove(globalStart, globalEnd - globalStart); - PathAndQuery.Insert(globalStart, value); - } - else - { - AppendQuery(name, value, false); - } - } - } - - public Uri ToUri() - { - UriBuilder.Path = PathAndQuery.ToString(0, _pathLength); - if (PathAndQuery.Length > _pathLength) - { - UriBuilder.Query = PathAndQuery.ToString(_pathLength + 1, PathAndQuery.Length - _pathLength - 1); - } - if (PathAndQuery.Length == _pathLength) - { - UriBuilder.Query = ""; - } - return UriBuilder.Uri; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenMemberAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenMemberAttribute.cs deleted file mode 100644 index 044dfe314c5..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenMemberAttribute.cs +++ /dev/null @@ -1,17 +0,0 @@ -// - -#nullable disable - -using System; - -namespace Microsoft.TypeSpec.Generator.Customizations -{ - [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] - internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute - { - /// The original name of the member. - public CodeGenMemberAttribute(string originalName) : base(originalName) - { - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSerializationAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSerializationAttribute.cs deleted file mode 100644 index aedb8b359b8..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSerializationAttribute.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System; - -namespace Microsoft.TypeSpec.Generator.Customizations -{ - [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] - internal partial class CodeGenSerializationAttribute : Attribute - { - /// The property name which these hooks apply to. - public CodeGenSerializationAttribute(string propertyName) - { - PropertyName = propertyName; - } - - /// The property name which these hooks apply to. - /// The serialization name of the property. - public CodeGenSerializationAttribute(string propertyName, string serializationName) - { - PropertyName = propertyName; - SerializationName = serializationName; - } - - /// Gets or sets the property name which these hooks should apply to. - public string PropertyName { get; } - - /// Gets or sets the serialization name of the property. - public string SerializationName { get; set; } - - /// - /// Gets or sets the method name to use when serializing the property value (property name excluded). - /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); - /// - public string SerializationValueHook { get; set; } - - /// - /// Gets or sets the method name to use when deserializing the property value from the JSON. - /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required - /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional - /// - public string DeserializationValueHook { get; set; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSuppressAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSuppressAttribute.cs deleted file mode 100644 index 601ded913ab..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenSuppressAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -// - -#nullable disable - -using System; - -namespace Microsoft.TypeSpec.Generator.Customizations -{ - [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] - internal partial class CodeGenSuppressAttribute : Attribute - { - /// The member to suppress. - /// The types of the parameters of the member. - public CodeGenSuppressAttribute(string member, params Type[] parameters) - { - Member = member; - Parameters = parameters; - } - - /// Gets the Member. - public string Member { get; } - - /// Gets the Parameters. - public Type[] Parameters { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenTypeAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenTypeAttribute.cs deleted file mode 100644 index d7b56bdccdf..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/CodeGenTypeAttribute.cs +++ /dev/null @@ -1,21 +0,0 @@ -// - -#nullable disable - -using System; - -namespace Microsoft.TypeSpec.Generator.Customizations -{ - [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] - internal partial class CodeGenTypeAttribute : Attribute - { - /// The original name of the type. - public CodeGenTypeAttribute(string originalName) - { - OriginalName = originalName; - } - - /// Gets the OriginalName. - public string OriginalName { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ErrorResult.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ErrorResult.cs deleted file mode 100644 index 1cfd4bc3bb7..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ErrorResult.cs +++ /dev/null @@ -1,24 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - internal partial class ErrorResult : ClientResult - { - private readonly PipelineResponse _response; - private readonly ClientResultException _exception; - - public ErrorResult(PipelineResponse response, ClientResultException exception) : base(default, response) - { - _response = response; - _exception = exception; - } - - /// Gets the Value. - public override T Value => throw _exception; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ModelSerializationExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ModelSerializationExtensions.cs deleted file mode 100644 index b1dab60c152..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/ModelSerializationExtensions.cs +++ /dev/null @@ -1,265 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Runtime.InteropServices; -using System.Text.Json; - -namespace _Type.Union -{ - internal static partial class ModelSerializationExtensions - { - internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); - internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions - { - MaxDepth = 256 - }; - - public static object GetObject(this JsonElement element) - { - switch (element.ValueKind) - { - case JsonValueKind.String: - return element.GetString(); - case JsonValueKind.Number: - if (element.TryGetInt32(out int intValue)) - { - return intValue; - } - if (element.TryGetInt64(out long longValue)) - { - return longValue; - } - return element.GetDouble(); - case JsonValueKind.True: - return true; - case JsonValueKind.False: - return false; - case JsonValueKind.Undefined: - case JsonValueKind.Null: - return null; - case JsonValueKind.Object: - Dictionary dictionary = new Dictionary(); - foreach (var jsonProperty in element.EnumerateObject()) - { - dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); - } - return dictionary; - case JsonValueKind.Array: - List list = new List(); - foreach (var item in element.EnumerateArray()) - { - list.Add(item.GetObject()); - } - return list.ToArray(); - default: - throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); - } - } - - public static byte[] GetBytesFromBase64(this JsonElement element, string format) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - - return format switch - { - "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), - "D" => element.GetBytesFromBase64(), - _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) - }; - } - - public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch - { - "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), - _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) - }; - - public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); - - public static char GetChar(this JsonElement element) - { - if (element.ValueKind == JsonValueKind.String) - { - string text = element.GetString(); - if (text == null || text.Length != 1) - { - throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); - } - return text[0]; - } - else - { - throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); - } - } - - [Conditional("DEBUG")] - public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) - { - throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); - } - - public static string GetRequiredString(this JsonElement element) - { - string value = element.GetString(); - if (value == null) - { - throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); - } - return value; - } - - public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) - { - writer.WriteStringValue(TypeFormatters.ToString(value, format)); - } - - public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) - { - writer.WriteStringValue(TypeFormatters.ToString(value, format)); - } - - public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) - { - writer.WriteStringValue(TypeFormatters.ToString(value, format)); - } - - public static void WriteStringValue(this Utf8JsonWriter writer, char value) - { - writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); - } - - public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) - { - if (value == null) - { - writer.WriteNullValue(); - return; - } - switch (format) - { - case "U": - writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); - break; - case "D": - writer.WriteBase64StringValue(value); - break; - default: - throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); - } - } - - public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) - { - if (format != "U") - { - throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); - } - writer.WriteNumberValue(value.ToUnixTimeSeconds()); - } - - public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) - { - switch (value) - { - case null: - writer.WriteNullValue(); - break; - case IJsonModel jsonModel: - jsonModel.Write(writer, options ?? WireOptions); - break; - case byte[] bytes: - writer.WriteBase64StringValue(bytes); - break; - case BinaryData bytes0: - writer.WriteBase64StringValue(bytes0); - break; - case JsonElement json: - json.WriteTo(writer); - break; - case int i: - writer.WriteNumberValue(i); - break; - case decimal d: - writer.WriteNumberValue(d); - break; - case double d0: - if (double.IsNaN(d0)) - { - writer.WriteStringValue("NaN"); - } - else - { - writer.WriteNumberValue(d0); - } - break; - case float f: - writer.WriteNumberValue(f); - break; - case long l: - writer.WriteNumberValue(l); - break; - case string s: - writer.WriteStringValue(s); - break; - case bool b: - writer.WriteBooleanValue(b); - break; - case Guid g: - writer.WriteStringValue(g); - break; - case DateTimeOffset dateTimeOffset: - writer.WriteStringValue(dateTimeOffset, "O"); - break; - case DateTime dateTime: - writer.WriteStringValue(dateTime, "O"); - break; - case IEnumerable> enumerable: - writer.WriteStartObject(); - foreach (var pair in enumerable) - { - writer.WritePropertyName(pair.Key); - writer.WriteObjectValue(pair.Value, options); - } - writer.WriteEndObject(); - break; - case IEnumerable objectEnumerable: - writer.WriteStartArray(); - foreach (var item in objectEnumerable) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - break; - case TimeSpan timeSpan: - writer.WriteStringValue(timeSpan, "P"); - break; - default: - throw new NotSupportedException($"Not supported type {value.GetType()}"); - } - } - - public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) - { - writer.WriteObjectValue(value, options); - } - - public static BinaryData GetUtf8Bytes(this JsonElement element) - { -#if NET9_0_OR_GREATER - return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); -#else - return BinaryData.FromString(element.GetRawText()); -#endif - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/SerializationFormat.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/SerializationFormat.cs deleted file mode 100644 index 2957f681312..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/SerializationFormat.cs +++ /dev/null @@ -1,46 +0,0 @@ -// - -#nullable disable - -namespace _Type.Union -{ - internal enum SerializationFormat - { - /// The default serialization format. - Default = 0, - /// The RFC1123 date time format. - DateTime_RFC1123 = 1, - /// The RFC3339 date time format. - DateTime_RFC3339 = 2, - /// The RFC7231 date time format. - DateTime_RFC7231 = 3, - /// The ISO8601 date time format. - DateTime_ISO8601 = 4, - /// The Unix date time format. - DateTime_Unix = 5, - /// The ISO8601 date format. - Date_ISO8601 = 6, - /// The ISO8601 duration format. - Duration_ISO8601 = 7, - /// The constant duration format. - Duration_Constant = 8, - /// The seconds duration format. - Duration_Seconds = 9, - /// The seconds duration format with float precision. - Duration_Seconds_Float = 10, - /// The seconds duration format with double precision. - Duration_Seconds_Double = 11, - /// The milliseconds duration format. - Duration_Milliseconds = 12, - /// The milliseconds duration format with float precision. - Duration_Milliseconds_Float = 13, - /// The milliseconds duration format with double precision. - Duration_Milliseconds_Double = 14, - /// The ISO8601 time format. - Time_ISO8601 = 15, - /// The Base64Url bytes format. - Bytes_Base64Url = 16, - /// The Base64 bytes format. - Bytes_Base64 = 17 - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/TypeFormatters.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/TypeFormatters.cs deleted file mode 100644 index 90ca993c473..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Internal/TypeFormatters.cs +++ /dev/null @@ -1,178 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Xml; - -namespace _Type.Union -{ - internal static partial class TypeFormatters - { - private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; - public const string DefaultNumberFormat = "G"; - - public static string ToString(bool value) => value ? "true" : "false"; - - public static string ToString(DateTime value, string format) => value.Kind switch - { - DateTimeKind.Utc => ToString((DateTimeOffset)value, format), - _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") - }; - - public static string ToString(DateTimeOffset value, string format) => format switch - { - "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), - "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), - "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "R" => value.ToString("r", CultureInfo.InvariantCulture), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(TimeSpan value, string format) => format switch - { - "P" => XmlConvert.ToString(value), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(byte[] value, string format) => format switch - { - "U" => ToBase64UrlString(value), - "D" => Convert.ToBase64String(value), - _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) - }; - - public static string ToBase64UrlString(byte[] value) - { - int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; - int size = checked (numWholeOrPartialInputBlocks * 4); - char[] output = new char[size]; - - int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); - - int i = 0; - for (; i < numBase64Chars; i++) - { - char ch = output[i]; - if (ch == '+') - { - output[i] = '-'; - } - else - { - if (ch == '/') - { - output[i] = '_'; - } - else - { - if (ch == '=') - { - break; - } - } - } - } - - return new string(output, 0, i); - } - - public static byte[] FromBase64UrlString(string value) - { - int paddingCharsToAdd = (value.Length % 4) switch - { - 0 => 0, - 2 => 2, - 3 => 1, - _ => throw new InvalidOperationException("Malformed input") - }; - char[] output = new char[(value.Length + paddingCharsToAdd)]; - int i = 0; - for (; i < value.Length; i++) - { - char ch = value[i]; - if (ch == '-') - { - output[i] = '+'; - } - else - { - if (ch == '_') - { - output[i] = '/'; - } - else - { - output[i] = ch; - } - } - } - - for (; i < output.Length; i++) - { - output[i] = '='; - } - - return Convert.FromBase64CharArray(output, 0, output.Length); - } - - public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch - { - "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), - _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) - }; - - public static TimeSpan ParseTimeSpan(string value, string format) => format switch - { - "P" => XmlConvert.ToTimeSpan(value), - _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) - }; - - public static string ToFormatSpecifier(SerializationFormat format) => format switch - { - SerializationFormat.DateTime_RFC1123 => "R", - SerializationFormat.DateTime_RFC3339 => "O", - SerializationFormat.DateTime_RFC7231 => "R", - SerializationFormat.DateTime_ISO8601 => "O", - SerializationFormat.Date_ISO8601 => "D", - SerializationFormat.DateTime_Unix => "U", - SerializationFormat.Bytes_Base64Url => "U", - SerializationFormat.Bytes_Base64 => "D", - SerializationFormat.Duration_ISO8601 => "P", - SerializationFormat.Duration_Constant => "c", - SerializationFormat.Duration_Seconds => "%s", - SerializationFormat.Duration_Seconds_Float => "s\\.FFF", - SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", - SerializationFormat.Time_ISO8601 => "T", - _ => null - }; - - public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) - { - string formatSpecifier = ToFormatSpecifier(format); - - return value switch - { - null => "null", - string s => s, - bool b => ToString(b), - int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), - byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), - IEnumerable s0 => string.Join(",", s0), - DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), - TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), - TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), - TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), - TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), - TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), - TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), - Guid guid => guid.ToString(), - BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), - _ => value.ToString() - }; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.RestClient.cs deleted file mode 100644 index 3b5137e244a..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class IntsOnly - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/ints-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/ints-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.cs index 1e67195b62b..d9e64843d11 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/IntsOnly.cs @@ -10,140 +10,28 @@ namespace _Type.Union { - /// Describe union of integer 1 | 2 | 3. public partial class IntsOnly { - private readonly Uri _endpoint; + protected IntsOnly() => throw null; - /// Initializes a new instance of IntsOnly for mocking. - protected IntsOnly() - { - } + internal IntsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of IntsOnly. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal IntsOnly(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse3)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse3)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(GetResponseProp2 prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Send(GetResponseProp2 prop, CancellationToken cancellationToken = default) - { - SendRequest3 spreadModel = new SendRequest3(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task SendAsync(GetResponseProp2 prop, CancellationToken cancellationToken = default) - { - SendRequest3 spreadModel = new SendRequest3(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(GetResponseProp2 prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.RestClient.cs deleted file mode 100644 index b203b0b34e9..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class MixedLiterals - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/mixed-literals", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/mixed-literals", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.cs index 3b61e3a399b..7ee7a6ee49c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedLiterals.cs @@ -10,146 +10,28 @@ namespace _Type.Union { - /// Describe union of floats "a" | 2 | 3.3. public partial class MixedLiterals { - private readonly Uri _endpoint; + protected MixedLiterals() => throw null; - /// Initializes a new instance of MixedLiterals for mocking. - protected MixedLiterals() - { - } + internal MixedLiterals(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of MixedLiterals. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal MixedLiterals(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse8)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse8)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(MixedLiteralsCases prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual ClientResult Send(MixedLiteralsCases prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest8 spreadModel = new SendRequest8(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual async Task SendAsync(MixedLiteralsCases prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest8 spreadModel = new SendRequest8(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(MixedLiteralsCases prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.RestClient.cs deleted file mode 100644 index 3f91f0b4dc2..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class MixedTypes - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/mixed-types", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/mixed-types", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.cs index 942f8daa1d3..b7ae1cff2e4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/MixedTypes.cs @@ -10,146 +10,28 @@ namespace _Type.Union { - /// Describe union of floats "a" | 2 | 3.3. public partial class MixedTypes { - private readonly Uri _endpoint; + protected MixedTypes() => throw null; - /// Initializes a new instance of MixedTypes for mocking. - protected MixedTypes() - { - } + internal MixedTypes(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of MixedTypes. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal MixedTypes(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse9)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse9)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(MixedTypesCases prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual ClientResult Send(MixedTypesCases prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest9 spreadModel = new SendRequest9(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual async Task SendAsync(MixedTypesCases prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest9 spreadModel = new SendRequest9(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(MixedTypesCases prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.Serialization.cs index 674b11c943e..376f80256c6 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.Serialization.cs @@ -4,136 +4,30 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The Cat. public partial class Cat : IJsonModel { - /// Initializes a new instance of for deserialization. - internal Cat() - { - } + internal Cat() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual Cat PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeCat(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Cat)} does not support reading '{options.Format}' format."); - } - } + protected virtual Cat PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(Cat)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - Cat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + Cat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(Cat)} does not support writing '{format}' format."); - } - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - Cat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + Cat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual Cat JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(Cat)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCat(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static Cat DeserializeCat(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("name"u8)) - { - name = prop.Value.GetString(); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new Cat(name, additionalBinaryDataProperties); - } + protected virtual Cat JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.cs index 5ad0b393d9b..fe5cca7c7c0 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Cat.cs @@ -2,37 +2,16 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The Cat. public partial class Cat { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - /// is null. - public Cat(string name) - { - Argument.AssertNotNull(name, nameof(name)); + public Cat(string name) => throw null; - Name = name; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal Cat(string name, IDictionary additionalBinaryDataProperties) + public string Name { - Name = name; - _additionalBinaryDataProperties = additionalBinaryDataProperties; + get => throw null; + set => throw null; } - - /// Gets or sets the Name. - public string Name { get; set; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.Serialization.cs index 8fcd3193ed5..1391a71d84b 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.Serialization.cs @@ -4,136 +4,30 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The Dog. public partial class Dog : IJsonModel { - /// Initializes a new instance of for deserialization. - internal Dog() - { - } + internal Dog() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual Dog PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeDog(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Dog)} does not support reading '{options.Format}' format."); - } - } + protected virtual Dog PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(Dog)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - Dog IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + Dog IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(Dog)} does not support writing '{format}' format."); - } - writer.WritePropertyName("bark"u8); - writer.WriteStringValue(Bark); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - Dog IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + Dog IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual Dog JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(Dog)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDog(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static Dog DeserializeDog(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string bark = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("bark"u8)) - { - bark = prop.Value.GetString(); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new Dog(bark, additionalBinaryDataProperties); - } + protected virtual Dog JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.cs index a00fd9aa254..1754f6b7635 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/Dog.cs @@ -2,37 +2,16 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The Dog. public partial class Dog { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - /// is null. - public Dog(string bark) - { - Argument.AssertNotNull(bark, nameof(bark)); + public Dog(string bark) => throw null; - Bark = bark; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal Dog(string bark, IDictionary additionalBinaryDataProperties) + public string Bark { - Bark = bark; - _additionalBinaryDataProperties = additionalBinaryDataProperties; + get => throw null; + set => throw null; } - - /// Gets or sets the Bark. - public string Bark { get; set; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.Serialization.cs index 7f5a11d2f92..ff9d24c1364 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.Serialization.cs @@ -4,144 +4,30 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The EnumsOnlyCases. public partial class EnumsOnlyCases : IJsonModel { - /// Initializes a new instance of for deserialization. - internal EnumsOnlyCases() - { - } + internal EnumsOnlyCases() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual EnumsOnlyCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeEnumsOnlyCases(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(EnumsOnlyCases)} does not support reading '{options.Format}' format."); - } - } + protected virtual EnumsOnlyCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(EnumsOnlyCases)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - EnumsOnlyCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + EnumsOnlyCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(EnumsOnlyCases)} does not support writing '{format}' format."); - } - writer.WritePropertyName("lr"u8); - writer.WriteStringValue(Lr.ToSerialString()); - writer.WritePropertyName("ud"u8); - writer.WriteStringValue(Ud.ToSerialString()); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - EnumsOnlyCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + EnumsOnlyCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual EnumsOnlyCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(EnumsOnlyCases)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeEnumsOnlyCases(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static EnumsOnlyCases DeserializeEnumsOnlyCases(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - EnumsOnlyCasesLr lr = default; - EnumsOnlyCasesUd ud = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("lr"u8)) - { - lr = prop.Value.GetString().ToEnumsOnlyCasesLr(); - continue; - } - if (prop.NameEquals("ud"u8)) - { - ud = prop.Value.GetString().ToEnumsOnlyCasesUd(); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new EnumsOnlyCases(lr, ud, additionalBinaryDataProperties); - } + protected virtual EnumsOnlyCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.cs index 6fbc23ffd72..f70f5f7d7b4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCases.cs @@ -2,41 +2,22 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The EnumsOnlyCases. public partial class EnumsOnlyCases { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; + public EnumsOnlyCases(EnumsOnlyCasesLr lr, EnumsOnlyCasesUd ud) => throw null; - /// Initializes a new instance of . - /// This should be receive/send the left variant. - /// This should be receive/send the up variant. - public EnumsOnlyCases(EnumsOnlyCasesLr lr, EnumsOnlyCasesUd ud) + public EnumsOnlyCasesLr Lr { - Lr = lr; - Ud = ud; + get => throw null; + set => throw null; } - /// Initializes a new instance of . - /// This should be receive/send the left variant. - /// This should be receive/send the up variant. - /// Keeps track of any properties unknown to the library. - internal EnumsOnlyCases(EnumsOnlyCasesLr lr, EnumsOnlyCasesUd ud, IDictionary additionalBinaryDataProperties) + public EnumsOnlyCasesUd Ud { - Lr = lr; - Ud = ud; - _additionalBinaryDataProperties = additionalBinaryDataProperties; + get => throw null; + set => throw null; } - - /// This should be receive/send the left variant. - public EnumsOnlyCasesLr Lr { get; set; } - - /// This should be receive/send the up variant. - public EnumsOnlyCasesUd Ud { get; set; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.Serialization.cs deleted file mode 100644 index d7f98bb901a..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.Serialization.cs +++ /dev/null @@ -1,43 +0,0 @@ -// - -#nullable disable - -using System; - -namespace _Type.Union -{ - internal static partial class EnumsOnlyCasesLrExtensions - { - /// The value to serialize. - public static string ToSerialString(this EnumsOnlyCasesLr value) => value switch - { - EnumsOnlyCasesLr.Left => "left", - EnumsOnlyCasesLr.Right => "right", - EnumsOnlyCasesLr.Up => "up", - EnumsOnlyCasesLr.Down => "down", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EnumsOnlyCasesLr value.") - }; - - /// The value to deserialize. - public static EnumsOnlyCasesLr ToEnumsOnlyCasesLr(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "left")) - { - return EnumsOnlyCasesLr.Left; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "right")) - { - return EnumsOnlyCasesLr.Right; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "up")) - { - return EnumsOnlyCasesLr.Up; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "down")) - { - return EnumsOnlyCasesLr.Down; - } - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EnumsOnlyCasesLr value."); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.cs index 24207fe0d94..27cb65862f7 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesLr.cs @@ -4,7 +4,6 @@ namespace _Type.Union { - /// public enum EnumsOnlyCasesLr { /// Left. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.Serialization.cs deleted file mode 100644 index ee74820e099..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; - -namespace _Type.Union -{ - internal static partial class EnumsOnlyCasesUdExtensions - { - /// The value to serialize. - public static string ToSerialString(this EnumsOnlyCasesUd value) => value switch - { - EnumsOnlyCasesUd.Up => "up", - EnumsOnlyCasesUd.Down => "down", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EnumsOnlyCasesUd value.") - }; - - /// The value to deserialize. - public static EnumsOnlyCasesUd ToEnumsOnlyCasesUd(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "up")) - { - return EnumsOnlyCasesUd.Up; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "down")) - { - return EnumsOnlyCasesUd.Down; - } - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EnumsOnlyCasesUd value."); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.cs index a8a4ad78173..e58e353aae8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/EnumsOnlyCasesUd.cs @@ -4,7 +4,6 @@ namespace _Type.Union { - /// public enum EnumsOnlyCasesUd { /// Up. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.Serialization.cs index 27cde67bb98..9d2744ca516 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.Serialization.cs @@ -5,144 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse. public partial class GetResponse : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse() - { - } + internal GetResponse() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteStringValue(Prop.ToSerialString()); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse DeserializeGetResponse(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - GetResponseProp prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = prop0.Value.GetString().ToGetResponseProp(); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.cs index b3cd16348ea..74aff777d1c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse.cs @@ -2,34 +2,10 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The GetResponse. public partial class GetResponse { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse(GetResponseProp prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse(GetResponseProp prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public GetResponseProp Prop { get; } + public GetResponseProp Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.Serialization.cs index 0b78fab41f3..a8892f65c6f 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.Serialization.cs @@ -5,144 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse1. public partial class GetResponse1 : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse1() - { - } + internal GetResponse1() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse1(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse1)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse1)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse1(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse1(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse1(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse1)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteStringValue(Prop.ToString()); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse1)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse1(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse1 DeserializeGetResponse1(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - GetResponseProp1 prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = new GetResponseProp1(prop0.Value.GetString()); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse1(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.cs index f1692689b4f..7477f04cb55 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse1.cs @@ -2,34 +2,10 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The GetResponse1. public partial class GetResponse1 { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse1(GetResponseProp1 prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse1(GetResponseProp1 prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public GetResponseProp1 Prop { get; } + public GetResponseProp1 Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.Serialization.cs index 005b56521e9..95f5cd6f4f6 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.Serialization.cs @@ -5,144 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse2. public partial class GetResponse2 : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse2() - { - } + internal GetResponse2() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse2(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse2)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse2)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse2(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse2(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse2(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse2)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteStringValue(Prop.ToString()); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse2)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse2(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse2 DeserializeGetResponse2(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StringExtensibleNamedUnion prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = new StringExtensibleNamedUnion(prop0.Value.GetString()); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse2(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.cs index d088b4846e4..780d585e5a6 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse2.cs @@ -2,34 +2,10 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The GetResponse2. public partial class GetResponse2 { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse2(StringExtensibleNamedUnion prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse2(StringExtensibleNamedUnion prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public StringExtensibleNamedUnion Prop { get; } + public StringExtensibleNamedUnion Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.Serialization.cs index e73c98ad822..9b5d45f0680 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.Serialization.cs @@ -5,144 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse3. public partial class GetResponse3 : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse3() - { - } + internal GetResponse3() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse3 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse3(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse3)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse3 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse3)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse3(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse3(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse3(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse3)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteNumberValue((int)Prop); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse3 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse3)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse3(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse3 DeserializeGetResponse3(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - GetResponseProp2 prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = prop0.Value.GetInt32().ToGetResponseProp2(); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse3(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse3 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.cs index 9468d7c9d89..628db49f452 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse3.cs @@ -2,34 +2,10 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The GetResponse3. public partial class GetResponse3 { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse3(GetResponseProp2 prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse3(GetResponseProp2 prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public GetResponseProp2 Prop { get; } + public GetResponseProp2 Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.Serialization.cs index 0797692888b..e33960ba0be 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.Serialization.cs @@ -5,144 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse4. public partial class GetResponse4 : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse4() - { - } + internal GetResponse4() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse4 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse4(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse4)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse4 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse4)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse4 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse4 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse4(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse4(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse4(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse4)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteNumberValue(Prop.ToSerialSingle()); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse4 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse4 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse4 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse4)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse4(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse4 DeserializeGetResponse4(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - GetResponseProp3 prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = prop0.Value.GetSingle().ToGetResponseProp3(); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse4(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse4 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.cs index 5894f1059eb..98a7b15d523 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse4.cs @@ -2,34 +2,10 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The GetResponse4. public partial class GetResponse4 { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse4(GetResponseProp3 prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse4(GetResponseProp3 prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public GetResponseProp3 Prop { get; } + public GetResponseProp3 Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.Serialization.cs index ec7706f6134..9ef18e2e1e0 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.Serialization.cs @@ -5,151 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse5. public partial class GetResponse5 : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse5() - { - } + internal GetResponse5() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse5 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse5(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse5)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse5 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse5)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse5 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse5 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse5(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse5(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse5(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse5)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Prop); -#else - using (JsonDocument document = JsonDocument.Parse(Prop)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse5 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse5 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse5 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse5)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse5(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse5 DeserializeGetResponse5(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - BinaryData prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = BinaryData.FromString(prop0.Value.GetRawText()); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse5(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse5 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.cs index 04e4c65f91e..caeec0431b1 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse5.cs @@ -3,72 +3,11 @@ #nullable disable using System; -using System.Collections.Generic; -using System.Text.Json; namespace _Type.Union { - /// The GetResponse5. public partial class GetResponse5 { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse5(BinaryData prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse5(BinaryData prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// - /// Gets the Prop. - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// . - /// - /// - /// . - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData Prop { get; } + public BinaryData Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.Serialization.cs index b7713be5cfe..d8d40f051ac 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.Serialization.cs @@ -5,144 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse6. public partial class GetResponse6 : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse6() - { - } + internal GetResponse6() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse6 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse6(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse6)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse6 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse6)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse6 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse6 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse6(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse6(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse6(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse6)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteObjectValue(Prop, options); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse6 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse6 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse6 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse6)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse6(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse6 DeserializeGetResponse6(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - EnumsOnlyCases prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = EnumsOnlyCases.DeserializeEnumsOnlyCases(prop0.Value, options); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse6(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse6 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.cs index 7dde2ad490a..f07f02a9b43 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse6.cs @@ -2,34 +2,10 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The GetResponse6. public partial class GetResponse6 { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse6(EnumsOnlyCases prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse6(EnumsOnlyCases prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public EnumsOnlyCases Prop { get; } + public EnumsOnlyCases Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.Serialization.cs index ba7a55b7e0f..7fef9678a03 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.Serialization.cs @@ -5,144 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse7. public partial class GetResponse7 : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse7() - { - } + internal GetResponse7() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse7 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse7(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse7)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse7 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse7)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse7 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse7 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse7(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse7(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse7(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse7)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteObjectValue(Prop, options); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse7 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse7 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse7 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse7)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse7(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse7 DeserializeGetResponse7(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StringAndArrayCases prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = StringAndArrayCases.DeserializeStringAndArrayCases(prop0.Value, options); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse7(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse7 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.cs index 3b1e3983314..a96c8ca6b4d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse7.cs @@ -2,34 +2,10 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The GetResponse7. public partial class GetResponse7 { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse7(StringAndArrayCases prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse7(StringAndArrayCases prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public StringAndArrayCases Prop { get; } + public StringAndArrayCases Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.Serialization.cs index 556119b5fbd..85c826e7d9e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.Serialization.cs @@ -5,144 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse8. public partial class GetResponse8 : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse8() - { - } + internal GetResponse8() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse8 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse8(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse8)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse8 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse8)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse8 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse8 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse8(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse8(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse8(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse8)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteObjectValue(Prop, options); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse8 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse8 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse8 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse8)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse8(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse8 DeserializeGetResponse8(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MixedLiteralsCases prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = MixedLiteralsCases.DeserializeMixedLiteralsCases(prop0.Value, options); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse8(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse8 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.cs index 87d5cf38391..d98e8de1c81 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse8.cs @@ -2,34 +2,10 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The GetResponse8. public partial class GetResponse8 { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse8(MixedLiteralsCases prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse8(MixedLiteralsCases prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public MixedLiteralsCases Prop { get; } + public MixedLiteralsCases Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.Serialization.cs index 7660e4a3c66..c6c7a43fdf1 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.Serialization.cs @@ -5,144 +5,32 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The GetResponse9. public partial class GetResponse9 : IJsonModel { - /// Initializes a new instance of for deserialization. - internal GetResponse9() - { - } + internal GetResponse9() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetResponse9 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetResponse9(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetResponse9)} does not support reading '{options.Format}' format."); - } - } + protected virtual GetResponse9 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(GetResponse9)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - GetResponse9 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + GetResponse9 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The to deserialize the from. - public static explicit operator GetResponse9(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetResponse9(document.RootElement, ModelSerializationExtensions.WireOptions); - } + public static explicit operator GetResponse9(ClientResult result) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse9)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteObjectValue(Prop, options); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - GetResponse9 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + GetResponse9 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual GetResponse9 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GetResponse9)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGetResponse9(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static GetResponse9 DeserializeGetResponse9(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MixedTypesCases prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = MixedTypesCases.DeserializeMixedTypesCases(prop0.Value, options); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new GetResponse9(prop, additionalBinaryDataProperties); - } + protected virtual GetResponse9 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.cs index ff1364d442d..3edebb7b4d0 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponse9.cs @@ -2,34 +2,10 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace _Type.Union { - /// The GetResponse9. public partial class GetResponse9 { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal GetResponse9(MixedTypesCases prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal GetResponse9(MixedTypesCases prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public MixedTypesCases Prop { get; } + public MixedTypesCases Prop => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.Serialization.cs deleted file mode 100644 index f4b1a4e0a7d..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.Serialization.cs +++ /dev/null @@ -1,38 +0,0 @@ -// - -#nullable disable - -using System; - -namespace _Type.Union -{ - internal static partial class GetResponsePropExtensions - { - /// The value to serialize. - public static string ToSerialString(this GetResponseProp value) => value switch - { - GetResponseProp.A => "a", - GetResponseProp.B => "b", - GetResponseProp.C => "c", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp value.") - }; - - /// The value to deserialize. - public static GetResponseProp ToGetResponseProp(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "a")) - { - return GetResponseProp.A; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "b")) - { - return GetResponseProp.B; - } - if (StringComparer.OrdinalIgnoreCase.Equals(value, "c")) - { - return GetResponseProp.C; - } - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp value."); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.cs index 3fa6e8be673..2440b719c44 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp.cs @@ -4,7 +4,6 @@ namespace _Type.Union { - /// public enum GetResponseProp { /// A. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp1.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp1.cs index ddc1d67d79c..9260592f572 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp1.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp1.cs @@ -7,59 +7,30 @@ namespace _Type.Union { - /// public readonly partial struct GetResponseProp1 : IEquatable { - private readonly string _value; - private const string BValue = "b"; - private const string CValue = "c"; + public GetResponseProp1(string value) => throw null; - /// Initializes a new instance of . - /// The value. - /// is null. - public GetResponseProp1(string value) - { - Argument.AssertNotNull(value, nameof(value)); + public static GetResponseProp1 B => throw null; - _value = value; - } + public static GetResponseProp1 C => throw null; - /// Gets the B. - public static GetResponseProp1 B { get; } = new GetResponseProp1(BValue); + public static bool operator ==(GetResponseProp1 left, GetResponseProp1 right) => throw null; - /// Gets the C. - public static GetResponseProp1 C { get; } = new GetResponseProp1(CValue); + public static bool operator !=(GetResponseProp1 left, GetResponseProp1 right) => throw null; - /// Determines if two values are the same. - /// The left value to compare. - /// The right value to compare. - public static bool operator ==(GetResponseProp1 left, GetResponseProp1 right) => left.Equals(right); + public static implicit operator GetResponseProp1(string value) => throw null; - /// Determines if two values are not the same. - /// The left value to compare. - /// The right value to compare. - public static bool operator !=(GetResponseProp1 left, GetResponseProp1 right) => !left.Equals(right); + public static implicit operator GetResponseProp1?(string value) => throw null; - /// Converts a string to a . - /// The value. - public static implicit operator GetResponseProp1(string value) => new GetResponseProp1(value); - - /// Converts a string to a . - /// The value. - public static implicit operator GetResponseProp1?(string value) => value == null ? null : new GetResponseProp1(value); - - /// [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is GetResponseProp1 other && Equals(other); + public override bool Equals(object obj) => throw null; - /// - public bool Equals(GetResponseProp1 other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + public bool Equals(GetResponseProp1 other) => throw null; - /// [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override int GetHashCode() => throw null; - /// - public override string ToString() => _value; + public override string ToString() => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.Serialization.cs deleted file mode 100644 index 2398ba89264..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.Serialization.cs +++ /dev/null @@ -1,29 +0,0 @@ -// - -#nullable disable - -using System; - -namespace _Type.Union -{ - internal static partial class GetResponseProp2Extensions - { - /// The value to deserialize. - public static GetResponseProp2 ToGetResponseProp2(this int value) - { - if (value == 1) - { - return GetResponseProp2._1; - } - if (value == 2) - { - return GetResponseProp2._2; - } - if (value == 3) - { - return GetResponseProp2._3; - } - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp2 value."); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.cs index 36a40c30d13..f0738ab58e4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp2.cs @@ -4,7 +4,6 @@ namespace _Type.Union { - /// public enum GetResponseProp2 { /// _1. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.Serialization.cs deleted file mode 100644 index b365a689de4..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.Serialization.cs +++ /dev/null @@ -1,38 +0,0 @@ -// - -#nullable disable - -using System; - -namespace _Type.Union -{ - internal static partial class GetResponseProp3Extensions - { - /// The value to serialize. - public static float ToSerialSingle(this GetResponseProp3 value) => value switch - { - GetResponseProp3._11 => 1.1F, - GetResponseProp3._22 => 2.2F, - GetResponseProp3._33 => 3.3F, - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp3 value.") - }; - - /// The value to deserialize. - public static GetResponseProp3 ToGetResponseProp3(this float value) - { - if (value == 1.1F) - { - return GetResponseProp3._11; - } - if (value == 2.2F) - { - return GetResponseProp3._22; - } - if (value == 3.3F) - { - return GetResponseProp3._33; - } - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GetResponseProp3 value."); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.cs index f33a94513de..b5820868a73 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/GetResponseProp3.cs @@ -4,7 +4,6 @@ namespace _Type.Union { - /// public enum GetResponseProp3 { /// _11. diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.Serialization.cs index 4b1b23f5e7d..8115f8b6175 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.Serialization.cs @@ -4,188 +4,30 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The MixedLiteralsCases. public partial class MixedLiteralsCases : IJsonModel { - /// Initializes a new instance of for deserialization. - internal MixedLiteralsCases() - { - } + internal MixedLiteralsCases() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual MixedLiteralsCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeMixedLiteralsCases(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MixedLiteralsCases)} does not support reading '{options.Format}' format."); - } - } + protected virtual MixedLiteralsCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(MixedLiteralsCases)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - MixedLiteralsCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + MixedLiteralsCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MixedLiteralsCases)} does not support writing '{format}' format."); - } - writer.WritePropertyName("stringLiteral"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(StringLiteral); -#else - using (JsonDocument document = JsonDocument.Parse(StringLiteral)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - writer.WritePropertyName("intLiteral"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(IntLiteral); -#else - using (JsonDocument document = JsonDocument.Parse(IntLiteral)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - writer.WritePropertyName("floatLiteral"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(FloatLiteral); -#else - using (JsonDocument document = JsonDocument.Parse(FloatLiteral)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - writer.WritePropertyName("booleanLiteral"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(BooleanLiteral); -#else - using (JsonDocument document = JsonDocument.Parse(BooleanLiteral)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - MixedLiteralsCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + MixedLiteralsCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual MixedLiteralsCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MixedLiteralsCases)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMixedLiteralsCases(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static MixedLiteralsCases DeserializeMixedLiteralsCases(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - BinaryData stringLiteral = default; - BinaryData intLiteral = default; - BinaryData floatLiteral = default; - BinaryData booleanLiteral = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("stringLiteral"u8)) - { - stringLiteral = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (prop.NameEquals("intLiteral"u8)) - { - intLiteral = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (prop.NameEquals("floatLiteral"u8)) - { - floatLiteral = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (prop.NameEquals("booleanLiteral"u8)) - { - booleanLiteral = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new MixedLiteralsCases(stringLiteral, intLiteral, floatLiteral, booleanLiteral, additionalBinaryDataProperties); - } + protected virtual MixedLiteralsCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.cs index b608c06e983..3861282b549 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedLiteralsCases.cs @@ -3,237 +3,35 @@ #nullable disable using System; -using System.Collections.Generic; -using System.Text.Json; namespace _Type.Union { - /// The MixedLiteralsCases. public partial class MixedLiteralsCases { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; + public MixedLiteralsCases(BinaryData stringLiteral, BinaryData intLiteral, BinaryData floatLiteral, BinaryData booleanLiteral) => throw null; - /// Initializes a new instance of . - /// This should be receive/send the "a" variant. - /// This should be receive/send the 2 variant. - /// This should be receive/send the 3.3 variant. - /// This should be receive/send the true variant. - /// , , or is null. - public MixedLiteralsCases(BinaryData stringLiteral, BinaryData intLiteral, BinaryData floatLiteral, BinaryData booleanLiteral) + public BinaryData StringLiteral { - Argument.AssertNotNull(stringLiteral, nameof(stringLiteral)); - Argument.AssertNotNull(intLiteral, nameof(intLiteral)); - Argument.AssertNotNull(floatLiteral, nameof(floatLiteral)); - Argument.AssertNotNull(booleanLiteral, nameof(booleanLiteral)); - - StringLiteral = stringLiteral; - IntLiteral = intLiteral; - FloatLiteral = floatLiteral; - BooleanLiteral = booleanLiteral; + get => throw null; + set => throw null; } - /// Initializes a new instance of . - /// This should be receive/send the "a" variant. - /// This should be receive/send the 2 variant. - /// This should be receive/send the 3.3 variant. - /// This should be receive/send the true variant. - /// Keeps track of any properties unknown to the library. - internal MixedLiteralsCases(BinaryData stringLiteral, BinaryData intLiteral, BinaryData floatLiteral, BinaryData booleanLiteral, IDictionary additionalBinaryDataProperties) + public BinaryData IntLiteral { - StringLiteral = stringLiteral; - IntLiteral = intLiteral; - FloatLiteral = floatLiteral; - BooleanLiteral = booleanLiteral; - _additionalBinaryDataProperties = additionalBinaryDataProperties; + get => throw null; + set => throw null; } - /// - /// This should be receive/send the "a" variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// "a". - /// - /// - /// 2. - /// - /// - /// 3.3. - /// - /// - /// True. - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData StringLiteral { get; set; } - - /// - /// This should be receive/send the 2 variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// "a". - /// - /// - /// 2. - /// - /// - /// 3.3. - /// - /// - /// True. - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData IntLiteral { get; set; } - - /// - /// This should be receive/send the 3.3 variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// "a". - /// - /// - /// 2. - /// - /// - /// 3.3. - /// - /// - /// True. - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData FloatLiteral { get; set; } + public BinaryData FloatLiteral + { + get => throw null; + set => throw null; + } - /// - /// This should be receive/send the true variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// "a". - /// - /// - /// 2. - /// - /// - /// 3.3. - /// - /// - /// True. - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData BooleanLiteral { get; set; } + public BinaryData BooleanLiteral + { + get => throw null; + set => throw null; + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.Serialization.cs index a0bcdb74419..f2ffbc26a5b 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.Serialization.cs @@ -4,231 +4,30 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The MixedTypesCases. public partial class MixedTypesCases : IJsonModel { - /// Initializes a new instance of for deserialization. - internal MixedTypesCases() - { - } + internal MixedTypesCases() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual MixedTypesCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeMixedTypesCases(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MixedTypesCases)} does not support reading '{options.Format}' format."); - } - } + protected virtual MixedTypesCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(MixedTypesCases)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - MixedTypesCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + MixedTypesCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MixedTypesCases)} does not support writing '{format}' format."); - } - writer.WritePropertyName("model"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Model); -#else - using (JsonDocument document = JsonDocument.Parse(Model)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - writer.WritePropertyName("literal"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Literal); -#else - using (JsonDocument document = JsonDocument.Parse(Literal)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - writer.WritePropertyName("int"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Int); -#else - using (JsonDocument document = JsonDocument.Parse(Int)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - writer.WritePropertyName("boolean"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Boolean); -#else - using (JsonDocument document = JsonDocument.Parse(Boolean)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - writer.WritePropertyName("array"u8); - writer.WriteStartArray(); - foreach (BinaryData item in Array) - { - if (item == null) - { - writer.WriteNullValue(); - continue; - } -#if NET6_0_OR_GREATER - writer.WriteRawValue(item); -#else - using (JsonDocument document = JsonDocument.Parse(item)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - writer.WriteEndArray(); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - MixedTypesCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + MixedTypesCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual MixedTypesCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MixedTypesCases)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMixedTypesCases(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static MixedTypesCases DeserializeMixedTypesCases(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - BinaryData model = default; - BinaryData literal = default; - BinaryData @int = default; - BinaryData boolean = default; - IList array = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("model"u8)) - { - model = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (prop.NameEquals("literal"u8)) - { - literal = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (prop.NameEquals("int"u8)) - { - @int = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (prop.NameEquals("boolean"u8)) - { - boolean = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (prop.NameEquals("array"u8)) - { - List array0 = new List(); - foreach (var item in prop.Value.EnumerateArray()) - { - if (item.ValueKind == JsonValueKind.Null) - { - array0.Add(null); - } - else - { - array0.Add(BinaryData.FromString(item.GetRawText())); - } - } - array = array0; - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new MixedTypesCases( - model, - literal, - @int, - boolean, - array, - additionalBinaryDataProperties); - } + protected virtual MixedTypesCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.cs index a39ed7f3ae7..7d4dfca9317 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/MixedTypesCases.cs @@ -4,289 +4,37 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text.Json; namespace _Type.Union { - /// The MixedTypesCases. public partial class MixedTypesCases { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; + public MixedTypesCases(BinaryData model, BinaryData literal, BinaryData @int, BinaryData boolean, IEnumerable array) => throw null; - /// Initializes a new instance of . - /// This should be receive/send the Cat variant. - /// This should be receive/send the "a" variant. - /// This should be receive/send the int variant. - /// This should be receive/send the boolean variant. - /// This should be receive/send 4 element with Cat, "a", int, and boolean. - /// , , , or is null. - public MixedTypesCases(BinaryData model, BinaryData literal, BinaryData @int, BinaryData boolean, IEnumerable array) + public BinaryData Model { - Argument.AssertNotNull(model, nameof(model)); - Argument.AssertNotNull(literal, nameof(literal)); - Argument.AssertNotNull(@int, nameof(@int)); - Argument.AssertNotNull(boolean, nameof(boolean)); - Argument.AssertNotNull(array, nameof(array)); - - Model = model; - Literal = literal; - Int = @int; - Boolean = boolean; - Array = array.ToList(); + get => throw null; + set => throw null; } - /// Initializes a new instance of . - /// This should be receive/send the Cat variant. - /// This should be receive/send the "a" variant. - /// This should be receive/send the int variant. - /// This should be receive/send the boolean variant. - /// This should be receive/send 4 element with Cat, "a", int, and boolean. - /// Keeps track of any properties unknown to the library. - internal MixedTypesCases(BinaryData model, BinaryData literal, BinaryData @int, BinaryData boolean, IList array, IDictionary additionalBinaryDataProperties) + public BinaryData Literal { - Model = model; - Literal = literal; - Int = @int; - Boolean = boolean; - Array = array; - _additionalBinaryDataProperties = additionalBinaryDataProperties; + get => throw null; + set => throw null; } - /// - /// This should be receive/send the Cat variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// . - /// - /// - /// "a". - /// - /// - /// . - /// - /// - /// . - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData Model { get; set; } - - /// - /// This should be receive/send the "a" variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// . - /// - /// - /// "a". - /// - /// - /// . - /// - /// - /// . - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData Literal { get; set; } - - /// - /// This should be receive/send the int variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// . - /// - /// - /// "a". - /// - /// - /// . - /// - /// - /// . - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData Int { get; set; } + public BinaryData Int + { + get => throw null; + set => throw null; + } - /// - /// This should be receive/send the boolean variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// . - /// - /// - /// "a". - /// - /// - /// . - /// - /// - /// . - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData Boolean { get; set; } + public BinaryData Boolean + { + get => throw null; + set => throw null; + } - /// - /// This should be receive/send 4 element with Cat, "a", int, and boolean - /// To assign an object to the element of this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// . - /// - /// - /// "a". - /// - /// - /// . - /// - /// - /// . - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public IList Array { get; } + public IList Array => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.Serialization.cs deleted file mode 100644 index 37f9fdc0671..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest. - internal partial class SendRequest : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest sendRequest) - { - if (sendRequest == null) - { - return null; - } - return BinaryContent.Create(sendRequest, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteStringValue(Prop.ToSerialString()); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest DeserializeSendRequest(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - GetResponseProp prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = prop0.Value.GetString().ToGetResponseProp(); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.cs deleted file mode 100644 index 167e9538d9c..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Union -{ - /// The SendRequest. - internal partial class SendRequest - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest(GetResponseProp prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest(GetResponseProp prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public GetResponseProp Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.Serialization.cs deleted file mode 100644 index 5dc71eac6e3..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest1. - internal partial class SendRequest1 : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest1() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest1(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest1)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest1)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest1 sendRequest1) - { - if (sendRequest1 == null) - { - return null; - } - return BinaryContent.Create(sendRequest1, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest1)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteStringValue(Prop.ToString()); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest1)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest1(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest1 DeserializeSendRequest1(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - GetResponseProp1 prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = new GetResponseProp1(prop0.Value.GetString()); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest1(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.cs deleted file mode 100644 index 991287c2c5f..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest1.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Union -{ - /// The SendRequest1. - internal partial class SendRequest1 - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest1(GetResponseProp1 prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest1(GetResponseProp1 prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public GetResponseProp1 Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.Serialization.cs deleted file mode 100644 index d50da670138..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest2. - internal partial class SendRequest2 : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest2() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest2 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest2(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest2)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest2)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest2 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest2 sendRequest2) - { - if (sendRequest2 == null) - { - return null; - } - return BinaryContent.Create(sendRequest2, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest2)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteStringValue(Prop.ToString()); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest2 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest2)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest2(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest2 DeserializeSendRequest2(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StringExtensibleNamedUnion prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = new StringExtensibleNamedUnion(prop0.Value.GetString()); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest2(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.cs deleted file mode 100644 index 8d937641568..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest2.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Union -{ - /// The SendRequest2. - internal partial class SendRequest2 - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest2(StringExtensibleNamedUnion prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest2(StringExtensibleNamedUnion prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public StringExtensibleNamedUnion Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.Serialization.cs deleted file mode 100644 index 02a6cab4a44..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest3. - internal partial class SendRequest3 : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest3() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest3 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest3(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest3)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest3)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest3 sendRequest3) - { - if (sendRequest3 == null) - { - return null; - } - return BinaryContent.Create(sendRequest3, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest3)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteNumberValue((int)Prop); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest3 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest3 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest3)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest3(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest3 DeserializeSendRequest3(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - GetResponseProp2 prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = prop0.Value.GetInt32().ToGetResponseProp2(); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest3(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.cs deleted file mode 100644 index ffca6bbe029..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest3.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Union -{ - /// The SendRequest3. - internal partial class SendRequest3 - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest3(GetResponseProp2 prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest3(GetResponseProp2 prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public GetResponseProp2 Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.Serialization.cs deleted file mode 100644 index e0e3c910fc7..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest4. - internal partial class SendRequest4 : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest4() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest4 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest4(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest4)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest4)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest4 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest4 sendRequest4) - { - if (sendRequest4 == null) - { - return null; - } - return BinaryContent.Create(sendRequest4, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest4)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteNumberValue(Prop.ToSerialSingle()); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest4 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest4 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest4)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest4(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest4 DeserializeSendRequest4(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - GetResponseProp3 prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = prop0.Value.GetSingle().ToGetResponseProp3(); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest4(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.cs deleted file mode 100644 index fd0ce88bd08..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest4.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Union -{ - /// The SendRequest4. - internal partial class SendRequest4 - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest4(GetResponseProp3 prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest4(GetResponseProp3 prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public GetResponseProp3 Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.Serialization.cs deleted file mode 100644 index 269b595553e..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.Serialization.cs +++ /dev/null @@ -1,157 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest5. - internal partial class SendRequest5 : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest5() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest5 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest5(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest5)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest5)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest5 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest5 sendRequest5) - { - if (sendRequest5 == null) - { - return null; - } - return BinaryContent.Create(sendRequest5, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest5)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Prop); -#else - using (JsonDocument document = JsonDocument.Parse(Prop)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest5 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest5 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest5)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest5(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest5 DeserializeSendRequest5(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - BinaryData prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = BinaryData.FromString(prop0.Value.GetRawText()); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest5(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.cs deleted file mode 100644 index 80c0ab8c08b..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest5.cs +++ /dev/null @@ -1,74 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest5. - internal partial class SendRequest5 - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest5(BinaryData prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest5(BinaryData prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// - /// Gets the Prop. - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// . - /// - /// - /// . - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.Serialization.cs deleted file mode 100644 index 86cc6ac0d75..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest6. - internal partial class SendRequest6 : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest6() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest6 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest6(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest6)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest6)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest6 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest6 sendRequest6) - { - if (sendRequest6 == null) - { - return null; - } - return BinaryContent.Create(sendRequest6, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest6)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteObjectValue(Prop, options); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest6 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest6 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest6)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest6(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest6 DeserializeSendRequest6(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - EnumsOnlyCases prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = EnumsOnlyCases.DeserializeEnumsOnlyCases(prop0.Value, options); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest6(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.cs deleted file mode 100644 index 6d9841ad267..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest6.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Union -{ - /// The SendRequest6. - internal partial class SendRequest6 - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest6(EnumsOnlyCases prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest6(EnumsOnlyCases prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public EnumsOnlyCases Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.Serialization.cs deleted file mode 100644 index dc694486107..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest7. - internal partial class SendRequest7 : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest7() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest7 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest7(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest7)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest7)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest7 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest7 sendRequest7) - { - if (sendRequest7 == null) - { - return null; - } - return BinaryContent.Create(sendRequest7, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest7)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteObjectValue(Prop, options); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest7 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest7 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest7)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest7(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest7 DeserializeSendRequest7(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - StringAndArrayCases prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = StringAndArrayCases.DeserializeStringAndArrayCases(prop0.Value, options); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest7(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.cs deleted file mode 100644 index f746cfb6b13..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest7.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Union -{ - /// The SendRequest7. - internal partial class SendRequest7 - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest7(StringAndArrayCases prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest7(StringAndArrayCases prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public StringAndArrayCases Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.Serialization.cs deleted file mode 100644 index 9bcf588a6ab..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest8. - internal partial class SendRequest8 : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest8() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest8 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest8(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest8)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest8)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest8 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest8 sendRequest8) - { - if (sendRequest8 == null) - { - return null; - } - return BinaryContent.Create(sendRequest8, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest8)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteObjectValue(Prop, options); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest8 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest8 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest8)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest8(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest8 DeserializeSendRequest8(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MixedLiteralsCases prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = MixedLiteralsCases.DeserializeMixedLiteralsCases(prop0.Value, options); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest8(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.cs deleted file mode 100644 index ef2c2ea1b53..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest8.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Union -{ - /// The SendRequest8. - internal partial class SendRequest8 - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest8(MixedLiteralsCases prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest8(MixedLiteralsCases prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public MixedLiteralsCases Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.Serialization.cs deleted file mode 100644 index 13abcda2dd8..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.Serialization.cs +++ /dev/null @@ -1,150 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace _Type.Union -{ - /// The SendRequest9. - internal partial class SendRequest9 : IJsonModel - { - /// Initializes a new instance of for deserialization. - internal SendRequest9() - { - } - - /// The data to parse. - /// The client options for reading and writing models. - protected virtual SendRequest9 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeSendRequest9(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SendRequest9)} does not support reading '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(SendRequest9)} does not support writing '{options.Format}' format."); - } - } - - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); - - /// The data to parse. - /// The client options for reading and writing models. - SendRequest9 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to serialize into . - public static implicit operator BinaryContent(SendRequest9 sendRequest9) - { - if (sendRequest9 == null) - { - return null; - } - return BinaryContent.Create(sendRequest9, ModelSerializationExtensions.WireOptions); - } - - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest9)} does not support writing '{format}' format."); - } - writer.WritePropertyName("prop"u8); - writer.WriteObjectValue(Prop, options); - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - /// The JSON reader. - /// The client options for reading and writing models. - SendRequest9 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); - - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual SendRequest9 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SendRequest9)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSendRequest9(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static SendRequest9 DeserializeSendRequest9(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MixedTypesCases prop = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop0 in element.EnumerateObject()) - { - if (prop0.NameEquals("prop"u8)) - { - prop = MixedTypesCases.DeserializeMixedTypesCases(prop0.Value, options); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); - } - } - return new SendRequest9(prop, additionalBinaryDataProperties); - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.cs deleted file mode 100644 index 3629eace1cb..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/SendRequest9.cs +++ /dev/null @@ -1,35 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Union -{ - /// The SendRequest9. - internal partial class SendRequest9 - { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; - - /// Initializes a new instance of . - /// - internal SendRequest9(MixedTypesCases prop) - { - Prop = prop; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal SendRequest9(MixedTypesCases prop, IDictionary additionalBinaryDataProperties) - { - Prop = prop; - _additionalBinaryDataProperties = additionalBinaryDataProperties; - } - - /// Gets the Prop. - public MixedTypesCases Prop { get; } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.Serialization.cs index b0d2c32ffe7..cfe41e6c340 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.Serialization.cs @@ -4,158 +4,30 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Text.Json; namespace _Type.Union { - /// The StringAndArrayCases. public partial class StringAndArrayCases : IJsonModel { - /// Initializes a new instance of for deserialization. - internal StringAndArrayCases() - { - } + internal StringAndArrayCases() => throw null; - /// The data to parse. - /// The client options for reading and writing models. - protected virtual StringAndArrayCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeStringAndArrayCases(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(StringAndArrayCases)} does not support reading '{options.Format}' format."); - } - } + protected virtual StringAndArrayCases PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, _TypeUnionContext.Default); - default: - throw new FormatException($"The model {nameof(StringAndArrayCases)} does not support writing '{options.Format}' format."); - } - } + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - /// The data to parse. - /// The client options for reading and writing models. - StringAndArrayCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + StringAndArrayCases IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - /// The client options for reading and writing models. - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StringAndArrayCases)} does not support writing '{format}' format."); - } - writer.WritePropertyName("string"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(String); -#else - using (JsonDocument document = JsonDocument.Parse(String)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - writer.WritePropertyName("array"u8); -#if NET6_0_OR_GREATER - writer.WriteRawValue(Array); -#else - using (JsonDocument document = JsonDocument.Parse(Array)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - if (options.Format != "W" && _additionalBinaryDataProperties != null) - { - foreach (var item in _additionalBinaryDataProperties) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - StringAndArrayCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + StringAndArrayCases IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - /// The JSON reader. - /// The client options for reading and writing models. - protected virtual StringAndArrayCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StringAndArrayCases)} does not support reading '{format}' format."); - } - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeStringAndArrayCases(document.RootElement, options); - } - - /// The JSON element to deserialize. - /// The client options for reading and writing models. - internal static StringAndArrayCases DeserializeStringAndArrayCases(JsonElement element, ModelReaderWriterOptions options) - { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - BinaryData @string = default; - BinaryData array = default; - IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); - foreach (var prop in element.EnumerateObject()) - { - if (prop.NameEquals("string"u8)) - { - @string = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (prop.NameEquals("array"u8)) - { - array = BinaryData.FromString(prop.Value.GetRawText()); - continue; - } - if (options.Format != "W") - { - additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); - } - } - return new StringAndArrayCases(@string, array, additionalBinaryDataProperties); - } + protected virtual StringAndArrayCases JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.cs index 4793dfc8bc8..a6f84c36aca 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringAndArrayCases.cs @@ -3,121 +3,23 @@ #nullable disable using System; -using System.Collections.Generic; -using System.Text.Json; namespace _Type.Union { - /// The StringAndArrayCases. public partial class StringAndArrayCases { - /// Keeps track of any properties unknown to the library. - private protected readonly IDictionary _additionalBinaryDataProperties; + public StringAndArrayCases(BinaryData @string, BinaryData array) => throw null; - /// Initializes a new instance of . - /// This should be receive/send the string variant. - /// This should be receive/send the array variant. - /// or is null. - public StringAndArrayCases(BinaryData @string, BinaryData array) + public BinaryData String { - Argument.AssertNotNull(@string, nameof(@string)); - Argument.AssertNotNull(array, nameof(array)); - - String = @string; - Array = array; + get => throw null; + set => throw null; } - /// Initializes a new instance of . - /// This should be receive/send the string variant. - /// This should be receive/send the array variant. - /// Keeps track of any properties unknown to the library. - internal StringAndArrayCases(BinaryData @string, BinaryData array, IDictionary additionalBinaryDataProperties) + public BinaryData Array { - String = @string; - Array = array; - _additionalBinaryDataProperties = additionalBinaryDataProperties; + get => throw null; + set => throw null; } - - /// - /// This should be receive/send the string variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// . - /// - /// - /// where T is of type . - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData String { get; set; } - - /// - /// This should be receive/send the array variant - /// To assign an object to this property use . - /// To assign an already formatted json string to this property use . - /// - /// - /// Supported types: - /// - /// - /// . - /// - /// - /// where T is of type . - /// - /// - /// - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo"). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\""). - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }). - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}"). - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - public BinaryData Array { get; set; } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringExtensibleNamedUnion.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringExtensibleNamedUnion.cs index b2f5f6a76bf..4cac1e8e32f 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringExtensibleNamedUnion.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/StringExtensibleNamedUnion.cs @@ -7,59 +7,30 @@ namespace _Type.Union { - /// public readonly partial struct StringExtensibleNamedUnion : IEquatable { - private readonly string _value; - private const string OptionBValue = "b"; - private const string CValue = "c"; + public StringExtensibleNamedUnion(string value) => throw null; - /// Initializes a new instance of . - /// The value. - /// is null. - public StringExtensibleNamedUnion(string value) - { - Argument.AssertNotNull(value, nameof(value)); + public static StringExtensibleNamedUnion OptionB => throw null; - _value = value; - } + public static StringExtensibleNamedUnion C => throw null; - /// Gets the OptionB. - public static StringExtensibleNamedUnion OptionB { get; } = new StringExtensibleNamedUnion(OptionBValue); + public static bool operator ==(StringExtensibleNamedUnion left, StringExtensibleNamedUnion right) => throw null; - /// Gets the C. - public static StringExtensibleNamedUnion C { get; } = new StringExtensibleNamedUnion(CValue); + public static bool operator !=(StringExtensibleNamedUnion left, StringExtensibleNamedUnion right) => throw null; - /// Determines if two values are the same. - /// The left value to compare. - /// The right value to compare. - public static bool operator ==(StringExtensibleNamedUnion left, StringExtensibleNamedUnion right) => left.Equals(right); + public static implicit operator StringExtensibleNamedUnion(string value) => throw null; - /// Determines if two values are not the same. - /// The left value to compare. - /// The right value to compare. - public static bool operator !=(StringExtensibleNamedUnion left, StringExtensibleNamedUnion right) => !left.Equals(right); + public static implicit operator StringExtensibleNamedUnion?(string value) => throw null; - /// Converts a string to a . - /// The value. - public static implicit operator StringExtensibleNamedUnion(string value) => new StringExtensibleNamedUnion(value); - - /// Converts a string to a . - /// The value. - public static implicit operator StringExtensibleNamedUnion?(string value) => value == null ? null : new StringExtensibleNamedUnion(value); - - /// [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is StringExtensibleNamedUnion other && Equals(other); + public override bool Equals(object obj) => throw null; - /// - public bool Equals(StringExtensibleNamedUnion other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + public bool Equals(StringExtensibleNamedUnion other) => throw null; - /// [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override int GetHashCode() => throw null; - /// - public override string ToString() => _value; + public override string ToString() => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/_TypeUnionContext.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/_TypeUnionContext.cs index 755c563bcf9..60e51e84695 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/_TypeUnionContext.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/Models/_TypeUnionContext.cs @@ -6,10 +6,6 @@ namespace _Type.Union { - /// - /// Context class which will be filled in by the System.ClientModel.SourceGeneration. - /// For more information - /// [ModelReaderWriterBuildable(typeof(Cat))] [ModelReaderWriterBuildable(typeof(Dog))] [ModelReaderWriterBuildable(typeof(EnumsOnlyCases))] @@ -25,16 +21,6 @@ namespace _Type.Union [ModelReaderWriterBuildable(typeof(GetResponse9))] [ModelReaderWriterBuildable(typeof(MixedLiteralsCases))] [ModelReaderWriterBuildable(typeof(MixedTypesCases))] - [ModelReaderWriterBuildable(typeof(SendRequest))] - [ModelReaderWriterBuildable(typeof(SendRequest1))] - [ModelReaderWriterBuildable(typeof(SendRequest2))] - [ModelReaderWriterBuildable(typeof(SendRequest3))] - [ModelReaderWriterBuildable(typeof(SendRequest4))] - [ModelReaderWriterBuildable(typeof(SendRequest5))] - [ModelReaderWriterBuildable(typeof(SendRequest6))] - [ModelReaderWriterBuildable(typeof(SendRequest7))] - [ModelReaderWriterBuildable(typeof(SendRequest8))] - [ModelReaderWriterBuildable(typeof(SendRequest9))] [ModelReaderWriterBuildable(typeof(StringAndArrayCases))] public partial class _TypeUnionContext : ModelReaderWriterContext { diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.RestClient.cs deleted file mode 100644 index 662a9e02444..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class ModelsOnly - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/models-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/models-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.cs index eba7c2ae51c..ebb37812dc0 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/ModelsOnly.cs @@ -10,146 +10,28 @@ namespace _Type.Union { - /// Describe union of models. public partial class ModelsOnly { - private readonly Uri _endpoint; + protected ModelsOnly() => throw null; - /// Initializes a new instance of ModelsOnly for mocking. - protected ModelsOnly() - { - } + internal ModelsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of ModelsOnly. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal ModelsOnly(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse5)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse5)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(BinaryData prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual ClientResult Send(BinaryData prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest5 spreadModel = new SendRequest5(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual async Task SendAsync(BinaryData prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest5 spreadModel = new SendRequest5(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(BinaryData prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.RestClient.cs deleted file mode 100644 index 0b016492b1b..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class StringAndArray - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/string-and-array", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/string-and-array", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.cs index d718de7d41f..0a470dd358d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringAndArray.cs @@ -10,146 +10,28 @@ namespace _Type.Union { - /// Describe union of a string and an array of strings. public partial class StringAndArray { - private readonly Uri _endpoint; + protected StringAndArray() => throw null; - /// Initializes a new instance of StringAndArray for mocking. - protected StringAndArray() - { - } + internal StringAndArray(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of StringAndArray. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal StringAndArray(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse7)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse7)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(StringAndArrayCases prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual ClientResult Send(StringAndArrayCases prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest7 spreadModel = new SendRequest7(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// is null. - /// Service returned a non-success status code. - public virtual async Task SendAsync(StringAndArrayCases prop, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(prop, nameof(prop)); - - SendRequest7 spreadModel = new SendRequest7(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(StringAndArrayCases prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.RestClient.cs deleted file mode 100644 index 8afb51d8888..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class StringExtensible - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/string-extensible", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/string-extensible", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.cs index 83de07b6630..c6d886ad068 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensible.cs @@ -10,140 +10,28 @@ namespace _Type.Union { - /// Describe union of string string | "b" | "c". public partial class StringExtensible { - private readonly Uri _endpoint; + protected StringExtensible() => throw null; - /// Initializes a new instance of StringExtensible for mocking. - protected StringExtensible() - { - } + internal StringExtensible(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of StringExtensible. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal StringExtensible(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse1)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse1)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(GetResponseProp1 prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Send(GetResponseProp1 prop, CancellationToken cancellationToken = default) - { - SendRequest1 spreadModel = new SendRequest1(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task SendAsync(GetResponseProp1 prop, CancellationToken cancellationToken = default) - { - SendRequest1 spreadModel = new SendRequest1(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(GetResponseProp1 prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.RestClient.cs deleted file mode 100644 index 95ab027470b..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class StringExtensibleNamed - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/string-extensible-named", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/string-extensible-named", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.cs index 573aa63e8f1..85a4d399263 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringExtensibleNamed.cs @@ -10,140 +10,28 @@ namespace _Type.Union { - /// Describe union of string string | "b" | "c" but where the union is named and some of the variants are named. public partial class StringExtensibleNamed { - private readonly Uri _endpoint; + protected StringExtensibleNamed() => throw null; - /// Initializes a new instance of StringExtensibleNamed for mocking. - protected StringExtensibleNamed() - { - } + internal StringExtensibleNamed(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of StringExtensibleNamed. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal StringExtensibleNamed(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse2)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse2)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(StringExtensibleNamedUnion prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Send(StringExtensibleNamedUnion prop, CancellationToken cancellationToken = default) - { - SendRequest2 spreadModel = new SendRequest2(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task SendAsync(StringExtensibleNamedUnion prop, CancellationToken cancellationToken = default) - { - SendRequest2 spreadModel = new SendRequest2(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(StringExtensibleNamedUnion prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.RestClient.cs deleted file mode 100644 index 53d7856cfd8..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.RestClient.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace _Type.Union -{ - /// - public partial class StringsOnly - { - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier _pipelineMessageClassifier204; - - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - - internal PipelineMessage CreateGetRequest(RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/strings-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); - PipelineRequest request = message.Request; - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateSendRequest(BinaryContent content, RequestOptions options) - { - ClientUriBuilder uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/union/strings-only", false); - PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier204); - PipelineRequest request = message.Request; - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.cs index dd4c7aa12e9..fb8ec122f24 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/StringsOnly.cs @@ -10,140 +10,28 @@ namespace _Type.Union { - /// Describe union of string "a" | "b" | "c". public partial class StringsOnly { - private readonly Uri _endpoint; + protected StringsOnly() => throw null; - /// Initializes a new instance of StringsOnly for mocking. - protected StringsOnly() - { - } + internal StringsOnly(ClientPipeline pipeline, Uri endpoint) => throw null; - /// Initializes a new instance of StringsOnly. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// Service endpoint. - internal StringsOnly(ClientPipeline pipeline, Uri endpoint) - { - _endpoint = endpoint; - Pipeline = pipeline; - } + public ClientPipeline Pipeline => throw null; - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } + public virtual ClientResult Get(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Get(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual Task GetAsync(RequestOptions options) => throw null; - /// - /// [Protocol Method] Get - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + public virtual ClientResult Get(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Get(CancellationToken cancellationToken = default) - { - ClientResult result = Get(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetResponse)result, result.GetRawResponse()); - } + public virtual Task> GetAsync(CancellationToken cancellationToken = default) => throw null; - /// Get. - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetResponse)result, result.GetRawResponse()); - } + public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult Send(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); + public virtual Task SendAsync(BinaryContent content, RequestOptions options = null) => throw null; - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } + public virtual ClientResult Send(GetResponseProp prop, CancellationToken cancellationToken = default) => throw null; - /// - /// [Protocol Method] Send - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task SendAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateSendRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual ClientResult Send(GetResponseProp prop, CancellationToken cancellationToken = default) - { - SendRequest spreadModel = new SendRequest(prop, default); - return Send(spreadModel, cancellationToken.ToRequestOptions()); - } - - /// Send. - /// - /// The cancellation token that can be used to cancel the operation. - /// Service returned a non-success status code. - public virtual async Task SendAsync(GetResponseProp prop, CancellationToken cancellationToken = default) - { - SendRequest spreadModel = new SendRequest(prop, default); - return await SendAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - } + public virtual Task SendAsync(GetResponseProp prop, CancellationToken cancellationToken = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/TypeUnionModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/TypeUnionModelFactory.cs index dbb8febbd29..94c8fc67c26 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/TypeUnionModelFactory.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/TypeUnionModelFactory.cs @@ -4,156 +4,41 @@ using System; using System.Collections.Generic; -using System.Linq; namespace _Type.Union { - /// A factory class for creating instances of the models for mocking. public static partial class TypeUnionModelFactory { - /// The GetResponse. - /// - /// A new instance for mocking. - public static GetResponse GetResponse(GetResponseProp prop = default) - { - return new GetResponse(prop, additionalBinaryDataProperties: null); - } - - /// The GetResponse1. - /// - /// A new instance for mocking. - public static GetResponse1 GetResponse1(GetResponseProp1 prop = default) - { - return new GetResponse1(prop, additionalBinaryDataProperties: null); - } - - /// The GetResponse2. - /// - /// A new instance for mocking. - public static GetResponse2 GetResponse2(StringExtensibleNamedUnion prop = default) - { - return new GetResponse2(prop, additionalBinaryDataProperties: null); - } - - /// The GetResponse3. - /// - /// A new instance for mocking. - public static GetResponse3 GetResponse3(GetResponseProp2 prop = default) - { - return new GetResponse3(prop, additionalBinaryDataProperties: null); - } - - /// The GetResponse4. - /// - /// A new instance for mocking. - public static GetResponse4 GetResponse4(GetResponseProp3 prop = default) - { - return new GetResponse4(prop, additionalBinaryDataProperties: null); - } - - /// The GetResponse5. - /// - /// A new instance for mocking. - public static GetResponse5 GetResponse5(BinaryData prop = default) - { - return new GetResponse5(prop, additionalBinaryDataProperties: null); - } - - /// The Cat. - /// - /// A new instance for mocking. - public static Cat Cat(string name = default) - { - return new Cat(name, additionalBinaryDataProperties: null); - } - - /// The Dog. - /// - /// A new instance for mocking. - public static Dog Dog(string bark = default) - { - return new Dog(bark, additionalBinaryDataProperties: null); - } - - /// The GetResponse6. - /// - /// A new instance for mocking. - public static GetResponse6 GetResponse6(EnumsOnlyCases prop = default) - { - return new GetResponse6(prop, additionalBinaryDataProperties: null); - } - - /// The EnumsOnlyCases. - /// This should be receive/send the left variant. - /// This should be receive/send the up variant. - /// A new instance for mocking. - public static EnumsOnlyCases EnumsOnlyCases(EnumsOnlyCasesLr lr = default, EnumsOnlyCasesUd ud = default) - { - return new EnumsOnlyCases(lr, ud, additionalBinaryDataProperties: null); - } - - /// The GetResponse7. - /// - /// A new instance for mocking. - public static GetResponse7 GetResponse7(StringAndArrayCases prop = default) - { - return new GetResponse7(prop, additionalBinaryDataProperties: null); - } - - /// The StringAndArrayCases. - /// This should be receive/send the string variant. - /// This should be receive/send the array variant. - /// A new instance for mocking. - public static StringAndArrayCases StringAndArrayCases(BinaryData @string = default, BinaryData array = default) - { - return new StringAndArrayCases(@string, array, additionalBinaryDataProperties: null); - } - - /// The GetResponse8. - /// - /// A new instance for mocking. - public static GetResponse8 GetResponse8(MixedLiteralsCases prop = default) - { - return new GetResponse8(prop, additionalBinaryDataProperties: null); - } - - /// The MixedLiteralsCases. - /// This should be receive/send the "a" variant. - /// This should be receive/send the 2 variant. - /// This should be receive/send the 3.3 variant. - /// This should be receive/send the true variant. - /// A new instance for mocking. - public static MixedLiteralsCases MixedLiteralsCases(BinaryData stringLiteral = default, BinaryData intLiteral = default, BinaryData floatLiteral = default, BinaryData booleanLiteral = default) - { - return new MixedLiteralsCases(stringLiteral, intLiteral, floatLiteral, booleanLiteral, additionalBinaryDataProperties: null); - } - - /// The GetResponse9. - /// - /// A new instance for mocking. - public static GetResponse9 GetResponse9(MixedTypesCases prop = default) - { - return new GetResponse9(prop, additionalBinaryDataProperties: null); - } - - /// The MixedTypesCases. - /// This should be receive/send the Cat variant. - /// This should be receive/send the "a" variant. - /// This should be receive/send the int variant. - /// This should be receive/send the boolean variant. - /// This should be receive/send 4 element with Cat, "a", int, and boolean. - /// A new instance for mocking. - public static MixedTypesCases MixedTypesCases(BinaryData model = default, BinaryData literal = default, BinaryData @int = default, BinaryData boolean = default, IEnumerable array = default) - { - array ??= new ChangeTrackingList(); - - return new MixedTypesCases( - model, - literal, - @int, - boolean, - array.ToList(), - additionalBinaryDataProperties: null); - } + public static GetResponse GetResponse(GetResponseProp prop = default) => throw null; + + public static GetResponse1 GetResponse1(GetResponseProp1 prop = default) => throw null; + + public static GetResponse2 GetResponse2(StringExtensibleNamedUnion prop = default) => throw null; + + public static GetResponse3 GetResponse3(GetResponseProp2 prop = default) => throw null; + + public static GetResponse4 GetResponse4(GetResponseProp3 prop = default) => throw null; + + public static GetResponse5 GetResponse5(BinaryData prop = default) => throw null; + + public static Cat Cat(string name = default) => throw null; + + public static Dog Dog(string bark = default) => throw null; + + public static GetResponse6 GetResponse6(EnumsOnlyCases prop = default) => throw null; + + public static EnumsOnlyCases EnumsOnlyCases(EnumsOnlyCasesLr lr = default, EnumsOnlyCasesUd ud = default) => throw null; + + public static GetResponse7 GetResponse7(StringAndArrayCases prop = default) => throw null; + + public static StringAndArrayCases StringAndArrayCases(BinaryData @string = default, BinaryData array = default) => throw null; + + public static GetResponse8 GetResponse8(MixedLiteralsCases prop = default) => throw null; + + public static MixedLiteralsCases MixedLiteralsCases(BinaryData stringLiteral = default, BinaryData intLiteral = default, BinaryData floatLiteral = default, BinaryData booleanLiteral = default) => throw null; + + public static GetResponse9 GetResponse9(MixedTypesCases prop = default) => throw null; + + public static MixedTypesCases MixedTypesCases(BinaryData model = default, BinaryData literal = default, BinaryData @int = default, BinaryData boolean = default, IEnumerable array = default) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.RestClient.cs deleted file mode 100644 index 013f0f1fac7..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.RestClient.cs +++ /dev/null @@ -1,11 +0,0 @@ -// - -#nullable disable - -namespace _Type.Union -{ - /// - public partial class UnionClient - { - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.cs index ce12a705610..48df18bf7cc 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClient.cs @@ -5,127 +5,40 @@ using System; using System.ClientModel.Primitives; using System.Diagnostics.CodeAnalysis; -using System.Threading; namespace _Type.Union { - /// Describe scenarios for various combinations of unions. public partial class UnionClient { - private readonly Uri _endpoint; - private StringsOnly _cachedStringsOnly; - private StringExtensible _cachedStringExtensible; - private StringExtensibleNamed _cachedStringExtensibleNamed; - private IntsOnly _cachedIntsOnly; - private FloatsOnly _cachedFloatsOnly; - private ModelsOnly _cachedModelsOnly; - private EnumsOnly _cachedEnumsOnly; - private StringAndArray _cachedStringAndArray; - private MixedLiterals _cachedMixedLiterals; - private MixedTypes _cachedMixedTypes; - - /// Initializes a new instance of UnionClient. - public UnionClient() : this(new Uri("http://localhost:3000"), new UnionClientOptions()) - { - } - - /// Initializes a new instance of UnionClient. - /// The authentication policy to use for pipeline creation. - /// Service endpoint. - /// The options for configuring the client. - internal UnionClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, UnionClientOptions options) - { - Argument.AssertNotNull(endpoint, nameof(endpoint)); - - options ??= new UnionClientOptions(); - - _endpoint = endpoint; - if (authenticationPolicy != null) - { - Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(UnionClient).Assembly), authenticationPolicy }, Array.Empty()); - } - else - { - Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(UnionClient).Assembly) }, Array.Empty()); - } - } - - /// Initializes a new instance of UnionClient. - /// Service endpoint. - /// The options for configuring the client. - /// is null. - public UnionClient(Uri endpoint, UnionClientOptions options) : this(null, endpoint, options) - { - } - - /// Initializes a new instance of UnionClient from a . - /// The settings for UnionClient. + public UnionClient() : this(new Uri("http://localhost:3000"), new UnionClientOptions()) => throw null; + + internal UnionClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, UnionClientOptions options) => throw null; + + public UnionClient(Uri endpoint, UnionClientOptions options) : this(null, endpoint, options) => throw null; + [Experimental("SCME0002")] - public UnionClient(UnionClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Endpoint, settings?.Options) - { - } - - /// The HTTP pipeline for sending and receiving REST requests and responses. - public ClientPipeline Pipeline { get; } - - /// Initializes a new instance of StringsOnly. - public virtual StringsOnly GetStringsOnlyClient() - { - return Volatile.Read(ref _cachedStringsOnly) ?? Interlocked.CompareExchange(ref _cachedStringsOnly, new StringsOnly(Pipeline, _endpoint), null) ?? _cachedStringsOnly; - } - - /// Initializes a new instance of StringExtensible. - public virtual StringExtensible GetStringExtensibleClient() - { - return Volatile.Read(ref _cachedStringExtensible) ?? Interlocked.CompareExchange(ref _cachedStringExtensible, new StringExtensible(Pipeline, _endpoint), null) ?? _cachedStringExtensible; - } - - /// Initializes a new instance of StringExtensibleNamed. - public virtual StringExtensibleNamed GetStringExtensibleNamedClient() - { - return Volatile.Read(ref _cachedStringExtensibleNamed) ?? Interlocked.CompareExchange(ref _cachedStringExtensibleNamed, new StringExtensibleNamed(Pipeline, _endpoint), null) ?? _cachedStringExtensibleNamed; - } - - /// Initializes a new instance of IntsOnly. - public virtual IntsOnly GetIntsOnlyClient() - { - return Volatile.Read(ref _cachedIntsOnly) ?? Interlocked.CompareExchange(ref _cachedIntsOnly, new IntsOnly(Pipeline, _endpoint), null) ?? _cachedIntsOnly; - } - - /// Initializes a new instance of FloatsOnly. - public virtual FloatsOnly GetFloatsOnlyClient() - { - return Volatile.Read(ref _cachedFloatsOnly) ?? Interlocked.CompareExchange(ref _cachedFloatsOnly, new FloatsOnly(Pipeline, _endpoint), null) ?? _cachedFloatsOnly; - } - - /// Initializes a new instance of ModelsOnly. - public virtual ModelsOnly GetModelsOnlyClient() - { - return Volatile.Read(ref _cachedModelsOnly) ?? Interlocked.CompareExchange(ref _cachedModelsOnly, new ModelsOnly(Pipeline, _endpoint), null) ?? _cachedModelsOnly; - } - - /// Initializes a new instance of EnumsOnly. - public virtual EnumsOnly GetEnumsOnlyClient() - { - return Volatile.Read(ref _cachedEnumsOnly) ?? Interlocked.CompareExchange(ref _cachedEnumsOnly, new EnumsOnly(Pipeline, _endpoint), null) ?? _cachedEnumsOnly; - } - - /// Initializes a new instance of StringAndArray. - public virtual StringAndArray GetStringAndArrayClient() - { - return Volatile.Read(ref _cachedStringAndArray) ?? Interlocked.CompareExchange(ref _cachedStringAndArray, new StringAndArray(Pipeline, _endpoint), null) ?? _cachedStringAndArray; - } - - /// Initializes a new instance of MixedLiterals. - public virtual MixedLiterals GetMixedLiteralsClient() - { - return Volatile.Read(ref _cachedMixedLiterals) ?? Interlocked.CompareExchange(ref _cachedMixedLiterals, new MixedLiterals(Pipeline, _endpoint), null) ?? _cachedMixedLiterals; - } - - /// Initializes a new instance of MixedTypes. - public virtual MixedTypes GetMixedTypesClient() - { - return Volatile.Read(ref _cachedMixedTypes) ?? Interlocked.CompareExchange(ref _cachedMixedTypes, new MixedTypes(Pipeline, _endpoint), null) ?? _cachedMixedTypes; - } + public UnionClient(UnionClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Endpoint, settings?.Options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual StringsOnly GetStringsOnlyClient() => throw null; + + public virtual StringExtensible GetStringExtensibleClient() => throw null; + + public virtual StringExtensibleNamed GetStringExtensibleNamedClient() => throw null; + + public virtual IntsOnly GetIntsOnlyClient() => throw null; + + public virtual FloatsOnly GetFloatsOnlyClient() => throw null; + + public virtual ModelsOnly GetModelsOnlyClient() => throw null; + + public virtual EnumsOnly GetEnumsOnlyClient() => throw null; + + public virtual StringAndArray GetStringAndArrayClient() => throw null; + + public virtual MixedLiterals GetMixedLiteralsClient() => throw null; + + public virtual MixedTypes GetMixedTypesClient() => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientOptions.cs index 8a08b8872de..9352bd0c9c3 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientOptions.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientOptions.cs @@ -8,23 +8,11 @@ namespace _Type.Union { - /// Client options for . public partial class UnionClientOptions : ClientPipelineOptions { - /// Initializes a new instance of UnionClientOptions. - public UnionClientOptions() - { - } + public UnionClientOptions() => throw null; - /// Initializes a new instance of UnionClientOptions from configuration. - /// The configuration section. [Experimental("SCME0002")] - internal UnionClientOptions(IConfigurationSection section) : base(section) - { - if (section is null || !section.Exists()) - { - return; - } - } + internal UnionClientOptions(IConfigurationSection section) : base(section) => throw null; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientSettings.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientSettings.cs index d6cfaa81214..71defed8463 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientSettings.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/union/src/Generated/UnionClientSettings.cs @@ -9,29 +9,21 @@ namespace _Type.Union { - /// Represents the settings used to configure a that can be loaded from an . [Experimental("SCME0002")] public partial class UnionClientSettings : ClientSettings { - /// Gets or sets the Endpoint. - public Uri Endpoint { get; set; } - - /// Gets or sets the Options. - public UnionClientOptions Options { get; set; } + public Uri Endpoint + { + get => throw null; + set => throw null; + } - /// Binds configuration values from the given section. - /// The configuration section. - protected override void BindCore(IConfigurationSection section) + public UnionClientOptions Options { - if (Uri.TryCreate(section["Endpoint"], UriKind.Absolute, out Uri endpoint)) - { - Endpoint = endpoint; - } - IConfigurationSection optionsSection = section.GetSection("Options"); - if (optionsSection.Exists()) - { - Options = new UnionClientOptions(optionsSection); - } + get => throw null; + set => throw null; } + + protected override void BindCore(IConfigurationSection section) => throw null; } } From df512a925df5e510ca2dcd2de94bcfff0fa55bce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 18:10:16 +0000 Subject: [PATCH 06/16] revert: undo Generate.ps1 and SampleService changes per reviewer feedback Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/dfd2e68b-1fe9-4fde-9797-caf864e5be31 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../Generated/schema/ConfigurationSchema.json | 60 - .../SampleClient/SampleTypeSpec.NuGet.targets | 6 - .../src/Generated/AnimalOperations.cs | 152 +- .../src/Generated/DogOperations.cs | 76 +- .../SampleClient/src/Generated/Metrics.cs | 139 +- .../src/Generated/MetricsSettings.cs | 45 - .../src/Generated/PetOperations.cs | 152 +- .../src/Generated/PlantOperations.cs | 296 ++- .../SampleTypeSpecClient.RestClient.cs | 4 +- .../src/Generated/SampleTypeSpecClient.cs | 2096 ++++++++++++++--- .../Generated/SampleTypeSpecClientOptions.cs | 18 - .../Generated/SampleTypeSpecClientSettings.cs | 37 - .../client/csharp/SampleService/package.json | 2 +- .../eng/scripts/Generate.ps1 | 2 +- 14 files changed, 2398 insertions(+), 687 deletions(-) delete mode 100644 docs/samples/client/csharp/SampleService/SampleClient/Generated/schema/ConfigurationSchema.json delete mode 100644 docs/samples/client/csharp/SampleService/SampleClient/SampleTypeSpec.NuGet.targets delete mode 100644 docs/samples/client/csharp/SampleService/SampleClient/src/Generated/MetricsSettings.cs delete mode 100644 docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientSettings.cs diff --git a/docs/samples/client/csharp/SampleService/SampleClient/Generated/schema/ConfigurationSchema.json b/docs/samples/client/csharp/SampleService/SampleClient/Generated/schema/ConfigurationSchema.json deleted file mode 100644 index a41ff644b36..00000000000 --- a/docs/samples/client/csharp/SampleService/SampleClient/Generated/schema/ConfigurationSchema.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "type": "object", - "properties": { - "Clients": { - "type": "object", - "properties": { - "Metrics": { - "type": "object", - "description": "Configuration for Metrics.", - "properties": { - "SampleTypeSpecUrl": { - "type": "string", - "format": "uri", - "description": "Gets or sets the SampleTypeSpecUrl." - }, - "MetricsNamespace": { - "type": "string" - }, - "Credential": { - "$ref": "#/definitions/credential" - }, - "Options": { - "$ref": "#/definitions/sampleTypeSpecClientOptions" - } - } - }, - "SampleTypeSpecClient": { - "type": "object", - "description": "Configuration for SampleTypeSpecClient.", - "properties": { - "SampleTypeSpecUrl": { - "type": "string", - "format": "uri", - "description": "Gets or sets the SampleTypeSpecUrl." - }, - "Credential": { - "$ref": "#/definitions/credential" - }, - "Options": { - "$ref": "#/definitions/sampleTypeSpecClientOptions" - } - } - } - }, - "additionalProperties": { - "type": "object", - "description": "Configuration for a named client instance." - } - } - }, - "definitions": { - "sampleTypeSpecClientOptions": { - "allOf": [ - { - "$ref": "#/definitions/options" - } - ] - } - } -} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/SampleTypeSpec.NuGet.targets b/docs/samples/client/csharp/SampleService/SampleClient/SampleTypeSpec.NuGet.targets deleted file mode 100644 index 9df53f09f6f..00000000000 --- a/docs/samples/client/csharp/SampleService/SampleClient/SampleTypeSpec.NuGet.targets +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/AnimalOperations.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/AnimalOperations.cs index 8b2255811e9..8fa8739984f 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/AnimalOperations.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/AnimalOperations.cs @@ -47,10 +47,23 @@ internal AnimalOperations(ClientPipeline pipeline, Uri endpoint) /// The response returned from the service. public virtual ClientResult UpdatePetAsAnimal(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdatePetAsAnimal."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdatePetAsAnimalRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateUpdatePetAsAnimalRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimal: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdatePetAsAnimal."); + } } /// @@ -68,10 +81,23 @@ public virtual ClientResult UpdatePetAsAnimal(BinaryContent content, RequestOpti /// The response returned from the service. public virtual async Task UpdatePetAsAnimalAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdatePetAsAnimalAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdatePetAsAnimalRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateUpdatePetAsAnimalRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimalAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdatePetAsAnimalAsync."); + } } /// Update a pet as an animal. @@ -81,10 +107,23 @@ public virtual async Task UpdatePetAsAnimalAsync(BinaryContent con /// Service returned a non-success status code. public virtual ClientResult UpdatePetAsAnimal(Animal animal, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(animal, nameof(animal)); + try + { + System.Console.WriteLine("Entering method UpdatePetAsAnimal."); + Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = UpdatePetAsAnimal(animal, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + ClientResult result = UpdatePetAsAnimal(animal, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimal: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdatePetAsAnimal."); + } } /// Update a pet as an animal. @@ -94,10 +133,23 @@ public virtual ClientResult UpdatePetAsAnimal(Animal animal, Cancellatio /// Service returned a non-success status code. public virtual async Task> UpdatePetAsAnimalAsync(Animal animal, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(animal, nameof(animal)); + try + { + System.Console.WriteLine("Entering method UpdatePetAsAnimalAsync."); + Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = await UpdatePetAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + ClientResult result = await UpdatePetAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimalAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdatePetAsAnimalAsync."); + } } /// @@ -115,10 +167,23 @@ public virtual async Task> UpdatePetAsAnimalAsync(Animal an /// The response returned from the service. public virtual ClientResult UpdateDogAsAnimal(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsAnimal."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsAnimalRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateUpdateDogAsAnimalRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimal: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsAnimal."); + } } /// @@ -136,10 +201,23 @@ public virtual ClientResult UpdateDogAsAnimal(BinaryContent content, RequestOpti /// The response returned from the service. public virtual async Task UpdateDogAsAnimalAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsAnimalAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsAnimalRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateUpdateDogAsAnimalRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimalAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsAnimalAsync."); + } } /// Update a dog as an animal. @@ -149,10 +227,23 @@ public virtual async Task UpdateDogAsAnimalAsync(BinaryContent con /// Service returned a non-success status code. public virtual ClientResult UpdateDogAsAnimal(Animal animal, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(animal, nameof(animal)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsAnimal."); + Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = UpdateDogAsAnimal(animal, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + ClientResult result = UpdateDogAsAnimal(animal, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimal: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsAnimal."); + } } /// Update a dog as an animal. @@ -162,10 +253,23 @@ public virtual ClientResult UpdateDogAsAnimal(Animal animal, Cancellatio /// Service returned a non-success status code. public virtual async Task> UpdateDogAsAnimalAsync(Animal animal, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(animal, nameof(animal)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsAnimalAsync."); + Argument.AssertNotNull(animal, nameof(animal)); - ClientResult result = await UpdateDogAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + ClientResult result = await UpdateDogAsAnimalAsync(animal, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Animal)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimalAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsAnimalAsync."); + } } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/DogOperations.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/DogOperations.cs index a269c6b6c5b..c80c36367aa 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/DogOperations.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/DogOperations.cs @@ -47,10 +47,23 @@ internal DogOperations(ClientPipeline pipeline, Uri endpoint) /// The response returned from the service. public virtual ClientResult UpdateDogAsDog(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsDog."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDog: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsDog."); + } } /// @@ -68,10 +81,23 @@ public virtual ClientResult UpdateDogAsDog(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task UpdateDogAsDogAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsDogAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDogAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsDogAsync."); + } } /// Update a dog as a dog. @@ -81,10 +107,23 @@ public virtual async Task UpdateDogAsDogAsync(BinaryContent conten /// Service returned a non-success status code. public virtual ClientResult UpdateDogAsDog(Dog dog, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(dog, nameof(dog)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsDog."); + Argument.AssertNotNull(dog, nameof(dog)); - ClientResult result = UpdateDogAsDog(dog, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Dog)result, result.GetRawResponse()); + ClientResult result = UpdateDogAsDog(dog, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Dog)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDog: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsDog."); + } } /// Update a dog as a dog. @@ -94,10 +133,23 @@ public virtual ClientResult UpdateDogAsDog(Dog dog, CancellationToken cance /// Service returned a non-success status code. public virtual async Task> UpdateDogAsDogAsync(Dog dog, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(dog, nameof(dog)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsDogAsync."); + Argument.AssertNotNull(dog, nameof(dog)); - ClientResult result = await UpdateDogAsDogAsync(dog, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Dog)result, result.GetRawResponse()); + ClientResult result = await UpdateDogAsDogAsync(dog, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Dog)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDogAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsDogAsync."); + } } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Metrics.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Metrics.cs index 18538f3d727..65e1ea56883 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Metrics.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Metrics.cs @@ -5,8 +5,6 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; @@ -16,17 +14,6 @@ namespace SampleTypeSpec public partial class Metrics { private readonly Uri _endpoint; - private const string AuthorizationHeader = "my-api-key"; - /// The OAuth2 flows supported by the service. - private static readonly Dictionary[] _flows = new Dictionary[] - { - new Dictionary - { - { GetTokenOptions.ScopesPropertyName, new string[] { "read" } }, - { GetTokenOptions.AuthorizationUrlPropertyName, "https://api.example.com/oauth2/authorize" }, - { GetTokenOptions.RefreshUrlPropertyName, "https://api.example.com/oauth2/refresh" } - } - }; private readonly string _metricsNamespace; /// Initializes a new instance of Metrics for mocking. @@ -48,29 +35,19 @@ internal Metrics(ClientPipeline pipeline, Uri endpoint, string metricsNamespace) /// Initializes a new instance of Metrics. /// Service endpoint. /// - /// A credential used to authenticate to the service. - /// , or is null. + /// or is null. /// is an empty string, and was expected to be non-empty. - public Metrics(Uri endpoint, string metricsNamespace, ApiKeyCredential credential) : this(endpoint, metricsNamespace, credential, new SampleTypeSpecClientOptions()) + public Metrics(Uri endpoint, string metricsNamespace) : this(endpoint, metricsNamespace, new SampleTypeSpecClientOptions()) { } /// Initializes a new instance of Metrics. /// Service endpoint. /// - /// A credential provider used to authenticate to the service. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public Metrics(Uri endpoint, string metricsNamespace, AuthenticationTokenProvider tokenProvider) : this(endpoint, metricsNamespace, tokenProvider, new SampleTypeSpecClientOptions()) - { - } - - /// Initializes a new instance of Metrics. - /// The authentication policy to use for pipeline creation. - /// Service endpoint. - /// /// The options for configuring the client. - internal Metrics(AuthenticationPolicy authenticationPolicy, Uri endpoint, string metricsNamespace, SampleTypeSpecClientOptions options) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Metrics(Uri endpoint, string metricsNamespace, SampleTypeSpecClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNullOrEmpty(metricsNamespace, nameof(metricsNamespace)); @@ -79,43 +56,7 @@ internal Metrics(AuthenticationPolicy authenticationPolicy, Uri endpoint, string _endpoint = endpoint; _metricsNamespace = metricsNamespace; - if (authenticationPolicy != null) - { - Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(Metrics).Assembly), authenticationPolicy }, Array.Empty()); - } - else - { - Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(Metrics).Assembly) }, Array.Empty()); - } - } - - /// Initializes a new instance of Metrics. - /// Service endpoint. - /// - /// A credential used to authenticate to the service. - /// The options for configuring the client. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public Metrics(Uri endpoint, string metricsNamespace, ApiKeyCredential credential, SampleTypeSpecClientOptions options) : this(ApiKeyAuthenticationPolicy.CreateHeaderApiKeyPolicy(credential, AuthorizationHeader), endpoint, metricsNamespace, options) - { - } - - /// Initializes a new instance of Metrics. - /// Service endpoint. - /// - /// A credential provider used to authenticate to the service. - /// The options for configuring the client. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public Metrics(Uri endpoint, string metricsNamespace, AuthenticationTokenProvider tokenProvider, SampleTypeSpecClientOptions options) : this(new BearerTokenPolicy(tokenProvider, _flows), endpoint, metricsNamespace, options) - { - } - - /// Initializes a new instance of Metrics from a . - /// The settings for Metrics. - [Experimental("SCME0002")] - public Metrics(MetricsSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.SampleTypeSpecUrl, settings?.MetricsNamespace, settings?.Options) - { + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(Metrics).Assembly) }, Array.Empty()); } /// The HTTP pipeline for sending and receiving REST requests and responses. @@ -135,8 +76,21 @@ public Metrics(MetricsSettings settings) : this(AuthenticationPolicy.Create(sett /// The response returned from the service. public virtual ClientResult GetWidgetMetrics(string day, RequestOptions options = null) { - using PipelineMessage message = CreateGetWidgetMetricsRequest(day, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method GetWidgetMetrics."); + using PipelineMessage message = CreateGetWidgetMetricsRequest(day, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWidgetMetrics: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWidgetMetrics."); + } } /// @@ -153,8 +107,21 @@ public virtual ClientResult GetWidgetMetrics(string day, RequestOptions options /// The response returned from the service. public virtual async Task GetWidgetMetricsAsync(string day, RequestOptions options = null) { - using PipelineMessage message = CreateGetWidgetMetricsRequest(day, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method GetWidgetMetricsAsync."); + using PipelineMessage message = CreateGetWidgetMetricsRequest(day, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWidgetMetricsAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWidgetMetricsAsync."); + } } /// Get Widget metrics for given day of week. @@ -163,8 +130,21 @@ public virtual async Task GetWidgetMetricsAsync(string day, Reques /// Service returned a non-success status code. public virtual ClientResult GetWidgetMetrics(DaysOfWeekExtensibleEnum day, CancellationToken cancellationToken = default) { - ClientResult result = GetWidgetMetrics(day.ToString(), cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetWidgetMetrics."); + ClientResult result = GetWidgetMetrics(day.ToString(), cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWidgetMetrics: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWidgetMetrics."); + } } /// Get Widget metrics for given day of week. @@ -173,8 +153,21 @@ public virtual ClientResult GetWidgetMetrics(DaysOfWee /// Service returned a non-success status code. public virtual async Task> GetWidgetMetricsAsync(DaysOfWeekExtensibleEnum day, CancellationToken cancellationToken = default) { - ClientResult result = await GetWidgetMetricsAsync(day.ToString(), cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetWidgetMetricsAsync."); + ClientResult result = await GetWidgetMetricsAsync(day.ToString(), cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((GetWidgetMetricsResponse)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWidgetMetricsAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWidgetMetricsAsync."); + } } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/MetricsSettings.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/MetricsSettings.cs deleted file mode 100644 index 6302674bf01..00000000000 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/MetricsSettings.cs +++ /dev/null @@ -1,45 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Configuration; - -namespace SampleTypeSpec -{ - /// Represents the settings used to configure a that can be loaded from an . - [Experimental("SCME0002")] - public partial class MetricsSettings : ClientSettings - { - /// Gets or sets the SampleTypeSpecUrl. - public Uri SampleTypeSpecUrl { get; set; } - - /// Gets or sets the MetricsNamespace. - public string MetricsNamespace { get; set; } - - /// Gets or sets the Options. - public SampleTypeSpecClientOptions Options { get; set; } - - /// Binds configuration values from the given section. - /// The configuration section. - protected override void BindCore(IConfigurationSection section) - { - if (Uri.TryCreate(section["SampleTypeSpecUrl"], UriKind.Absolute, out Uri sampleTypeSpecUrl)) - { - SampleTypeSpecUrl = sampleTypeSpecUrl; - } - string metricsNamespace = section["MetricsNamespace"]; - if (!string.IsNullOrEmpty(metricsNamespace)) - { - MetricsNamespace = metricsNamespace; - } - IConfigurationSection optionsSection = section.GetSection("Options"); - if (optionsSection.Exists()) - { - Options = new SampleTypeSpecClientOptions(optionsSection); - } - } - } -} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PetOperations.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PetOperations.cs index 8183d3fcd4e..395ff6b18d9 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PetOperations.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PetOperations.cs @@ -47,10 +47,23 @@ internal PetOperations(ClientPipeline pipeline, Uri endpoint) /// The response returned from the service. public virtual ClientResult UpdatePetAsPet(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdatePetAsPet."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdatePetAsPetRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateUpdatePetAsPetRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdatePetAsPet: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdatePetAsPet."); + } } /// @@ -68,10 +81,23 @@ public virtual ClientResult UpdatePetAsPet(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task UpdatePetAsPetAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdatePetAsPetAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdatePetAsPetRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateUpdatePetAsPetRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdatePetAsPetAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdatePetAsPetAsync."); + } } /// Update a pet as a pet. @@ -81,10 +107,23 @@ public virtual async Task UpdatePetAsPetAsync(BinaryContent conten /// Service returned a non-success status code. public virtual ClientResult UpdatePetAsPet(Pet pet, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(pet, nameof(pet)); + try + { + System.Console.WriteLine("Entering method UpdatePetAsPet."); + Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = UpdatePetAsPet(pet, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + ClientResult result = UpdatePetAsPet(pet, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdatePetAsPet: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdatePetAsPet."); + } } /// Update a pet as a pet. @@ -94,10 +133,23 @@ public virtual ClientResult UpdatePetAsPet(Pet pet, CancellationToken cance /// Service returned a non-success status code. public virtual async Task> UpdatePetAsPetAsync(Pet pet, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(pet, nameof(pet)); + try + { + System.Console.WriteLine("Entering method UpdatePetAsPetAsync."); + Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = await UpdatePetAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + ClientResult result = await UpdatePetAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdatePetAsPetAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdatePetAsPetAsync."); + } } /// @@ -115,10 +167,23 @@ public virtual async Task> UpdatePetAsPetAsync(Pet pet, Cancel /// The response returned from the service. public virtual ClientResult UpdateDogAsPet(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsPet."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsPetRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateUpdateDogAsPetRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsPet: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsPet."); + } } /// @@ -136,10 +201,23 @@ public virtual ClientResult UpdateDogAsPet(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task UpdateDogAsPetAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsPetAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateDogAsPetRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateUpdateDogAsPetRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsPetAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsPetAsync."); + } } /// Update a dog as a pet. @@ -149,10 +227,23 @@ public virtual async Task UpdateDogAsPetAsync(BinaryContent conten /// Service returned a non-success status code. public virtual ClientResult UpdateDogAsPet(Pet pet, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(pet, nameof(pet)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsPet."); + Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = UpdateDogAsPet(pet, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + ClientResult result = UpdateDogAsPet(pet, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsPet: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsPet."); + } } /// Update a dog as a pet. @@ -162,10 +253,23 @@ public virtual ClientResult UpdateDogAsPet(Pet pet, CancellationToken cance /// Service returned a non-success status code. public virtual async Task> UpdateDogAsPetAsync(Pet pet, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(pet, nameof(pet)); + try + { + System.Console.WriteLine("Entering method UpdateDogAsPetAsync."); + Argument.AssertNotNull(pet, nameof(pet)); - ClientResult result = await UpdateDogAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + ClientResult result = await UpdateDogAsPetAsync(pet, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Pet)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateDogAsPetAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateDogAsPetAsync."); + } } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PlantOperations.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PlantOperations.cs index 70a66822b03..dcfa7b2cb12 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PlantOperations.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/PlantOperations.cs @@ -45,8 +45,21 @@ internal PlantOperations(ClientPipeline pipeline, Uri endpoint) /// The response returned from the service. public virtual ClientResult GetTree(RequestOptions options) { - using PipelineMessage message = CreateGetTreeRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method GetTree."); + using PipelineMessage message = CreateGetTreeRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetTree: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetTree."); + } } /// @@ -62,8 +75,21 @@ public virtual ClientResult GetTree(RequestOptions options) /// The response returned from the service. public virtual async Task GetTreeAsync(RequestOptions options) { - using PipelineMessage message = CreateGetTreeRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method GetTreeAsync."); + using PipelineMessage message = CreateGetTreeRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetTreeAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetTreeAsync."); + } } /// Get a tree as a plant. @@ -71,8 +97,21 @@ public virtual async Task GetTreeAsync(RequestOptions options) /// Service returned a non-success status code. public virtual ClientResult GetTree(CancellationToken cancellationToken = default) { - ClientResult result = GetTree(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetTree."); + ClientResult result = GetTree(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetTree: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetTree."); + } } /// Get a tree as a plant. @@ -80,8 +119,21 @@ public virtual ClientResult GetTree(CancellationToken cancellationToken = /// Service returned a non-success status code. public virtual async Task> GetTreeAsync(CancellationToken cancellationToken = default) { - ClientResult result = await GetTreeAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetTreeAsync."); + ClientResult result = await GetTreeAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetTreeAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetTreeAsync."); + } } /// @@ -97,8 +149,21 @@ public virtual async Task> GetTreeAsync(CancellationToken can /// The response returned from the service. public virtual ClientResult GetTreeAsJson(RequestOptions options) { - using PipelineMessage message = CreateGetTreeAsJsonRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method GetTreeAsJson."); + using PipelineMessage message = CreateGetTreeAsJsonRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetTreeAsJson: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetTreeAsJson."); + } } /// @@ -114,8 +179,21 @@ public virtual ClientResult GetTreeAsJson(RequestOptions options) /// The response returned from the service. public virtual async Task GetTreeAsJsonAsync(RequestOptions options) { - using PipelineMessage message = CreateGetTreeAsJsonRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method GetTreeAsJsonAsync."); + using PipelineMessage message = CreateGetTreeAsJsonRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetTreeAsJsonAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetTreeAsJsonAsync."); + } } /// Get a tree as a plant. @@ -123,8 +201,21 @@ public virtual async Task GetTreeAsJsonAsync(RequestOptions option /// Service returned a non-success status code. public virtual ClientResult GetTreeAsJson(CancellationToken cancellationToken = default) { - ClientResult result = GetTreeAsJson(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetTreeAsJson."); + ClientResult result = GetTreeAsJson(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetTreeAsJson: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetTreeAsJson."); + } } /// Get a tree as a plant. @@ -132,8 +223,21 @@ public virtual ClientResult GetTreeAsJson(CancellationToken cancellationTo /// Service returned a non-success status code. public virtual async Task> GetTreeAsJsonAsync(CancellationToken cancellationToken = default) { - ClientResult result = await GetTreeAsJsonAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetTreeAsJsonAsync."); + ClientResult result = await GetTreeAsJsonAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetTreeAsJsonAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetTreeAsJsonAsync."); + } } /// @@ -151,10 +255,23 @@ public virtual async Task> GetTreeAsJsonAsync(CancellationTok /// The response returned from the service. public virtual ClientResult UpdateTree(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateTree."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateTreeRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateUpdateTreeRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateTree: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateTree."); + } } /// @@ -172,10 +289,23 @@ public virtual ClientResult UpdateTree(BinaryContent content, RequestOptions opt /// The response returned from the service. public virtual async Task UpdateTreeAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateTreeAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateTreeRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateUpdateTreeRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateTreeAsync."); + } } /// Update a tree as a plant. @@ -185,11 +315,24 @@ public virtual async Task UpdateTreeAsync(BinaryContent content, R /// Service returned a non-success status code. public virtual ClientResult UpdateTree(Tree tree, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(tree, nameof(tree)); + try + { + System.Console.WriteLine("Entering method UpdateTree."); + Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("X"); - ClientResult result = UpdateTree(content, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using BinaryContent content = tree.ToBinaryContent("X"); + ClientResult result = UpdateTree(content, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateTree: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateTree."); + } } /// Update a tree as a plant. @@ -199,11 +342,24 @@ public virtual ClientResult UpdateTree(Tree tree, CancellationToken cancel /// Service returned a non-success status code. public virtual async Task> UpdateTreeAsync(Tree tree, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(tree, nameof(tree)); + try + { + System.Console.WriteLine("Entering method UpdateTreeAsync."); + Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("X"); - ClientResult result = await UpdateTreeAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using BinaryContent content = tree.ToBinaryContent("X"); + ClientResult result = await UpdateTreeAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateTreeAsync."); + } } /// @@ -221,10 +377,23 @@ public virtual async Task> UpdateTreeAsync(Tree tree, Cancell /// The response returned from the service. public virtual ClientResult UpdateTreeAsJson(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateTreeAsJson."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateTreeAsJsonRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateUpdateTreeAsJsonRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsJson: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateTreeAsJson."); + } } /// @@ -242,10 +411,23 @@ public virtual ClientResult UpdateTreeAsJson(BinaryContent content, RequestOptio /// The response returned from the service. public virtual async Task UpdateTreeAsJsonAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateTreeAsJsonAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateTreeAsJsonRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateUpdateTreeAsJsonRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsJsonAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateTreeAsJsonAsync."); + } } /// Update a tree as a plant. @@ -255,11 +437,24 @@ public virtual async Task UpdateTreeAsJsonAsync(BinaryContent cont /// Service returned a non-success status code. public virtual ClientResult UpdateTreeAsJson(Tree tree, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(tree, nameof(tree)); + try + { + System.Console.WriteLine("Entering method UpdateTreeAsJson."); + Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("J"); - ClientResult result = UpdateTreeAsJson(content, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using BinaryContent content = tree.ToBinaryContent("J"); + ClientResult result = UpdateTreeAsJson(content, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsJson: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateTreeAsJson."); + } } /// Update a tree as a plant. @@ -269,11 +464,24 @@ public virtual ClientResult UpdateTreeAsJson(Tree tree, CancellationToken /// Service returned a non-success status code. public virtual async Task> UpdateTreeAsJsonAsync(Tree tree, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(tree, nameof(tree)); + try + { + System.Console.WriteLine("Entering method UpdateTreeAsJsonAsync."); + Argument.AssertNotNull(tree, nameof(tree)); - using BinaryContent content = tree.ToBinaryContent("J"); - ClientResult result = await UpdateTreeAsJsonAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + using BinaryContent content = tree.ToBinaryContent("J"); + ClientResult result = await UpdateTreeAsJsonAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Tree)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateTreeAsJsonAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateTreeAsJsonAsync."); + } } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs index 0f038c721bc..7388bc4fc20 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs @@ -216,14 +216,14 @@ internal PipelineMessage CreateReturnsAnonymousModelRequest(RequestOptions optio return message; } - internal PipelineMessage CreateGetUnknownValueRequest(RequestOptions options) + internal PipelineMessage CreateGetUnknownValueRequest(string accept, RequestOptions options) { ClientUriBuilder uri = new ClientUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/unknown-value", false); PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); PipelineRequest request = message.Request; - request.Headers.Set("Accept", "text/plain"); + request.Headers.Set("Accept", accept); message.Apply(options); return message; } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs index d5b160ecf7e..fdf22f78834 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs @@ -6,7 +6,6 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -17,9 +16,13 @@ namespace SampleTypeSpec public partial class SampleTypeSpecClient { private readonly Uri _endpoint; + /// A credential used to authenticate to the service. + private readonly ApiKeyCredential _keyCredential; private const string AuthorizationHeader = "my-api-key"; + /// A credential provider used to authenticate to the service. + private readonly AuthenticationTokenProvider _tokenProvider; /// The OAuth2 flows supported by the service. - private static readonly Dictionary[] _flows = new Dictionary[] + private readonly Dictionary[] _flows = new Dictionary[] { new Dictionary { @@ -56,50 +59,39 @@ protected SampleTypeSpecClient() } /// Initializes a new instance of SampleTypeSpecClient. - /// The authentication policy to use for pipeline creation. /// Service endpoint. + /// A credential used to authenticate to the service. /// The options for configuring the client. - internal SampleTypeSpecClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, SampleTypeSpecClientOptions options) + /// or is null. + public SampleTypeSpecClient(Uri endpoint, ApiKeyCredential credential, SampleTypeSpecClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); options ??= new SampleTypeSpecClientOptions(); _endpoint = endpoint; - if (authenticationPolicy != null) - { - Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(SampleTypeSpecClient).Assembly), authenticationPolicy }, Array.Empty()); - } - else - { - Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(SampleTypeSpecClient).Assembly) }, Array.Empty()); - } + _keyCredential = credential; + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(SampleTypeSpecClient).Assembly), ApiKeyAuthenticationPolicy.CreateHeaderApiKeyPolicy(_keyCredential, AuthorizationHeader) }, Array.Empty()); _apiVersion = options.Version; } - /// Initializes a new instance of SampleTypeSpecClient. - /// Service endpoint. - /// A credential used to authenticate to the service. - /// The options for configuring the client. - /// or is null. - public SampleTypeSpecClient(Uri endpoint, ApiKeyCredential credential, SampleTypeSpecClientOptions options) : this(ApiKeyAuthenticationPolicy.CreateHeaderApiKeyPolicy(credential, AuthorizationHeader), endpoint, options) - { - } - /// Initializes a new instance of SampleTypeSpecClient. /// Service endpoint. /// A credential provider used to authenticate to the service. /// The options for configuring the client. /// or is null. - public SampleTypeSpecClient(Uri endpoint, AuthenticationTokenProvider tokenProvider, SampleTypeSpecClientOptions options) : this(new BearerTokenPolicy(tokenProvider, _flows), endpoint, options) + public SampleTypeSpecClient(Uri endpoint, AuthenticationTokenProvider tokenProvider, SampleTypeSpecClientOptions options) { - } + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(tokenProvider, nameof(tokenProvider)); - /// Initializes a new instance of SampleTypeSpecClient from a . - /// The settings for SampleTypeSpecClient. - [Experimental("SCME0002")] - public SampleTypeSpecClient(SampleTypeSpecClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.SampleTypeSpecUrl, settings?.Options) - { + options ??= new SampleTypeSpecClientOptions(); + + _endpoint = endpoint; + _tokenProvider = tokenProvider; + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(SampleTypeSpecClient).Assembly), new BearerTokenPolicy(_tokenProvider, _flows) }, Array.Empty()); + _apiVersion = options.Version; } /// The HTTP pipeline for sending and receiving REST requests and responses. @@ -123,11 +115,24 @@ public SampleTypeSpecClient(SampleTypeSpecClientSettings settings) : this(Authen /// The response returned from the service. public virtual ClientResult SayHi(string headParameter, string queryParameter, string optionalQuery, RequestOptions options) { - Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); - Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); + try + { + System.Console.WriteLine("Entering method SayHi."); + Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); + Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - using PipelineMessage message = CreateSayHiRequest(headParameter, queryParameter, optionalQuery, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateSayHiRequest(headParameter, queryParameter, optionalQuery, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method SayHi: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method SayHi."); + } } /// @@ -148,11 +153,24 @@ public virtual ClientResult SayHi(string headParameter, string queryParameter, s /// The response returned from the service. public virtual async Task SayHiAsync(string headParameter, string queryParameter, string optionalQuery, RequestOptions options) { - Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); - Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); + try + { + System.Console.WriteLine("Entering method SayHiAsync."); + Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); + Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - using PipelineMessage message = CreateSayHiRequest(headParameter, queryParameter, optionalQuery, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateSayHiRequest(headParameter, queryParameter, optionalQuery, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method SayHiAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method SayHiAsync."); + } } /// Return hi. @@ -165,11 +183,24 @@ public virtual async Task SayHiAsync(string headParameter, string /// Service returned a non-success status code. public virtual ClientResult SayHi(string headParameter, string queryParameter, string optionalQuery = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); - Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); + try + { + System.Console.WriteLine("Entering method SayHi."); + Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); + Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - ClientResult result = SayHi(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + ClientResult result = SayHi(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method SayHi: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method SayHi."); + } } /// Return hi. @@ -182,11 +213,24 @@ public virtual ClientResult SayHi(string headParameter, string queryParam /// Service returned a non-success status code. public virtual async Task> SayHiAsync(string headParameter, string queryParameter, string optionalQuery = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); - Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); + try + { + System.Console.WriteLine("Entering method SayHiAsync."); + Argument.AssertNotNullOrEmpty(headParameter, nameof(headParameter)); + Argument.AssertNotNullOrEmpty(queryParameter, nameof(queryParameter)); - ClientResult result = await SayHiAsync(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + ClientResult result = await SayHiAsync(headParameter, queryParameter, optionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method SayHiAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method SayHiAsync."); + } } /// @@ -207,12 +251,25 @@ public virtual async Task> SayHiAsync(string headParameter, /// The response returned from the service. public virtual ClientResult HelloAgain(string p2, string p1, BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method HelloAgain."); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateHelloAgainRequest(p2, p1, content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateHelloAgainRequest(p2, p1, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloAgain: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloAgain."); + } } /// @@ -233,12 +290,25 @@ public virtual ClientResult HelloAgain(string p2, string p1, BinaryContent conte /// The response returned from the service. public virtual async Task HelloAgainAsync(string p2, string p1, BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method HelloAgainAsync."); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateHelloAgainRequest(p2, p1, content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateHelloAgainRequest(p2, p1, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloAgainAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloAgainAsync."); + } } /// Return hi again. @@ -251,12 +321,25 @@ public virtual async Task HelloAgainAsync(string p2, string p1, Bi /// Service returned a non-success status code. public virtual ClientResult HelloAgain(string p2, string p1, RoundTripModel action, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(action, nameof(action)); + try + { + System.Console.WriteLine("Entering method HelloAgain."); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(action, nameof(action)); - ClientResult result = HelloAgain(p2, p1, action, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + ClientResult result = HelloAgain(p2, p1, action, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloAgain: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloAgain."); + } } /// Return hi again. @@ -269,12 +352,25 @@ public virtual ClientResult HelloAgain(string p2, string p1, Rou /// Service returned a non-success status code. public virtual async Task> HelloAgainAsync(string p2, string p1, RoundTripModel action, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(action, nameof(action)); + try + { + System.Console.WriteLine("Entering method HelloAgainAsync."); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(action, nameof(action)); - ClientResult result = await HelloAgainAsync(p2, p1, action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + ClientResult result = await HelloAgainAsync(p2, p1, action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloAgainAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloAgainAsync."); + } } /// @@ -295,12 +391,25 @@ public virtual async Task> HelloAgainAsync(string p /// The response returned from the service. public virtual ClientResult NoContentType(string p2, string p1, BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method NoContentType."); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateNoContentTypeRequest(p2, p1, content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateNoContentTypeRequest(p2, p1, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method NoContentType: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method NoContentType."); + } } /// @@ -321,12 +430,25 @@ public virtual ClientResult NoContentType(string p2, string p1, BinaryContent co /// The response returned from the service. public virtual async Task NoContentTypeAsync(string p2, string p1, BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNullOrEmpty(p2, nameof(p2)); - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method NoContentTypeAsync."); + Argument.AssertNotNullOrEmpty(p2, nameof(p2)); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateNoContentTypeRequest(p2, p1, content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateNoContentTypeRequest(p2, p1, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method NoContentTypeAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method NoContentTypeAsync."); + } } /// Return hi again. @@ -336,10 +458,23 @@ public virtual async Task NoContentTypeAsync(string p2, string p1, /// Service returned a non-success status code. public virtual ClientResult NoContentType(Wrapper info, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(info, nameof(info)); + try + { + System.Console.WriteLine("Entering method NoContentType."); + Argument.AssertNotNull(info, nameof(info)); - ClientResult result = NoContentType(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + ClientResult result = NoContentType(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method NoContentType: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method NoContentType."); + } } /// Return hi again. @@ -349,10 +484,23 @@ public virtual ClientResult NoContentType(Wrapper info, Cancella /// Service returned a non-success status code. public virtual async Task> NoContentTypeAsync(Wrapper info, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(info, nameof(info)); + try + { + System.Console.WriteLine("Entering method NoContentTypeAsync."); + Argument.AssertNotNull(info, nameof(info)); - ClientResult result = await NoContentTypeAsync(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + ClientResult result = await NoContentTypeAsync(info.P2, info.P1, info.Action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RoundTripModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method NoContentTypeAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method NoContentTypeAsync."); + } } /// @@ -368,8 +516,21 @@ public virtual async Task> NoContentTypeAsync(Wrapp /// The response returned from the service. public virtual ClientResult HelloDemo2(RequestOptions options) { - using PipelineMessage message = CreateHelloDemo2Request(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method HelloDemo2."); + using PipelineMessage message = CreateHelloDemo2Request(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloDemo2: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloDemo2."); + } } /// @@ -385,8 +546,21 @@ public virtual ClientResult HelloDemo2(RequestOptions options) /// The response returned from the service. public virtual async Task HelloDemo2Async(RequestOptions options) { - using PipelineMessage message = CreateHelloDemo2Request(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method HelloDemo2Async."); + using PipelineMessage message = CreateHelloDemo2Request(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloDemo2Async: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloDemo2Async."); + } } /// Return hi in demo2. @@ -394,8 +568,21 @@ public virtual async Task HelloDemo2Async(RequestOptions options) /// Service returned a non-success status code. public virtual ClientResult HelloDemo2(CancellationToken cancellationToken = default) { - ClientResult result = HelloDemo2(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method HelloDemo2."); + ClientResult result = HelloDemo2(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloDemo2: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloDemo2."); + } } /// Return hi in demo2. @@ -403,8 +590,21 @@ public virtual ClientResult HelloDemo2(CancellationToken cancellationToke /// Service returned a non-success status code. public virtual async Task> HelloDemo2Async(CancellationToken cancellationToken = default) { - ClientResult result = await HelloDemo2Async(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method HelloDemo2Async."); + ClientResult result = await HelloDemo2Async(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloDemo2Async: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloDemo2Async."); + } } /// @@ -422,10 +622,23 @@ public virtual async Task> HelloDemo2Async(CancellationToken /// The response returned from the service. public virtual ClientResult CreateLiteral(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method CreateLiteral."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateCreateLiteralRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateCreateLiteralRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method CreateLiteral: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method CreateLiteral."); + } } /// @@ -443,10 +656,23 @@ public virtual ClientResult CreateLiteral(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task CreateLiteralAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method CreateLiteralAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateCreateLiteralRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateCreateLiteralRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method CreateLiteralAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method CreateLiteralAsync."); + } } /// Create with literal value. @@ -456,10 +682,23 @@ public virtual async Task CreateLiteralAsync(BinaryContent content /// Service returned a non-success status code. public virtual ClientResult CreateLiteral(Thing body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method CreateLiteral."); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = CreateLiteral(body, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + ClientResult result = CreateLiteral(body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method CreateLiteral: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method CreateLiteral."); + } } /// Create with literal value. @@ -469,10 +708,23 @@ public virtual ClientResult CreateLiteral(Thing body, CancellationToken c /// Service returned a non-success status code. public virtual async Task> CreateLiteralAsync(Thing body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method CreateLiteralAsync."); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = await CreateLiteralAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + ClientResult result = await CreateLiteralAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method CreateLiteralAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method CreateLiteralAsync."); + } } /// @@ -488,8 +740,21 @@ public virtual async Task> CreateLiteralAsync(Thing body, Ca /// The response returned from the service. public virtual ClientResult HelloLiteral(RequestOptions options) { - using PipelineMessage message = CreateHelloLiteralRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method HelloLiteral."); + using PipelineMessage message = CreateHelloLiteralRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloLiteral: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloLiteral."); + } } /// @@ -505,8 +770,21 @@ public virtual ClientResult HelloLiteral(RequestOptions options) /// The response returned from the service. public virtual async Task HelloLiteralAsync(RequestOptions options) { - using PipelineMessage message = CreateHelloLiteralRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method HelloLiteralAsync."); + using PipelineMessage message = CreateHelloLiteralRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloLiteralAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloLiteralAsync."); + } } /// Send literal parameters. @@ -514,8 +792,21 @@ public virtual async Task HelloLiteralAsync(RequestOptions options /// Service returned a non-success status code. public virtual ClientResult HelloLiteral(CancellationToken cancellationToken = default) { - ClientResult result = HelloLiteral(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method HelloLiteral."); + ClientResult result = HelloLiteral(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloLiteral: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloLiteral."); + } } /// Send literal parameters. @@ -523,8 +814,21 @@ public virtual ClientResult HelloLiteral(CancellationToken cancellationTo /// Service returned a non-success status code. public virtual async Task> HelloLiteralAsync(CancellationToken cancellationToken = default) { - ClientResult result = await HelloLiteralAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method HelloLiteralAsync."); + ClientResult result = await HelloLiteralAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HelloLiteralAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HelloLiteralAsync."); + } } /// @@ -541,8 +845,21 @@ public virtual async Task> HelloLiteralAsync(CancellationTok /// The response returned from the service. public virtual ClientResult TopAction(DateTimeOffset action, RequestOptions options) { - using PipelineMessage message = CreateTopActionRequest(action, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method TopAction."); + using PipelineMessage message = CreateTopActionRequest(action, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method TopAction: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method TopAction."); + } } /// @@ -559,8 +876,21 @@ public virtual ClientResult TopAction(DateTimeOffset action, RequestOptions opti /// The response returned from the service. public virtual async Task TopActionAsync(DateTimeOffset action, RequestOptions options) { - using PipelineMessage message = CreateTopActionRequest(action, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method TopActionAsync."); + using PipelineMessage message = CreateTopActionRequest(action, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method TopActionAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method TopActionAsync."); + } } /// top level method. @@ -569,8 +899,21 @@ public virtual async Task TopActionAsync(DateTimeOffset action, Re /// Service returned a non-success status code. public virtual ClientResult TopAction(DateTimeOffset action, CancellationToken cancellationToken = default) { - ClientResult result = TopAction(action, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method TopAction."); + ClientResult result = TopAction(action, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method TopAction: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method TopAction."); + } } /// top level method. @@ -579,8 +922,21 @@ public virtual ClientResult TopAction(DateTimeOffset action, Cancellation /// Service returned a non-success status code. public virtual async Task> TopActionAsync(DateTimeOffset action, CancellationToken cancellationToken = default) { - ClientResult result = await TopActionAsync(action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method TopActionAsync."); + ClientResult result = await TopActionAsync(action, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method TopActionAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method TopActionAsync."); + } } /// @@ -596,8 +952,21 @@ public virtual async Task> TopActionAsync(DateTimeOffset act /// The response returned from the service. public virtual ClientResult TopAction2(RequestOptions options = null) { - using PipelineMessage message = CreateTopAction2Request(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method TopAction2."); + using PipelineMessage message = CreateTopAction2Request(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method TopAction2: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method TopAction2."); + } } /// @@ -613,8 +982,21 @@ public virtual ClientResult TopAction2(RequestOptions options = null) /// The response returned from the service. public virtual async Task TopAction2Async(RequestOptions options = null) { - using PipelineMessage message = CreateTopAction2Request(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method TopAction2Async."); + using PipelineMessage message = CreateTopAction2Request(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method TopAction2Async: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method TopAction2Async."); + } } /// @@ -632,10 +1014,23 @@ public virtual async Task TopAction2Async(RequestOptions options = /// The response returned from the service. public virtual ClientResult PatchAction(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method PatchAction."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreatePatchActionRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreatePatchActionRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method PatchAction: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method PatchAction."); + } } /// @@ -653,10 +1048,23 @@ public virtual ClientResult PatchAction(BinaryContent content, RequestOptions op /// The response returned from the service. public virtual async Task PatchActionAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method PatchActionAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreatePatchActionRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreatePatchActionRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method PatchActionAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method PatchActionAsync."); + } } /// @@ -674,10 +1082,23 @@ public virtual async Task PatchActionAsync(BinaryContent content, /// The response returned from the service. public virtual ClientResult AnonymousBody(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method AnonymousBody."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateAnonymousBodyRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateAnonymousBodyRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method AnonymousBody: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method AnonymousBody."); + } } /// @@ -695,10 +1116,23 @@ public virtual ClientResult AnonymousBody(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task AnonymousBodyAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method AnonymousBodyAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateAnonymousBodyRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateAnonymousBodyRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method AnonymousBodyAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method AnonymousBodyAsync."); + } } /// body parameter without body decorator. @@ -724,32 +1158,45 @@ public virtual async Task AnonymousBodyAsync(BinaryContent content /// Service returned a non-success status code. public virtual ClientResult AnonymousBody(string name, BinaryData requiredUnion, string requiredNullableString, ThingRequiredNullableLiteralString1? requiredNullableLiteralString, string requiredBadDescription, IEnumerable requiredNullableList, string propertyWithSpecialDocs, string optionalNullableString = default, ThingOptionalLiteralString? optionalLiteralString = default, ThingOptionalLiteralInt? optionalLiteralInt = default, ThingOptionalLiteralFloat? optionalLiteralFloat = default, bool? optionalLiteralBool = default, IEnumerable optionalNullableList = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(requiredUnion, nameof(requiredUnion)); - Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); - Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); - - Thing spreadModel = new Thing( - name, - requiredUnion, - "accept", - requiredNullableString, - optionalNullableString, - 123, - 1.23F, - false, - optionalLiteralString, - requiredNullableLiteralString, - optionalLiteralInt, - optionalLiteralFloat, - optionalLiteralBool, - requiredBadDescription, - optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), - requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), - propertyWithSpecialDocs, - default); - ClientResult result = AnonymousBody(spreadModel, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method AnonymousBody."); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(requiredUnion, nameof(requiredUnion)); + Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); + Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); + + Thing spreadModel = new Thing( + name, + requiredUnion, + "accept", + requiredNullableString, + optionalNullableString, + 123, + 1.23F, + false, + optionalLiteralString, + requiredNullableLiteralString, + optionalLiteralInt, + optionalLiteralFloat, + optionalLiteralBool, + requiredBadDescription, + optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), + requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), + propertyWithSpecialDocs, + default); + ClientResult result = AnonymousBody(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method AnonymousBody: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method AnonymousBody."); + } } /// body parameter without body decorator. @@ -775,32 +1222,45 @@ public virtual ClientResult AnonymousBody(string name, BinaryData require /// Service returned a non-success status code. public virtual async Task> AnonymousBodyAsync(string name, BinaryData requiredUnion, string requiredNullableString, ThingRequiredNullableLiteralString1? requiredNullableLiteralString, string requiredBadDescription, IEnumerable requiredNullableList, string propertyWithSpecialDocs, string optionalNullableString = default, ThingOptionalLiteralString? optionalLiteralString = default, ThingOptionalLiteralInt? optionalLiteralInt = default, ThingOptionalLiteralFloat? optionalLiteralFloat = default, bool? optionalLiteralBool = default, IEnumerable optionalNullableList = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(requiredUnion, nameof(requiredUnion)); - Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); - Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); - - Thing spreadModel = new Thing( - name, - requiredUnion, - "accept", - requiredNullableString, - optionalNullableString, - 123, - 1.23F, - false, - optionalLiteralString, - requiredNullableLiteralString, - optionalLiteralInt, - optionalLiteralFloat, - optionalLiteralBool, - requiredBadDescription, - optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), - requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), - propertyWithSpecialDocs, - default); - ClientResult result = await AnonymousBodyAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method AnonymousBodyAsync."); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(requiredUnion, nameof(requiredUnion)); + Argument.AssertNotNullOrEmpty(requiredBadDescription, nameof(requiredBadDescription)); + Argument.AssertNotNullOrEmpty(propertyWithSpecialDocs, nameof(propertyWithSpecialDocs)); + + Thing spreadModel = new Thing( + name, + requiredUnion, + "accept", + requiredNullableString, + optionalNullableString, + 123, + 1.23F, + false, + optionalLiteralString, + requiredNullableLiteralString, + optionalLiteralInt, + optionalLiteralFloat, + optionalLiteralBool, + requiredBadDescription, + optionalNullableList?.ToList() as IList ?? new ChangeTrackingList(), + requiredNullableList?.ToList() as IList ?? new ChangeTrackingList(), + propertyWithSpecialDocs, + default); + ClientResult result = await AnonymousBodyAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method AnonymousBodyAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method AnonymousBodyAsync."); + } } /// @@ -818,10 +1278,23 @@ public virtual async Task> AnonymousBodyAsync(string name, B /// The response returned from the service. public virtual ClientResult FriendlyModel(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method FriendlyModel."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateFriendlyModelRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateFriendlyModelRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method FriendlyModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method FriendlyModel."); + } } /// @@ -839,10 +1312,23 @@ public virtual ClientResult FriendlyModel(BinaryContent content, RequestOptions /// The response returned from the service. public virtual async Task FriendlyModelAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method FriendlyModelAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateFriendlyModelRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateFriendlyModelRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method FriendlyModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method FriendlyModelAsync."); + } } /// Model can have its friendly name. @@ -853,11 +1339,24 @@ public virtual async Task FriendlyModelAsync(BinaryContent content /// Service returned a non-success status code. public virtual ClientResult FriendlyModel(string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); + try + { + System.Console.WriteLine("Entering method FriendlyModel."); + Argument.AssertNotNullOrEmpty(name, nameof(name)); - Friend spreadModel = new Friend(name, default); - ClientResult result = FriendlyModel(spreadModel, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Friend)result, result.GetRawResponse()); + Friend spreadModel = new Friend(name, default); + ClientResult result = FriendlyModel(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Friend)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method FriendlyModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method FriendlyModel."); + } } /// Model can have its friendly name. @@ -868,11 +1367,24 @@ public virtual ClientResult FriendlyModel(string name, CancellationToken /// Service returned a non-success status code. public virtual async Task> FriendlyModelAsync(string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); + try + { + System.Console.WriteLine("Entering method FriendlyModelAsync."); + Argument.AssertNotNullOrEmpty(name, nameof(name)); - Friend spreadModel = new Friend(name, default); - ClientResult result = await FriendlyModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Friend)result, result.GetRawResponse()); + Friend spreadModel = new Friend(name, default); + ClientResult result = await FriendlyModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Friend)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method FriendlyModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method FriendlyModelAsync."); + } } /// @@ -888,8 +1400,21 @@ public virtual async Task> FriendlyModelAsync(string name, /// The response returned from the service. public virtual ClientResult AddTimeHeader(RequestOptions options) { - using PipelineMessage message = CreateAddTimeHeaderRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method AddTimeHeader."); + using PipelineMessage message = CreateAddTimeHeaderRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method AddTimeHeader: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method AddTimeHeader."); + } } /// @@ -905,8 +1430,21 @@ public virtual ClientResult AddTimeHeader(RequestOptions options) /// The response returned from the service. public virtual async Task AddTimeHeaderAsync(RequestOptions options) { - using PipelineMessage message = CreateAddTimeHeaderRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method AddTimeHeaderAsync."); + using PipelineMessage message = CreateAddTimeHeaderRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method AddTimeHeaderAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method AddTimeHeaderAsync."); + } } /// AddTimeHeader. @@ -914,7 +1452,20 @@ public virtual async Task AddTimeHeaderAsync(RequestOptions option /// Service returned a non-success status code. public virtual ClientResult AddTimeHeader(CancellationToken cancellationToken = default) { - return AddTimeHeader(cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method AddTimeHeader."); + return AddTimeHeader(cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method AddTimeHeader: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method AddTimeHeader."); + } } /// AddTimeHeader. @@ -922,7 +1473,20 @@ public virtual ClientResult AddTimeHeader(CancellationToken cancellationToken = /// Service returned a non-success status code. public virtual async Task AddTimeHeaderAsync(CancellationToken cancellationToken = default) { - return await AddTimeHeaderAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + try + { + System.Console.WriteLine("Entering method AddTimeHeaderAsync."); + return await AddTimeHeaderAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method AddTimeHeaderAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method AddTimeHeaderAsync."); + } } /// @@ -940,10 +1504,23 @@ public virtual async Task AddTimeHeaderAsync(CancellationToken can /// The response returned from the service. public virtual ClientResult ProjectedNameModel(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method ProjectedNameModel."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateProjectedNameModelRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateProjectedNameModelRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method ProjectedNameModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method ProjectedNameModel."); + } } /// @@ -961,10 +1538,23 @@ public virtual ClientResult ProjectedNameModel(BinaryContent content, RequestOpt /// The response returned from the service. public virtual async Task ProjectedNameModelAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method ProjectedNameModelAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateProjectedNameModelRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateProjectedNameModelRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method ProjectedNameModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method ProjectedNameModelAsync."); + } } /// Model can have its projected name. @@ -975,11 +1565,24 @@ public virtual async Task ProjectedNameModelAsync(BinaryContent co /// Service returned a non-success status code. public virtual ClientResult ProjectedNameModel(string otherName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); + try + { + System.Console.WriteLine("Entering method ProjectedNameModel."); + Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); - RenamedModel spreadModel = new RenamedModel(otherName, default); - ClientResult result = ProjectedNameModel(spreadModel, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((RenamedModel)result, result.GetRawResponse()); + RenamedModel spreadModel = new RenamedModel(otherName, default); + ClientResult result = ProjectedNameModel(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RenamedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method ProjectedNameModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method ProjectedNameModel."); + } } /// Model can have its projected name. @@ -990,11 +1593,24 @@ public virtual ClientResult ProjectedNameModel(string otherName, C /// Service returned a non-success status code. public virtual async Task> ProjectedNameModelAsync(string otherName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); + try + { + System.Console.WriteLine("Entering method ProjectedNameModelAsync."); + Argument.AssertNotNullOrEmpty(otherName, nameof(otherName)); - RenamedModel spreadModel = new RenamedModel(otherName, default); - ClientResult result = await ProjectedNameModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((RenamedModel)result, result.GetRawResponse()); + RenamedModel spreadModel = new RenamedModel(otherName, default); + ClientResult result = await ProjectedNameModelAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RenamedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method ProjectedNameModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method ProjectedNameModelAsync."); + } } /// @@ -1010,8 +1626,21 @@ public virtual async Task> ProjectedNameModelAsync(st /// The response returned from the service. public virtual ClientResult ReturnsAnonymousModel(RequestOptions options) { - using PipelineMessage message = CreateReturnsAnonymousModelRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method ReturnsAnonymousModel."); + using PipelineMessage message = CreateReturnsAnonymousModelRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method ReturnsAnonymousModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method ReturnsAnonymousModel."); + } } /// @@ -1027,8 +1656,21 @@ public virtual ClientResult ReturnsAnonymousModel(RequestOptions options) /// The response returned from the service. public virtual async Task ReturnsAnonymousModelAsync(RequestOptions options) { - using PipelineMessage message = CreateReturnsAnonymousModelRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method ReturnsAnonymousModelAsync."); + using PipelineMessage message = CreateReturnsAnonymousModelRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method ReturnsAnonymousModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method ReturnsAnonymousModelAsync."); + } } /// return anonymous model. @@ -1036,8 +1678,21 @@ public virtual async Task ReturnsAnonymousModelAsync(RequestOption /// Service returned a non-success status code. public virtual ClientResult ReturnsAnonymousModel(CancellationToken cancellationToken = default) { - ClientResult result = ReturnsAnonymousModel(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method ReturnsAnonymousModel."); + ClientResult result = ReturnsAnonymousModel(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method ReturnsAnonymousModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method ReturnsAnonymousModel."); + } } /// return anonymous model. @@ -1045,8 +1700,21 @@ public virtual ClientResult ReturnsAnonymousModel /// Service returned a non-success status code. public virtual async Task> ReturnsAnonymousModelAsync(CancellationToken cancellationToken = default) { - ClientResult result = await ReturnsAnonymousModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method ReturnsAnonymousModelAsync."); + ClientResult result = await ReturnsAnonymousModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ReturnsAnonymousModelResponse)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method ReturnsAnonymousModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method ReturnsAnonymousModelAsync."); + } } /// @@ -1057,13 +1725,31 @@ public virtual async Task> ReturnsAn /// /// /// + /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - public virtual ClientResult GetUnknownValue(RequestOptions options) + public virtual ClientResult GetUnknownValue(string accept, RequestOptions options) { - using PipelineMessage message = CreateGetUnknownValueRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method GetUnknownValue."); + Argument.AssertNotNullOrEmpty(accept, nameof(accept)); + + using PipelineMessage message = CreateGetUnknownValueRequest(accept, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetUnknownValue: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetUnknownValue."); + } } /// @@ -1074,31 +1760,85 @@ public virtual ClientResult GetUnknownValue(RequestOptions options) /// /// /// + /// /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - public virtual async Task GetUnknownValueAsync(RequestOptions options) + public virtual async Task GetUnknownValueAsync(string accept, RequestOptions options) { - using PipelineMessage message = CreateGetUnknownValueRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method GetUnknownValueAsync."); + Argument.AssertNotNullOrEmpty(accept, nameof(accept)); + + using PipelineMessage message = CreateGetUnknownValueRequest(accept, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetUnknownValueAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetUnknownValueAsync."); + } } /// get extensible enum. + /// /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - public virtual ClientResult GetUnknownValue(CancellationToken cancellationToken = default) + public virtual ClientResult GetUnknownValue(string accept, CancellationToken cancellationToken = default) { - ClientResult result = GetUnknownValue(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetUnknownValue."); + Argument.AssertNotNullOrEmpty(accept, nameof(accept)); + + ClientResult result = GetUnknownValue(accept, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetUnknownValue: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetUnknownValue."); + } } /// get extensible enum. + /// /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. - public virtual async Task> GetUnknownValueAsync(CancellationToken cancellationToken = default) + public virtual async Task> GetUnknownValueAsync(string accept, CancellationToken cancellationToken = default) { - ClientResult result = await GetUnknownValueAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetUnknownValueAsync."); + Argument.AssertNotNullOrEmpty(accept, nameof(accept)); + + ClientResult result = await GetUnknownValueAsync(accept, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue(result.GetRawResponse().Content.ToString(), result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetUnknownValueAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetUnknownValueAsync."); + } } /// @@ -1116,10 +1856,23 @@ public virtual async Task> GetUnknownValueAsync(Cancellatio /// The response returned from the service. public virtual ClientResult InternalProtocol(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method InternalProtocol."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateInternalProtocolRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateInternalProtocolRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method InternalProtocol: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method InternalProtocol."); + } } /// @@ -1137,10 +1890,23 @@ public virtual ClientResult InternalProtocol(BinaryContent content, RequestOptio /// The response returned from the service. public virtual async Task InternalProtocolAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method InternalProtocolAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateInternalProtocolRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateInternalProtocolRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method InternalProtocolAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method InternalProtocolAsync."); + } } /// When set protocol false and convenient true, then the protocol method should be internal. @@ -1150,10 +1916,23 @@ public virtual async Task InternalProtocolAsync(BinaryContent cont /// Service returned a non-success status code. public virtual ClientResult InternalProtocol(Thing body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method InternalProtocol."); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = InternalProtocol(body, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + ClientResult result = InternalProtocol(body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method InternalProtocol: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method InternalProtocol."); + } } /// When set protocol false and convenient true, then the protocol method should be internal. @@ -1163,10 +1942,23 @@ public virtual ClientResult InternalProtocol(Thing body, CancellationToke /// Service returned a non-success status code. public virtual async Task> InternalProtocolAsync(Thing body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method InternalProtocolAsync."); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = await InternalProtocolAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + ClientResult result = await InternalProtocolAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Thing)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method InternalProtocolAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method InternalProtocolAsync."); + } } /// @@ -1182,8 +1974,21 @@ public virtual async Task> InternalProtocolAsync(Thing body, /// The response returned from the service. public virtual ClientResult StillConvenient(RequestOptions options) { - using PipelineMessage message = CreateStillConvenientRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method StillConvenient."); + using PipelineMessage message = CreateStillConvenientRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method StillConvenient: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method StillConvenient."); + } } /// @@ -1199,8 +2004,21 @@ public virtual ClientResult StillConvenient(RequestOptions options) /// The response returned from the service. public virtual async Task StillConvenientAsync(RequestOptions options) { - using PipelineMessage message = CreateStillConvenientRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method StillConvenientAsync."); + using PipelineMessage message = CreateStillConvenientRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method StillConvenientAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method StillConvenientAsync."); + } } /// When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one. @@ -1208,7 +2026,20 @@ public virtual async Task StillConvenientAsync(RequestOptions opti /// Service returned a non-success status code. public virtual ClientResult StillConvenient(CancellationToken cancellationToken = default) { - return StillConvenient(cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method StillConvenient."); + return StillConvenient(cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method StillConvenient: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method StillConvenient."); + } } /// When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one. @@ -1216,7 +2047,20 @@ public virtual ClientResult StillConvenient(CancellationToken cancellationToken /// Service returned a non-success status code. public virtual async Task StillConvenientAsync(CancellationToken cancellationToken = default) { - return await StillConvenientAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + try + { + System.Console.WriteLine("Entering method StillConvenientAsync."); + return await StillConvenientAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method StillConvenientAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method StillConvenientAsync."); + } } /// @@ -1235,10 +2079,23 @@ public virtual async Task StillConvenientAsync(CancellationToken c /// The response returned from the service. public virtual ClientResult HeadAsBoolean(string id, RequestOptions options) { - Argument.AssertNotNullOrEmpty(id, nameof(id)); + try + { + System.Console.WriteLine("Entering method HeadAsBoolean."); + Argument.AssertNotNullOrEmpty(id, nameof(id)); - using PipelineMessage message = CreateHeadAsBooleanRequest(id, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateHeadAsBooleanRequest(id, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HeadAsBoolean: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HeadAsBoolean."); + } } /// @@ -1257,10 +2114,23 @@ public virtual ClientResult HeadAsBoolean(string id, RequestOptions options) /// The response returned from the service. public virtual async Task HeadAsBooleanAsync(string id, RequestOptions options) { - Argument.AssertNotNullOrEmpty(id, nameof(id)); + try + { + System.Console.WriteLine("Entering method HeadAsBooleanAsync."); + Argument.AssertNotNullOrEmpty(id, nameof(id)); - using PipelineMessage message = CreateHeadAsBooleanRequest(id, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateHeadAsBooleanRequest(id, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HeadAsBooleanAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HeadAsBooleanAsync."); + } } /// head as boolean. @@ -1271,9 +2141,22 @@ public virtual async Task HeadAsBooleanAsync(string id, RequestOpt /// Service returned a non-success status code. public virtual ClientResult HeadAsBoolean(string id, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(id, nameof(id)); + try + { + System.Console.WriteLine("Entering method HeadAsBoolean."); + Argument.AssertNotNullOrEmpty(id, nameof(id)); - return HeadAsBoolean(id, cancellationToken.ToRequestOptions()); + return HeadAsBoolean(id, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HeadAsBoolean: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HeadAsBoolean."); + } } /// head as boolean. @@ -1284,9 +2167,22 @@ public virtual ClientResult HeadAsBoolean(string id, CancellationToken cancellat /// Service returned a non-success status code. public virtual async Task HeadAsBooleanAsync(string id, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(id, nameof(id)); + try + { + System.Console.WriteLine("Entering method HeadAsBooleanAsync."); + Argument.AssertNotNullOrEmpty(id, nameof(id)); - return await HeadAsBooleanAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return await HeadAsBooleanAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method HeadAsBooleanAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method HeadAsBooleanAsync."); + } } /// @@ -1305,10 +2201,23 @@ public virtual async Task HeadAsBooleanAsync(string id, Cancellati /// The response returned from the service. public virtual ClientResult WithApiVersion(string p1, RequestOptions options) { - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + try + { + System.Console.WriteLine("Entering method WithApiVersion."); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - using PipelineMessage message = CreateWithApiVersionRequest(p1, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateWithApiVersionRequest(p1, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method WithApiVersion: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method WithApiVersion."); + } } /// @@ -1327,10 +2236,23 @@ public virtual ClientResult WithApiVersion(string p1, RequestOptions options) /// The response returned from the service. public virtual async Task WithApiVersionAsync(string p1, RequestOptions options) { - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + try + { + System.Console.WriteLine("Entering method WithApiVersionAsync."); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - using PipelineMessage message = CreateWithApiVersionRequest(p1, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateWithApiVersionRequest(p1, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method WithApiVersionAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method WithApiVersionAsync."); + } } /// Return hi again. @@ -1341,9 +2263,22 @@ public virtual async Task WithApiVersionAsync(string p1, RequestOp /// Service returned a non-success status code. public virtual ClientResult WithApiVersion(string p1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + try + { + System.Console.WriteLine("Entering method WithApiVersion."); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - return WithApiVersion(p1, cancellationToken.ToRequestOptions()); + return WithApiVersion(p1, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method WithApiVersion: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method WithApiVersion."); + } } /// Return hi again. @@ -1354,9 +2289,22 @@ public virtual ClientResult WithApiVersion(string p1, CancellationToken cancella /// Service returned a non-success status code. public virtual async Task WithApiVersionAsync(string p1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(p1, nameof(p1)); + try + { + System.Console.WriteLine("Entering method WithApiVersionAsync."); + Argument.AssertNotNullOrEmpty(p1, nameof(p1)); - return await WithApiVersionAsync(p1, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return await WithApiVersionAsync(p1, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method WithApiVersionAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method WithApiVersionAsync."); + } } /// @@ -1372,7 +2320,20 @@ public virtual async Task WithApiVersionAsync(string p1, Cancellat /// The response returned from the service. public virtual CollectionResult GetWithNextLink(RequestOptions options) { - return new SampleTypeSpecClientGetWithNextLinkCollectionResult(this, options); + try + { + System.Console.WriteLine("Entering method GetWithNextLink."); + return new SampleTypeSpecClientGetWithNextLinkCollectionResult(this, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithNextLink: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithNextLink."); + } } /// @@ -1388,7 +2349,20 @@ public virtual CollectionResult GetWithNextLink(RequestOptions options) /// The response returned from the service. public virtual AsyncCollectionResult GetWithNextLinkAsync(RequestOptions options) { - return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult(this, options); + try + { + System.Console.WriteLine("Entering method GetWithNextLinkAsync."); + return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult(this, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithNextLinkAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithNextLinkAsync."); + } } /// List things with nextlink. @@ -1396,7 +2370,20 @@ public virtual AsyncCollectionResult GetWithNextLinkAsync(RequestOptions options /// Service returned a non-success status code. public virtual CollectionResult GetWithNextLink(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithNextLink."); + return new SampleTypeSpecClientGetWithNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithNextLink: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithNextLink."); + } } /// List things with nextlink. @@ -1404,7 +2391,20 @@ public virtual CollectionResult GetWithNextLink(CancellationToken cancell /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithNextLinkAsync(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithNextLinkAsync."); + return new SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithNextLinkAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithNextLinkAsync."); + } } /// @@ -1420,7 +2420,20 @@ public virtual AsyncCollectionResult GetWithNextLinkAsync(CancellationTok /// The response returned from the service. public virtual CollectionResult GetWithStringNextLink(RequestOptions options) { - return new SampleTypeSpecClientGetWithStringNextLinkCollectionResult(this, options); + try + { + System.Console.WriteLine("Entering method GetWithStringNextLink."); + return new SampleTypeSpecClientGetWithStringNextLinkCollectionResult(this, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithStringNextLink: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithStringNextLink."); + } } /// @@ -1436,7 +2449,20 @@ public virtual CollectionResult GetWithStringNextLink(RequestOptions options) /// The response returned from the service. public virtual AsyncCollectionResult GetWithStringNextLinkAsync(RequestOptions options) { - return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult(this, options); + try + { + System.Console.WriteLine("Entering method GetWithStringNextLinkAsync."); + return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult(this, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithStringNextLinkAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithStringNextLinkAsync."); + } } /// List things with nextlink. @@ -1444,7 +2470,20 @@ public virtual AsyncCollectionResult GetWithStringNextLinkAsync(RequestOptions o /// Service returned a non-success status code. public virtual CollectionResult GetWithStringNextLink(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithStringNextLink."); + return new SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithStringNextLink: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithStringNextLink."); + } } /// List things with nextlink. @@ -1452,7 +2491,20 @@ public virtual CollectionResult GetWithStringNextLink(CancellationToken c /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithStringNextLinkAsync(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithStringNextLinkAsync."); + return new SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithStringNextLinkAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithStringNextLinkAsync."); + } } /// @@ -1469,7 +2521,20 @@ public virtual AsyncCollectionResult GetWithStringNextLinkAsync(Cancellat /// The response returned from the service. public virtual CollectionResult GetWithContinuationToken(string token, RequestOptions options) { - return new SampleTypeSpecClientGetWithContinuationTokenCollectionResult(this, token, options); + try + { + System.Console.WriteLine("Entering method GetWithContinuationToken."); + return new SampleTypeSpecClientGetWithContinuationTokenCollectionResult(this, token, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithContinuationToken: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithContinuationToken."); + } } /// @@ -1486,7 +2551,20 @@ public virtual CollectionResult GetWithContinuationToken(string token, RequestOp /// The response returned from the service. public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string token, RequestOptions options) { - return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult(this, token, options); + try + { + System.Console.WriteLine("Entering method GetWithContinuationTokenAsync."); + return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult(this, token, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithContinuationTokenAsync."); + } } /// List things with continuation token. @@ -1495,7 +2573,20 @@ public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string token, /// Service returned a non-success status code. public virtual CollectionResult GetWithContinuationToken(string token = default, CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithContinuationToken."); + return new SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithContinuationToken: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithContinuationToken."); + } } /// List things with continuation token. @@ -1504,7 +2595,20 @@ public virtual CollectionResult GetWithContinuationToken(string token = d /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string token = default, CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithContinuationTokenAsync."); + return new SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithContinuationTokenAsync."); + } } /// @@ -1521,7 +2625,20 @@ public virtual AsyncCollectionResult GetWithContinuationTokenAsync(string /// The response returned from the service. public virtual CollectionResult GetWithContinuationTokenHeaderResponse(string token, RequestOptions options) { - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult(this, token, options); + try + { + System.Console.WriteLine("Entering method GetWithContinuationTokenHeaderResponse."); + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult(this, token, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenHeaderResponse: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithContinuationTokenHeaderResponse."); + } } /// @@ -1538,7 +2655,20 @@ public virtual CollectionResult GetWithContinuationTokenHeaderResponse(string to /// The response returned from the service. public virtual AsyncCollectionResult GetWithContinuationTokenHeaderResponseAsync(string token, RequestOptions options) { - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult(this, token, options); + try + { + System.Console.WriteLine("Entering method GetWithContinuationTokenHeaderResponseAsync."); + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult(this, token, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenHeaderResponseAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithContinuationTokenHeaderResponseAsync."); + } } /// List things with continuation token header response. @@ -1547,7 +2677,20 @@ public virtual AsyncCollectionResult GetWithContinuationTokenHeaderResponseAsync /// Service returned a non-success status code. public virtual CollectionResult GetWithContinuationTokenHeaderResponse(string token = default, CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithContinuationTokenHeaderResponse."); + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenHeaderResponse: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithContinuationTokenHeaderResponse."); + } } /// List things with continuation token header response. @@ -1556,7 +2699,20 @@ public virtual CollectionResult GetWithContinuationTokenHeaderResponse(st /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithContinuationTokenHeaderResponseAsync(string token = default, CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithContinuationTokenHeaderResponseAsync."); + return new SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT(this, token, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithContinuationTokenHeaderResponseAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithContinuationTokenHeaderResponseAsync."); + } } /// @@ -1572,7 +2728,20 @@ public virtual AsyncCollectionResult GetWithContinuationTokenHeaderRespon /// The response returned from the service. public virtual CollectionResult GetWithPaging(RequestOptions options) { - return new SampleTypeSpecClientGetWithPagingCollectionResult(this, options); + try + { + System.Console.WriteLine("Entering method GetWithPaging."); + return new SampleTypeSpecClientGetWithPagingCollectionResult(this, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithPaging: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithPaging."); + } } /// @@ -1588,7 +2757,20 @@ public virtual CollectionResult GetWithPaging(RequestOptions options) /// The response returned from the service. public virtual AsyncCollectionResult GetWithPagingAsync(RequestOptions options) { - return new SampleTypeSpecClientGetWithPagingAsyncCollectionResult(this, options); + try + { + System.Console.WriteLine("Entering method GetWithPagingAsync."); + return new SampleTypeSpecClientGetWithPagingAsyncCollectionResult(this, options); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithPagingAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithPagingAsync."); + } } /// List things with paging. @@ -1596,7 +2778,20 @@ public virtual AsyncCollectionResult GetWithPagingAsync(RequestOptions options) /// Service returned a non-success status code. public virtual CollectionResult GetWithPaging(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithPagingCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithPaging."); + return new SampleTypeSpecClientGetWithPagingCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithPaging: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithPaging."); + } } /// List things with paging. @@ -1604,7 +2799,20 @@ public virtual CollectionResult GetWithPaging(CancellationToken cancellat /// Service returned a non-success status code. public virtual AsyncCollectionResult GetWithPagingAsync(CancellationToken cancellationToken = default) { - return new SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + try + { + System.Console.WriteLine("Entering method GetWithPagingAsync."); + return new SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetWithPagingAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetWithPagingAsync."); + } } /// @@ -1627,12 +2835,25 @@ public virtual AsyncCollectionResult GetWithPagingAsync(CancellationToken /// The response returned from the service. public virtual ClientResult EmbeddedParameters(string requiredHeader, string requiredQuery, BinaryContent content, string optionalHeader = default, string optionalQuery = default, RequestOptions options = null) { - Argument.AssertNotNullOrEmpty(requiredHeader, nameof(requiredHeader)); - Argument.AssertNotNullOrEmpty(requiredQuery, nameof(requiredQuery)); - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method EmbeddedParameters."); + Argument.AssertNotNullOrEmpty(requiredHeader, nameof(requiredHeader)); + Argument.AssertNotNullOrEmpty(requiredQuery, nameof(requiredQuery)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateEmbeddedParametersRequest(requiredHeader, requiredQuery, content, optionalHeader, optionalQuery, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateEmbeddedParametersRequest(requiredHeader, requiredQuery, content, optionalHeader, optionalQuery, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method EmbeddedParameters: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method EmbeddedParameters."); + } } /// @@ -1655,12 +2876,25 @@ public virtual ClientResult EmbeddedParameters(string requiredHeader, string req /// The response returned from the service. public virtual async Task EmbeddedParametersAsync(string requiredHeader, string requiredQuery, BinaryContent content, string optionalHeader = default, string optionalQuery = default, RequestOptions options = null) { - Argument.AssertNotNullOrEmpty(requiredHeader, nameof(requiredHeader)); - Argument.AssertNotNullOrEmpty(requiredQuery, nameof(requiredQuery)); - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method EmbeddedParametersAsync."); + Argument.AssertNotNullOrEmpty(requiredHeader, nameof(requiredHeader)); + Argument.AssertNotNullOrEmpty(requiredQuery, nameof(requiredQuery)); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateEmbeddedParametersRequest(requiredHeader, requiredQuery, content, optionalHeader, optionalQuery, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateEmbeddedParametersRequest(requiredHeader, requiredQuery, content, optionalHeader, optionalQuery, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method EmbeddedParametersAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method EmbeddedParametersAsync."); + } } /// An operation with embedded parameters within the body. @@ -1670,9 +2904,22 @@ public virtual async Task EmbeddedParametersAsync(string requiredH /// Service returned a non-success status code. public virtual ClientResult EmbeddedParameters(ModelWithEmbeddedNonBodyParameters body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method EmbeddedParameters."); + Argument.AssertNotNull(body, nameof(body)); - return EmbeddedParameters(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()); + return EmbeddedParameters(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method EmbeddedParameters: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method EmbeddedParameters."); + } } /// An operation with embedded parameters within the body. @@ -1682,9 +2929,22 @@ public virtual ClientResult EmbeddedParameters(ModelWithEmbeddedNonBodyParameter /// Service returned a non-success status code. public virtual async Task EmbeddedParametersAsync(ModelWithEmbeddedNonBodyParameters body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method EmbeddedParametersAsync."); + Argument.AssertNotNull(body, nameof(body)); - return await EmbeddedParametersAsync(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return await EmbeddedParametersAsync(body.RequiredHeader, body.RequiredQuery, body, body.OptionalHeader, body.OptionalQuery, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method EmbeddedParametersAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method EmbeddedParametersAsync."); + } } /// @@ -1702,10 +2962,23 @@ public virtual async Task EmbeddedParametersAsync(ModelWithEmbedde /// The response returned from the service. public virtual ClientResult DynamicModelOperation(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method DynamicModelOperation."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateDynamicModelOperationRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateDynamicModelOperationRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method DynamicModelOperation: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method DynamicModelOperation."); + } } /// @@ -1723,10 +2996,23 @@ public virtual ClientResult DynamicModelOperation(BinaryContent content, Request /// The response returned from the service. public virtual async Task DynamicModelOperationAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method DynamicModelOperationAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateDynamicModelOperationRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateDynamicModelOperationRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method DynamicModelOperationAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method DynamicModelOperationAsync."); + } } /// An operation with a dynamic model. @@ -1736,9 +3022,22 @@ public virtual async Task DynamicModelOperationAsync(BinaryContent /// Service returned a non-success status code. public virtual ClientResult DynamicModelOperation(DynamicModel body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method DynamicModelOperation."); + Argument.AssertNotNull(body, nameof(body)); - return DynamicModelOperation(body, cancellationToken.ToRequestOptions()); + return DynamicModelOperation(body, cancellationToken.ToRequestOptions()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method DynamicModelOperation: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method DynamicModelOperation."); + } } /// An operation with a dynamic model. @@ -1748,9 +3047,22 @@ public virtual ClientResult DynamicModelOperation(DynamicModel body, Cancellatio /// Service returned a non-success status code. public virtual async Task DynamicModelOperationAsync(DynamicModel body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method DynamicModelOperationAsync."); + Argument.AssertNotNull(body, nameof(body)); - return await DynamicModelOperationAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return await DynamicModelOperationAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method DynamicModelOperationAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method DynamicModelOperationAsync."); + } } /// @@ -1766,8 +3078,21 @@ public virtual async Task DynamicModelOperationAsync(DynamicModel /// The response returned from the service. public virtual ClientResult GetXmlAdvancedModel(RequestOptions options) { - using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + try + { + System.Console.WriteLine("Entering method GetXmlAdvancedModel."); + using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetXmlAdvancedModel."); + } } /// @@ -1783,8 +3108,21 @@ public virtual ClientResult GetXmlAdvancedModel(RequestOptions options) /// The response returned from the service. public virtual async Task GetXmlAdvancedModelAsync(RequestOptions options) { - using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + try + { + System.Console.WriteLine("Entering method GetXmlAdvancedModelAsync."); + using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetXmlAdvancedModelAsync."); + } } /// Get an advanced XML model with various property types. @@ -1792,8 +3130,21 @@ public virtual async Task GetXmlAdvancedModelAsync(RequestOptions /// Service returned a non-success status code. public virtual ClientResult GetXmlAdvancedModel(CancellationToken cancellationToken = default) { - ClientResult result = GetXmlAdvancedModel(cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetXmlAdvancedModel."); + ClientResult result = GetXmlAdvancedModel(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetXmlAdvancedModel."); + } } /// Get an advanced XML model with various property types. @@ -1801,8 +3152,21 @@ public virtual ClientResult GetXmlAdvancedModel(CancellationTo /// Service returned a non-success status code. public virtual async Task> GetXmlAdvancedModelAsync(CancellationToken cancellationToken = default) { - ClientResult result = await GetXmlAdvancedModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + try + { + System.Console.WriteLine("Entering method GetXmlAdvancedModelAsync."); + ClientResult result = await GetXmlAdvancedModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetXmlAdvancedModelAsync."); + } } /// @@ -1820,10 +3184,23 @@ public virtual async Task> GetXmlAdvancedModelAsy /// The response returned from the service. public virtual ClientResult UpdateXmlAdvancedModel(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateXmlAdvancedModel."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateXmlAdvancedModelRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + using PipelineMessage message = CreateUpdateXmlAdvancedModelRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateXmlAdvancedModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateXmlAdvancedModel."); + } } /// @@ -1841,10 +3218,23 @@ public virtual ClientResult UpdateXmlAdvancedModel(BinaryContent content, Reques /// The response returned from the service. public virtual async Task UpdateXmlAdvancedModelAsync(BinaryContent content, RequestOptions options = null) { - Argument.AssertNotNull(content, nameof(content)); + try + { + System.Console.WriteLine("Entering method UpdateXmlAdvancedModelAsync."); + Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = CreateUpdateXmlAdvancedModelRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = CreateUpdateXmlAdvancedModelRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateXmlAdvancedModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateXmlAdvancedModelAsync."); + } } /// Update an advanced XML model with various property types. @@ -1854,10 +3244,23 @@ public virtual async Task UpdateXmlAdvancedModelAsync(BinaryConten /// Service returned a non-success status code. public virtual ClientResult UpdateXmlAdvancedModel(XmlAdvancedModel body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method UpdateXmlAdvancedModel."); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = UpdateXmlAdvancedModel(body, cancellationToken.ToRequestOptions()); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + ClientResult result = UpdateXmlAdvancedModel(body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateXmlAdvancedModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateXmlAdvancedModel."); + } } /// Update an advanced XML model with various property types. @@ -1867,10 +3270,23 @@ public virtual ClientResult UpdateXmlAdvancedModel(XmlAdvanced /// Service returned a non-success status code. public virtual async Task> UpdateXmlAdvancedModelAsync(XmlAdvancedModel body, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + try + { + System.Console.WriteLine("Entering method UpdateXmlAdvancedModelAsync."); + Argument.AssertNotNull(body, nameof(body)); - ClientResult result = await UpdateXmlAdvancedModelAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); - return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + ClientResult result = await UpdateXmlAdvancedModelAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method UpdateXmlAdvancedModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method UpdateXmlAdvancedModelAsync."); + } } /// Initializes a new instance of AnimalOperations. diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientOptions.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientOptions.cs index 019e2638bf5..c62f450a18d 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientOptions.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientOptions.cs @@ -4,8 +4,6 @@ using System; using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Configuration; namespace SampleTypeSpec { @@ -26,22 +24,6 @@ public SampleTypeSpecClientOptions(ServiceVersion version = LatestVersion) }; } - /// Initializes a new instance of SampleTypeSpecClientOptions from configuration. - /// The configuration section. - [Experimental("SCME0002")] - internal SampleTypeSpecClientOptions(IConfigurationSection section) : base(section) - { - Version = "2024-08-16-preview"; - if (section is null || !section.Exists()) - { - return; - } - if (section["Version"] is string version) - { - Version = version; - } - } - /// Gets the Version. internal string Version { get; } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientSettings.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientSettings.cs deleted file mode 100644 index a1fa0ba0560..00000000000 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClientSettings.cs +++ /dev/null @@ -1,37 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Configuration; - -namespace SampleTypeSpec -{ - /// Represents the settings used to configure a that can be loaded from an . - [Experimental("SCME0002")] - public partial class SampleTypeSpecClientSettings : ClientSettings - { - /// Gets or sets the SampleTypeSpecUrl. - public Uri SampleTypeSpecUrl { get; set; } - - /// Gets or sets the Options. - public SampleTypeSpecClientOptions Options { get; set; } - - /// Binds configuration values from the given section. - /// The configuration section. - protected override void BindCore(IConfigurationSection section) - { - if (Uri.TryCreate(section["SampleTypeSpecUrl"], UriKind.Absolute, out Uri sampleTypeSpecUrl)) - { - SampleTypeSpecUrl = sampleTypeSpecUrl; - } - IConfigurationSection optionsSection = section.GetSection("Options"); - if (optionsSection.Exists()) - { - Options = new SampleTypeSpecClientOptions(optionsSection); - } - } - } -} diff --git a/docs/samples/client/csharp/SampleService/package.json b/docs/samples/client/csharp/SampleService/package.json index 97c31d59fb2..e24bc78579c 100644 --- a/docs/samples/client/csharp/SampleService/package.json +++ b/docs/samples/client/csharp/SampleService/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@typespec/http-client-csharp": "1.0.0-alpha.20260407.1", + "@typespec/http-client-csharp": "1.0.0-alpha.20260310.2", "logging-plugin": "file:../plugins/logging" } } diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index 5462350078e..e1cfdeb502c 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -31,7 +31,7 @@ if (-not $LaunchOnly) { Write-Host "Generating SampleTypeSpec using plugins" -ForegroundColor Cyan - Invoke "npx tsp compile . --trace @typespec/http-client-csharp --emit $packageRoot" $sampleDir + Invoke "npx tsp compile . --trace @typespec/http-client-csharp" $sampleDir # exit if the generation failed if ($LASTEXITCODE -ne 0) { From 91732833fd0531a696b0312b663f06c03aff9bf7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 19:20:48 +0000 Subject: [PATCH 07/16] chore: temporarily disable SampleService and Sample-TypeSpec generation in Generate.ps1 Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/247e76c9-f70d-4915-8a59-b057b95f4b6f Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../eng/scripts/Generate.ps1 | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index e1cfdeb502c..e49487c9234 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -19,53 +19,55 @@ if (-not $LaunchOnly) { if ($null -eq $filter -or $filter -eq "Sample-TypeSpec") { - Write-Host "Building logging plugin" -ForegroundColor Cyan - $pluginDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'plugins' 'logging' 'Logging.Plugin' 'src' - Invoke "dotnet build" $pluginDir + # TODO: Re-enable SampleService generation once a compatible emitter version is published + # Write-Host "Building logging plugin" -ForegroundColor Cyan + # $pluginDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'plugins' 'logging' 'Logging.Plugin' 'src' + # Invoke "dotnet build" $pluginDir - $sampleDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'SampleService' + # $sampleDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'SampleService' - Write-Host "Installing SampleTypeSpec plugins" -ForegroundColor Cyan + # Write-Host "Installing SampleTypeSpec plugins" -ForegroundColor Cyan - Invoke "npm install --no-package-lock" $sampleDir + # Invoke "npm install --no-package-lock" $sampleDir - Write-Host "Generating SampleTypeSpec using plugins" -ForegroundColor Cyan + # Write-Host "Generating SampleTypeSpec using plugins" -ForegroundColor Cyan - Invoke "npx tsp compile . --trace @typespec/http-client-csharp" $sampleDir + # Invoke "npx tsp compile . --trace @typespec/http-client-csharp" $sampleDir - # exit if the generation failed - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE - } + # # exit if the generation failed + # if ($LASTEXITCODE -ne 0) { + # exit $LASTEXITCODE + # } - Write-Host "Building SampleTypeSpec plugin library" -ForegroundColor Cyan - Invoke "dotnet build $sampleDir/SampleClient/src/SampleTypeSpec.csproj" + # Write-Host "Building SampleTypeSpec plugin library" -ForegroundColor Cyan + # Invoke "dotnet build $sampleDir/SampleClient/src/SampleTypeSpec.csproj" - # exit if the generation failed - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE - } + # # exit if the generation failed + # if ($LASTEXITCODE -ne 0) { + # exit $LASTEXITCODE + # } - Write-Host "Generating SampleTypeSpec" -ForegroundColor Cyan - $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' + # TODO: Re-enable Sample-TypeSpec generation once SampleService is re-enabled (Sample-TypeSpec imports SampleService/main.tsp) + # Write-Host "Generating SampleTypeSpec" -ForegroundColor Cyan + # $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' - $SampleTypeSpecTestProject = Join-Path $testProjectsLocalDir "Sample-TypeSpec" - $SampleTypeSpecTestProject = $SampleTypeSpecTestProject + # $SampleTypeSpecTestProject = Join-Path $testProjectsLocalDir "Sample-TypeSpec" + # $SampleTypeSpecTestProject = $SampleTypeSpecTestProject - Invoke (Get-TspCommand "$SampleTypeSpecTestProject/Sample-TypeSpec.tsp" $SampleTypeSpecTestProject) + # Invoke (Get-TspCommand "$SampleTypeSpecTestProject/Sample-TypeSpec.tsp" $SampleTypeSpecTestProject) - # exit if the generation failed - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE - } + # # exit if the generation failed + # if ($LASTEXITCODE -ne 0) { + # exit $LASTEXITCODE + # } - Write-Host "Building SampleTypeSpec" -ForegroundColor Cyan - Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Sample-TypeSpec/src/SampleTypeSpec.csproj" + # Write-Host "Building SampleTypeSpec" -ForegroundColor Cyan + # Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Sample-TypeSpec/src/SampleTypeSpec.csproj" - # exit if the generation failed - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE - } + # # exit if the generation failed + # if ($LASTEXITCODE -ne 0) { + # exit $LASTEXITCODE + # } } } From 96fa8ba85af872d810c4841d0f0f10fbbf18d8ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 19:45:12 +0000 Subject: [PATCH 08/16] fix: only comment out SampleService plugin generation, keep Sample-TypeSpec Local active Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/0a9ea8bf-a321-4c53-8932-8a50a3c287bd Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../client/csharp/SampleService/package.json | 2 +- .../eng/scripts/Generate.ps1 | 39 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/docs/samples/client/csharp/SampleService/package.json b/docs/samples/client/csharp/SampleService/package.json index e24bc78579c..3621022c3af 100644 --- a/docs/samples/client/csharp/SampleService/package.json +++ b/docs/samples/client/csharp/SampleService/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@typespec/http-client-csharp": "1.0.0-alpha.20260310.2", + "@typespec/http-client-csharp": "1.0.0-alpha.20260407.3", "logging-plugin": "file:../plugins/logging" } } diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index e49487c9234..2bc6d4b9d37 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -19,16 +19,16 @@ if (-not $LaunchOnly) { if ($null -eq $filter -or $filter -eq "Sample-TypeSpec") { - # TODO: Re-enable SampleService generation once a compatible emitter version is published + # TODO: Re-enable SampleService plugin generation once a compatible emitter version is published # Write-Host "Building logging plugin" -ForegroundColor Cyan # $pluginDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'plugins' 'logging' 'Logging.Plugin' 'src' # Invoke "dotnet build" $pluginDir - # $sampleDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'SampleService' + $sampleDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'SampleService' - # Write-Host "Installing SampleTypeSpec plugins" -ForegroundColor Cyan + Write-Host "Installing SampleTypeSpec plugins" -ForegroundColor Cyan - # Invoke "npm install --no-package-lock" $sampleDir + Invoke "npm install --no-package-lock" $sampleDir # Write-Host "Generating SampleTypeSpec using plugins" -ForegroundColor Cyan @@ -47,27 +47,26 @@ if (-not $LaunchOnly) { # exit $LASTEXITCODE # } - # TODO: Re-enable Sample-TypeSpec generation once SampleService is re-enabled (Sample-TypeSpec imports SampleService/main.tsp) - # Write-Host "Generating SampleTypeSpec" -ForegroundColor Cyan - # $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' + Write-Host "Generating SampleTypeSpec" -ForegroundColor Cyan + $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' - # $SampleTypeSpecTestProject = Join-Path $testProjectsLocalDir "Sample-TypeSpec" - # $SampleTypeSpecTestProject = $SampleTypeSpecTestProject + $SampleTypeSpecTestProject = Join-Path $testProjectsLocalDir "Sample-TypeSpec" + $SampleTypeSpecTestProject = $SampleTypeSpecTestProject - # Invoke (Get-TspCommand "$SampleTypeSpecTestProject/Sample-TypeSpec.tsp" $SampleTypeSpecTestProject) + Invoke (Get-TspCommand "$SampleTypeSpecTestProject/Sample-TypeSpec.tsp" $SampleTypeSpecTestProject) - # # exit if the generation failed - # if ($LASTEXITCODE -ne 0) { - # exit $LASTEXITCODE - # } + # exit if the generation failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } - # Write-Host "Building SampleTypeSpec" -ForegroundColor Cyan - # Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Sample-TypeSpec/src/SampleTypeSpec.csproj" + Write-Host "Building SampleTypeSpec" -ForegroundColor Cyan + Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Sample-TypeSpec/src/SampleTypeSpec.csproj" - # # exit if the generation failed - # if ($LASTEXITCODE -ne 0) { - # exit $LASTEXITCODE - # } + # exit if the generation failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } } } From fba483506dfe14e6f2902cc13942670008dd9c35 Mon Sep 17 00:00:00 2001 From: Jorge Rangel Date: Wed, 8 Apr 2026 14:52:19 -0500 Subject: [PATCH 09/16] fix generate.ps1 --- packages/http-client-csharp/eng/scripts/Generate.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index 2bc6d4b9d37..b167cb2814e 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -24,11 +24,11 @@ if (-not $LaunchOnly) { # $pluginDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'plugins' 'logging' 'Logging.Plugin' 'src' # Invoke "dotnet build" $pluginDir - $sampleDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'SampleService' + # $sampleDir = Join-Path $packageRoot '..' '..' 'docs' 'samples' 'client' 'csharp' 'SampleService' - Write-Host "Installing SampleTypeSpec plugins" -ForegroundColor Cyan + # Write-Host "Installing SampleTypeSpec plugins" -ForegroundColor Cyan - Invoke "npm install --no-package-lock" $sampleDir + # Invoke "npm install --no-package-lock" $sampleDir # Write-Host "Generating SampleTypeSpec using plugins" -ForegroundColor Cyan From a823cd9188fdd23b7b0046d0404c9c9abca554c5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 19:54:45 +0000 Subject: [PATCH 10/16] revert: restore SampleService/package.json to original state Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/bbadad93-afec-4c9f-b2b1-72245c0bc58c Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- docs/samples/client/csharp/SampleService/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/samples/client/csharp/SampleService/package.json b/docs/samples/client/csharp/SampleService/package.json index 3621022c3af..e24bc78579c 100644 --- a/docs/samples/client/csharp/SampleService/package.json +++ b/docs/samples/client/csharp/SampleService/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@typespec/http-client-csharp": "1.0.0-alpha.20260407.3", + "@typespec/http-client-csharp": "1.0.0-alpha.20260310.2", "logging-plugin": "file:../plugins/logging" } } From 287c94db445add5585a305c789c108f7fdddc57c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 20:09:17 +0000 Subject: [PATCH 11/16] chore: comment out Sample-TypeSpec generation (depends on SampleService deps), regenerate all Spector specs Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/bbadad93-afec-4c9f-b2b1-72245c0bc58c Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../eng/scripts/Generate.ps1 | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index b167cb2814e..a9fe3a2804b 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -47,26 +47,28 @@ if (-not $LaunchOnly) { # exit $LASTEXITCODE # } - Write-Host "Generating SampleTypeSpec" -ForegroundColor Cyan - $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' + # TODO: Re-enable Sample-TypeSpec generation once SampleService deps can be installed + # (Sample-TypeSpec.tsp imports SampleService/main.tsp which needs SampleService's node_modules) + # Write-Host "Generating SampleTypeSpec" -ForegroundColor Cyan + # $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' - $SampleTypeSpecTestProject = Join-Path $testProjectsLocalDir "Sample-TypeSpec" - $SampleTypeSpecTestProject = $SampleTypeSpecTestProject + # $SampleTypeSpecTestProject = Join-Path $testProjectsLocalDir "Sample-TypeSpec" + # $SampleTypeSpecTestProject = $SampleTypeSpecTestProject - Invoke (Get-TspCommand "$SampleTypeSpecTestProject/Sample-TypeSpec.tsp" $SampleTypeSpecTestProject) + # Invoke (Get-TspCommand "$SampleTypeSpecTestProject/Sample-TypeSpec.tsp" $SampleTypeSpecTestProject) - # exit if the generation failed - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE - } + # # exit if the generation failed + # if ($LASTEXITCODE -ne 0) { + # exit $LASTEXITCODE + # } - Write-Host "Building SampleTypeSpec" -ForegroundColor Cyan - Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Sample-TypeSpec/src/SampleTypeSpec.csproj" + # Write-Host "Building SampleTypeSpec" -ForegroundColor Cyan + # Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Sample-TypeSpec/src/SampleTypeSpec.csproj" - # exit if the generation failed - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE - } + # # exit if the generation failed + # if ($LASTEXITCODE -ne 0) { + # exit $LASTEXITCODE + # } } } From 9fb3cb2861f7a3c1de0a25ceba011389cd502360 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 21:21:45 +0000 Subject: [PATCH 12/16] fix: restore Generate.ps1 to match Jorge's commit fba4835 exactly Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/5de14e87-b504-4691-b57d-06a59b4a6147 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../eng/scripts/Generate.ps1 | 32 ++++--- .../Generated/Models/Bird.Serialization.cs | 39 --------- .../src/Generated/Models/Bird.cs | 28 ------- .../Models/Dinosaur.Serialization.cs | 37 --------- .../src/Generated/Models/Dinosaur.cs | 24 ------ .../Generated/Models/Eagle.Serialization.cs | 33 -------- .../src/Generated/Models/Eagle.cs | 26 ------ .../Generated/Models/Goose.Serialization.cs | 33 -------- .../src/Generated/Models/Goose.cs | 16 ---- .../Generated/Models/SeaGull.Serialization.cs | 33 -------- .../src/Generated/Models/SeaGull.cs | 16 ---- .../Generated/Models/Sparrow.Serialization.cs | 33 -------- .../src/Generated/Models/Sparrow.cs | 16 ---- .../Generated/Models/TRex.Serialization.cs | 33 -------- .../src/Generated/Models/TRex.cs | 16 ---- .../Models/UnknownBird.Serialization.cs | 33 -------- .../src/Generated/Models/UnknownBird.cs | 14 ---- .../Models/UnknownDinosaur.Serialization.cs | 33 -------- .../src/Generated/Models/UnknownDinosaur.cs | 14 ---- ...elInheritanceSingleDiscriminatorContext.cs | 21 ----- .../Generated/SingleDiscriminatorClient.cs | 83 ------------------- .../SingleDiscriminatorClientOptions.cs | 18 ---- .../SingleDiscriminatorClientSettings.cs | 29 ------- ...eritanceSingleDiscriminatorModelFactory.cs | 25 ------ 24 files changed, 15 insertions(+), 670 deletions(-) delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.Serialization.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientOptions.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientSettings.cs delete mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index a9fe3a2804b..b167cb2814e 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -47,28 +47,26 @@ if (-not $LaunchOnly) { # exit $LASTEXITCODE # } - # TODO: Re-enable Sample-TypeSpec generation once SampleService deps can be installed - # (Sample-TypeSpec.tsp imports SampleService/main.tsp which needs SampleService's node_modules) - # Write-Host "Generating SampleTypeSpec" -ForegroundColor Cyan - # $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' + Write-Host "Generating SampleTypeSpec" -ForegroundColor Cyan + $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' - # $SampleTypeSpecTestProject = Join-Path $testProjectsLocalDir "Sample-TypeSpec" - # $SampleTypeSpecTestProject = $SampleTypeSpecTestProject + $SampleTypeSpecTestProject = Join-Path $testProjectsLocalDir "Sample-TypeSpec" + $SampleTypeSpecTestProject = $SampleTypeSpecTestProject - # Invoke (Get-TspCommand "$SampleTypeSpecTestProject/Sample-TypeSpec.tsp" $SampleTypeSpecTestProject) + Invoke (Get-TspCommand "$SampleTypeSpecTestProject/Sample-TypeSpec.tsp" $SampleTypeSpecTestProject) - # # exit if the generation failed - # if ($LASTEXITCODE -ne 0) { - # exit $LASTEXITCODE - # } + # exit if the generation failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } - # Write-Host "Building SampleTypeSpec" -ForegroundColor Cyan - # Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Sample-TypeSpec/src/SampleTypeSpec.csproj" + Write-Host "Building SampleTypeSpec" -ForegroundColor Cyan + Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Sample-TypeSpec/src/SampleTypeSpec.csproj" - # # exit if the generation failed - # if ($LASTEXITCODE -ne 0) { - # exit $LASTEXITCODE - # } + # exit if the generation failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.Serialization.cs deleted file mode 100644 index 3c62ae4bc65..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.Serialization.cs +++ /dev/null @@ -1,39 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - [PersistableModelProxy(typeof(UnknownBird))] - public abstract partial class Bird : IJsonModel - { - internal Bird() => throw null; - - protected virtual Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - - Bird IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - - public static implicit operator BinaryContent(Bird bird) => throw null; - - public static explicit operator Bird(ClientResult result) => throw null; - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - Bird IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - - protected virtual Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs deleted file mode 100644 index 9c3da3c7e79..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs +++ /dev/null @@ -1,28 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public abstract partial class Bird - { - private protected Bird(string kind, int wingspan) => throw null; - - internal Bird(string kind, int wingspan, IDictionary additionalBinaryDataProperties) => throw null; - - internal string Kind - { - get => throw null; - set => throw null; - } - - public int Wingspan - { - get => throw null; - set => throw null; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.Serialization.cs deleted file mode 100644 index f843ed50fbc..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.Serialization.cs +++ /dev/null @@ -1,37 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - [PersistableModelProxy(typeof(UnknownDinosaur))] - public abstract partial class Dinosaur : IJsonModel - { - internal Dinosaur() => throw null; - - protected virtual Dinosaur PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - - protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - - Dinosaur IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - - public static explicit operator Dinosaur(ClientResult result) => throw null; - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - Dinosaur IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - - protected virtual Dinosaur JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs deleted file mode 100644 index 13c3bfa165e..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs +++ /dev/null @@ -1,24 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public abstract partial class Dinosaur - { - private protected Dinosaur(string kind, int size) => throw null; - - internal Dinosaur(string kind, int size, IDictionary additionalBinaryDataProperties) => throw null; - - internal string Kind - { - get => throw null; - set => throw null; - } - - public int Size => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.Serialization.cs deleted file mode 100644 index edfbcabed7c..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class Eagle : Bird, IJsonModel - { - internal Eagle() => throw null; - - protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - - Eagle IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - Eagle IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - - protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs deleted file mode 100644 index 157a75ac950..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs +++ /dev/null @@ -1,26 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class Eagle : Bird - { - public Eagle(int wingspan) : base("eagle", wingspan) => throw null; - - internal Eagle(string kind, int wingspan, IDictionary additionalBinaryDataProperties, IList friends, IDictionary hate, Bird partner) : base(kind, wingspan, additionalBinaryDataProperties) => throw null; - - public IList Friends => throw null; - - public IDictionary Hate => throw null; - - public Bird Partner - { - get => throw null; - set => throw null; - } - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.Serialization.cs deleted file mode 100644 index c54c1f10a78..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class Goose : Bird, IJsonModel - { - internal Goose() => throw null; - - protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - - Goose IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - Goose IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - - protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs deleted file mode 100644 index bcdae2c174c..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs +++ /dev/null @@ -1,16 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class Goose : Bird - { - public Goose(int wingspan) : base("goose", wingspan) => throw null; - - internal Goose(string kind, int wingspan, IDictionary additionalBinaryDataProperties) : base(kind, wingspan, additionalBinaryDataProperties) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.Serialization.cs deleted file mode 100644 index ac92d3697f9..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class SeaGull : Bird, IJsonModel - { - internal SeaGull() => throw null; - - protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - - SeaGull IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - SeaGull IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - - protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs deleted file mode 100644 index 05857207fc9..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs +++ /dev/null @@ -1,16 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class SeaGull : Bird - { - public SeaGull(int wingspan) : base("seagull", wingspan) => throw null; - - internal SeaGull(string kind, int wingspan, IDictionary additionalBinaryDataProperties) : base(kind, wingspan, additionalBinaryDataProperties) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.Serialization.cs deleted file mode 100644 index ff21640bf92..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class Sparrow : Bird, IJsonModel - { - internal Sparrow() => throw null; - - protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - - Sparrow IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - Sparrow IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - - protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs deleted file mode 100644 index 1e29cd2b9e8..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs +++ /dev/null @@ -1,16 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class Sparrow : Bird - { - public Sparrow(int wingspan) : base("sparrow", wingspan) => throw null; - - internal Sparrow(string kind, int wingspan, IDictionary additionalBinaryDataProperties) : base(kind, wingspan, additionalBinaryDataProperties) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.Serialization.cs deleted file mode 100644 index e7eaa25db00..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class TRex : Dinosaur, IJsonModel - { - internal TRex() => throw null; - - protected override Dinosaur PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - - TRex IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - TRex IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - - protected override Dinosaur JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs deleted file mode 100644 index c9fa8acfe68..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs +++ /dev/null @@ -1,16 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class TRex : Dinosaur - { - internal TRex(int size) : base("t-rex", size) => throw null; - - internal TRex(string kind, int size, IDictionary additionalBinaryDataProperties) : base(kind, size, additionalBinaryDataProperties) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.Serialization.cs deleted file mode 100644 index 69c3bb5be9e..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - internal partial class UnknownBird : Bird, IJsonModel - { - internal UnknownBird() => throw null; - - protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - - Bird IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - Bird IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - - protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs deleted file mode 100644 index 796bde39923..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs +++ /dev/null @@ -1,14 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - internal partial class UnknownBird : Bird - { - internal UnknownBird(string kind, int wingspan, IDictionary additionalBinaryDataProperties) : base(kind ?? "unknown", wingspan, additionalBinaryDataProperties) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.Serialization.cs deleted file mode 100644 index 492099b9aad..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.Serialization.cs +++ /dev/null @@ -1,33 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - internal partial class UnknownDinosaur : Dinosaur, IJsonModel - { - internal UnknownDinosaur() => throw null; - - protected override Dinosaur PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; - - protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; - - Dinosaur IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; - - Dinosaur IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - - protected override Dinosaur JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs deleted file mode 100644 index 3e296ce661e..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs +++ /dev/null @@ -1,14 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - internal partial class UnknownDinosaur : Dinosaur - { - internal UnknownDinosaur(string kind, int size, IDictionary additionalBinaryDataProperties) : base(kind ?? "unknown", size, additionalBinaryDataProperties) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs deleted file mode 100644 index 66003f92303..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs +++ /dev/null @@ -1,21 +0,0 @@ -// - -#nullable disable - -using System.ClientModel.Primitives; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - [ModelReaderWriterBuildable(typeof(Bird))] - [ModelReaderWriterBuildable(typeof(Dinosaur))] - [ModelReaderWriterBuildable(typeof(Eagle))] - [ModelReaderWriterBuildable(typeof(Goose))] - [ModelReaderWriterBuildable(typeof(SeaGull))] - [ModelReaderWriterBuildable(typeof(Sparrow))] - [ModelReaderWriterBuildable(typeof(TRex))] - [ModelReaderWriterBuildable(typeof(UnknownBird))] - [ModelReaderWriterBuildable(typeof(UnknownDinosaur))] - public partial class _TypeModelInheritanceSingleDiscriminatorContext : ModelReaderWriterContext - { - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs deleted file mode 100644 index d6a1a0eb170..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs +++ /dev/null @@ -1,83 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; -using System.Threading; -using System.Threading.Tasks; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class SingleDiscriminatorClient - { - public SingleDiscriminatorClient() : this(new Uri("http://localhost:3000"), new SingleDiscriminatorClientOptions()) => throw null; - - internal SingleDiscriminatorClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, SingleDiscriminatorClientOptions options) => throw null; - - public SingleDiscriminatorClient(Uri endpoint, SingleDiscriminatorClientOptions options) : this(null, endpoint, options) => throw null; - - [Experimental("SCME0002")] - public SingleDiscriminatorClient(SingleDiscriminatorClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Endpoint, settings?.Options) => throw null; - - public ClientPipeline Pipeline => throw null; - - public virtual ClientResult GetModel(RequestOptions options) => throw null; - - public virtual Task GetModelAsync(RequestOptions options) => throw null; - - public virtual ClientResult GetModel(CancellationToken cancellationToken = default) => throw null; - - public virtual Task> GetModelAsync(CancellationToken cancellationToken = default) => throw null; - - public virtual ClientResult PutModel(BinaryContent content, RequestOptions options = null) => throw null; - - public virtual Task PutModelAsync(BinaryContent content, RequestOptions options = null) => throw null; - - public virtual ClientResult PutModel(Bird input, CancellationToken cancellationToken = default) => throw null; - - public virtual Task PutModelAsync(Bird input, CancellationToken cancellationToken = default) => throw null; - - public virtual ClientResult GetRecursiveModel(RequestOptions options) => throw null; - - public virtual Task GetRecursiveModelAsync(RequestOptions options) => throw null; - - public virtual ClientResult GetRecursiveModel(CancellationToken cancellationToken = default) => throw null; - - public virtual Task> GetRecursiveModelAsync(CancellationToken cancellationToken = default) => throw null; - - public virtual ClientResult PutRecursiveModel(BinaryContent content, RequestOptions options = null) => throw null; - - public virtual Task PutRecursiveModelAsync(BinaryContent content, RequestOptions options = null) => throw null; - - public virtual ClientResult PutRecursiveModel(Bird input, CancellationToken cancellationToken = default) => throw null; - - public virtual Task PutRecursiveModelAsync(Bird input, CancellationToken cancellationToken = default) => throw null; - - public virtual ClientResult GetMissingDiscriminator(RequestOptions options) => throw null; - - public virtual Task GetMissingDiscriminatorAsync(RequestOptions options) => throw null; - - public virtual ClientResult GetMissingDiscriminator(CancellationToken cancellationToken = default) => throw null; - - public virtual Task> GetMissingDiscriminatorAsync(CancellationToken cancellationToken = default) => throw null; - - public virtual ClientResult GetWrongDiscriminator(RequestOptions options) => throw null; - - public virtual Task GetWrongDiscriminatorAsync(RequestOptions options) => throw null; - - public virtual ClientResult GetWrongDiscriminator(CancellationToken cancellationToken = default) => throw null; - - public virtual Task> GetWrongDiscriminatorAsync(CancellationToken cancellationToken = default) => throw null; - - public virtual ClientResult GetLegacyModel(RequestOptions options) => throw null; - - public virtual Task GetLegacyModelAsync(RequestOptions options) => throw null; - - public virtual ClientResult GetLegacyModel(CancellationToken cancellationToken = default) => throw null; - - public virtual Task> GetLegacyModelAsync(CancellationToken cancellationToken = default) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientOptions.cs deleted file mode 100644 index 2b4f31e4023..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -// - -#nullable disable - -using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Configuration; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public partial class SingleDiscriminatorClientOptions : ClientPipelineOptions - { - public SingleDiscriminatorClientOptions() => throw null; - - [Experimental("SCME0002")] - internal SingleDiscriminatorClientOptions(IConfigurationSection section) : base(section) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientSettings.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientSettings.cs deleted file mode 100644 index ab187bd8d92..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientSettings.cs +++ /dev/null @@ -1,29 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Configuration; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - [Experimental("SCME0002")] - public partial class SingleDiscriminatorClientSettings : ClientSettings - { - public Uri Endpoint - { - get => throw null; - set => throw null; - } - - public SingleDiscriminatorClientOptions Options - { - get => throw null; - set => throw null; - } - - protected override void BindCore(IConfigurationSection section) => throw null; - } -} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs deleted file mode 100644 index a76389a6425..00000000000 --- a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs +++ /dev/null @@ -1,25 +0,0 @@ -// - -#nullable disable - -using System.Collections.Generic; - -namespace _Type.Model.Inheritance.SingleDiscriminator -{ - public static partial class TypeModelInheritanceSingleDiscriminatorModelFactory - { - public static Bird Bird(string kind = default, int wingspan = default) => throw null; - - public static SeaGull SeaGull(int wingspan = default) => throw null; - - public static Sparrow Sparrow(int wingspan = default) => throw null; - - public static Goose Goose(int wingspan = default) => throw null; - - public static Eagle Eagle(int wingspan = default, IEnumerable friends = default, IDictionary hate = default, Bird partner = default) => throw null; - - public static Dinosaur Dinosaur(string kind = default, int size = default) => throw null; - - public static TRex TRex(int size = default) => throw null; - } -} From 60c655a02707ec78b4f7722978816908f7304143 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 21:23:33 +0000 Subject: [PATCH 13/16] fix: restore single-discriminator generated files accidentally deleted by concurrent Test-Spector run Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/5de14e87-b504-4691-b57d-06a59b4a6147 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- .../Generated/Models/Bird.Serialization.cs | 39 +++++++++ .../src/Generated/Models/Bird.cs | 28 +++++++ .../Models/Dinosaur.Serialization.cs | 37 +++++++++ .../src/Generated/Models/Dinosaur.cs | 24 ++++++ .../Generated/Models/Eagle.Serialization.cs | 33 ++++++++ .../src/Generated/Models/Eagle.cs | 26 ++++++ .../Generated/Models/Goose.Serialization.cs | 33 ++++++++ .../src/Generated/Models/Goose.cs | 16 ++++ .../Generated/Models/SeaGull.Serialization.cs | 33 ++++++++ .../src/Generated/Models/SeaGull.cs | 16 ++++ .../Generated/Models/Sparrow.Serialization.cs | 33 ++++++++ .../src/Generated/Models/Sparrow.cs | 16 ++++ .../Generated/Models/TRex.Serialization.cs | 33 ++++++++ .../src/Generated/Models/TRex.cs | 16 ++++ .../Models/UnknownBird.Serialization.cs | 33 ++++++++ .../src/Generated/Models/UnknownBird.cs | 14 ++++ .../Models/UnknownDinosaur.Serialization.cs | 33 ++++++++ .../src/Generated/Models/UnknownDinosaur.cs | 14 ++++ ...elInheritanceSingleDiscriminatorContext.cs | 21 +++++ .../Generated/SingleDiscriminatorClient.cs | 83 +++++++++++++++++++ .../SingleDiscriminatorClientOptions.cs | 18 ++++ .../SingleDiscriminatorClientSettings.cs | 29 +++++++ ...eritanceSingleDiscriminatorModelFactory.cs | 25 ++++++ 23 files changed, 653 insertions(+) create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.Serialization.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientSettings.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.Serialization.cs new file mode 100644 index 00000000000..3c62ae4bc65 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.Serialization.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + [PersistableModelProxy(typeof(UnknownBird))] + public abstract partial class Bird : IJsonModel + { + internal Bird() => throw null; + + protected virtual Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Bird IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static implicit operator BinaryContent(Bird bird) => throw null; + + public static explicit operator Bird(ClientResult result) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Bird IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs new file mode 100644 index 00000000000..9c3da3c7e79 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Bird.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public abstract partial class Bird + { + private protected Bird(string kind, int wingspan) => throw null; + + internal Bird(string kind, int wingspan, IDictionary additionalBinaryDataProperties) => throw null; + + internal string Kind + { + get => throw null; + set => throw null; + } + + public int Wingspan + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.Serialization.cs new file mode 100644 index 00000000000..f843ed50fbc --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.Serialization.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + [PersistableModelProxy(typeof(UnknownDinosaur))] + public abstract partial class Dinosaur : IJsonModel + { + internal Dinosaur() => throw null; + + protected virtual Dinosaur PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Dinosaur IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + public static explicit operator Dinosaur(ClientResult result) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Dinosaur IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected virtual Dinosaur JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs new file mode 100644 index 00000000000..13c3bfa165e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Dinosaur.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public abstract partial class Dinosaur + { + private protected Dinosaur(string kind, int size) => throw null; + + internal Dinosaur(string kind, int size, IDictionary additionalBinaryDataProperties) => throw null; + + internal string Kind + { + get => throw null; + set => throw null; + } + + public int Size => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.Serialization.cs new file mode 100644 index 00000000000..edfbcabed7c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class Eagle : Bird, IJsonModel + { + internal Eagle() => throw null; + + protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Eagle IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Eagle IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs new file mode 100644 index 00000000000..157a75ac950 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Eagle.cs @@ -0,0 +1,26 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class Eagle : Bird + { + public Eagle(int wingspan) : base("eagle", wingspan) => throw null; + + internal Eagle(string kind, int wingspan, IDictionary additionalBinaryDataProperties, IList friends, IDictionary hate, Bird partner) : base(kind, wingspan, additionalBinaryDataProperties) => throw null; + + public IList Friends => throw null; + + public IDictionary Hate => throw null; + + public Bird Partner + { + get => throw null; + set => throw null; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.Serialization.cs new file mode 100644 index 00000000000..c54c1f10a78 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class Goose : Bird, IJsonModel + { + internal Goose() => throw null; + + protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Goose IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Goose IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs new file mode 100644 index 00000000000..bcdae2c174c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Goose.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class Goose : Bird + { + public Goose(int wingspan) : base("goose", wingspan) => throw null; + + internal Goose(string kind, int wingspan, IDictionary additionalBinaryDataProperties) : base(kind, wingspan, additionalBinaryDataProperties) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.Serialization.cs new file mode 100644 index 00000000000..ac92d3697f9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class SeaGull : Bird, IJsonModel + { + internal SeaGull() => throw null; + + protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + SeaGull IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + SeaGull IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs new file mode 100644 index 00000000000..05857207fc9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/SeaGull.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class SeaGull : Bird + { + public SeaGull(int wingspan) : base("seagull", wingspan) => throw null; + + internal SeaGull(string kind, int wingspan, IDictionary additionalBinaryDataProperties) : base(kind, wingspan, additionalBinaryDataProperties) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.Serialization.cs new file mode 100644 index 00000000000..ff21640bf92 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class Sparrow : Bird, IJsonModel + { + internal Sparrow() => throw null; + + protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Sparrow IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Sparrow IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs new file mode 100644 index 00000000000..1e29cd2b9e8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/Sparrow.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class Sparrow : Bird + { + public Sparrow(int wingspan) : base("sparrow", wingspan) => throw null; + + internal Sparrow(string kind, int wingspan, IDictionary additionalBinaryDataProperties) : base(kind, wingspan, additionalBinaryDataProperties) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.Serialization.cs new file mode 100644 index 00000000000..e7eaa25db00 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class TRex : Dinosaur, IJsonModel + { + internal TRex() => throw null; + + protected override Dinosaur PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + TRex IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + TRex IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected override Dinosaur JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs new file mode 100644 index 00000000000..c9fa8acfe68 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/TRex.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class TRex : Dinosaur + { + internal TRex(int size) : base("t-rex", size) => throw null; + + internal TRex(string kind, int size, IDictionary additionalBinaryDataProperties) : base(kind, size, additionalBinaryDataProperties) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.Serialization.cs new file mode 100644 index 00000000000..69c3bb5be9e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + internal partial class UnknownBird : Bird, IJsonModel + { + internal UnknownBird() => throw null; + + protected override Bird PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Bird IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Bird IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected override Bird JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs new file mode 100644 index 00000000000..796bde39923 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownBird.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + internal partial class UnknownBird : Bird + { + internal UnknownBird(string kind, int wingspan, IDictionary additionalBinaryDataProperties) : base(kind ?? "unknown", wingspan, additionalBinaryDataProperties) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.Serialization.cs new file mode 100644 index 00000000000..492099b9aad --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + internal partial class UnknownDinosaur : Dinosaur, IJsonModel + { + internal UnknownDinosaur() => throw null; + + protected override Dinosaur PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; + + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null; + + Dinosaur IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; + + Dinosaur IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + + protected override Dinosaur JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs new file mode 100644 index 00000000000..3e296ce661e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/UnknownDinosaur.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + internal partial class UnknownDinosaur : Dinosaur + { + internal UnknownDinosaur(string kind, int size, IDictionary additionalBinaryDataProperties) : base(kind ?? "unknown", size, additionalBinaryDataProperties) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs new file mode 100644 index 00000000000..66003f92303 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/Models/_TypeModelInheritanceSingleDiscriminatorContext.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + [ModelReaderWriterBuildable(typeof(Bird))] + [ModelReaderWriterBuildable(typeof(Dinosaur))] + [ModelReaderWriterBuildable(typeof(Eagle))] + [ModelReaderWriterBuildable(typeof(Goose))] + [ModelReaderWriterBuildable(typeof(SeaGull))] + [ModelReaderWriterBuildable(typeof(Sparrow))] + [ModelReaderWriterBuildable(typeof(TRex))] + [ModelReaderWriterBuildable(typeof(UnknownBird))] + [ModelReaderWriterBuildable(typeof(UnknownDinosaur))] + public partial class _TypeModelInheritanceSingleDiscriminatorContext : ModelReaderWriterContext + { + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs new file mode 100644 index 00000000000..d6a1a0eb170 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClient.cs @@ -0,0 +1,83 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using System.Threading; +using System.Threading.Tasks; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class SingleDiscriminatorClient + { + public SingleDiscriminatorClient() : this(new Uri("http://localhost:3000"), new SingleDiscriminatorClientOptions()) => throw null; + + internal SingleDiscriminatorClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, SingleDiscriminatorClientOptions options) => throw null; + + public SingleDiscriminatorClient(Uri endpoint, SingleDiscriminatorClientOptions options) : this(null, endpoint, options) => throw null; + + [Experimental("SCME0002")] + public SingleDiscriminatorClient(SingleDiscriminatorClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Endpoint, settings?.Options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult GetModel(RequestOptions options) => throw null; + + public virtual Task GetModelAsync(RequestOptions options) => throw null; + + public virtual ClientResult GetModel(CancellationToken cancellationToken = default) => throw null; + + public virtual Task> GetModelAsync(CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult PutModel(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task PutModelAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult PutModel(Bird input, CancellationToken cancellationToken = default) => throw null; + + public virtual Task PutModelAsync(Bird input, CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult GetRecursiveModel(RequestOptions options) => throw null; + + public virtual Task GetRecursiveModelAsync(RequestOptions options) => throw null; + + public virtual ClientResult GetRecursiveModel(CancellationToken cancellationToken = default) => throw null; + + public virtual Task> GetRecursiveModelAsync(CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult PutRecursiveModel(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual Task PutRecursiveModelAsync(BinaryContent content, RequestOptions options = null) => throw null; + + public virtual ClientResult PutRecursiveModel(Bird input, CancellationToken cancellationToken = default) => throw null; + + public virtual Task PutRecursiveModelAsync(Bird input, CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult GetMissingDiscriminator(RequestOptions options) => throw null; + + public virtual Task GetMissingDiscriminatorAsync(RequestOptions options) => throw null; + + public virtual ClientResult GetMissingDiscriminator(CancellationToken cancellationToken = default) => throw null; + + public virtual Task> GetMissingDiscriminatorAsync(CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult GetWrongDiscriminator(RequestOptions options) => throw null; + + public virtual Task GetWrongDiscriminatorAsync(RequestOptions options) => throw null; + + public virtual ClientResult GetWrongDiscriminator(CancellationToken cancellationToken = default) => throw null; + + public virtual Task> GetWrongDiscriminatorAsync(CancellationToken cancellationToken = default) => throw null; + + public virtual ClientResult GetLegacyModel(RequestOptions options) => throw null; + + public virtual Task GetLegacyModelAsync(RequestOptions options) => throw null; + + public virtual ClientResult GetLegacyModel(CancellationToken cancellationToken = default) => throw null; + + public virtual Task> GetLegacyModelAsync(CancellationToken cancellationToken = default) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientOptions.cs new file mode 100644 index 00000000000..2b4f31e4023 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientOptions.cs @@ -0,0 +1,18 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Configuration; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public partial class SingleDiscriminatorClientOptions : ClientPipelineOptions + { + public SingleDiscriminatorClientOptions() => throw null; + + [Experimental("SCME0002")] + internal SingleDiscriminatorClientOptions(IConfigurationSection section) : base(section) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientSettings.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientSettings.cs new file mode 100644 index 00000000000..ab187bd8d92 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/SingleDiscriminatorClientSettings.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Configuration; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + [Experimental("SCME0002")] + public partial class SingleDiscriminatorClientSettings : ClientSettings + { + public Uri Endpoint + { + get => throw null; + set => throw null; + } + + public SingleDiscriminatorClientOptions Options + { + get => throw null; + set => throw null; + } + + protected override void BindCore(IConfigurationSection section) => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs new file mode 100644 index 00000000000..a76389a6425 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/type/model/inheritance/single-discriminator/src/Generated/TypeModelInheritanceSingleDiscriminatorModelFactory.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System.Collections.Generic; + +namespace _Type.Model.Inheritance.SingleDiscriminator +{ + public static partial class TypeModelInheritanceSingleDiscriminatorModelFactory + { + public static Bird Bird(string kind = default, int wingspan = default) => throw null; + + public static SeaGull SeaGull(int wingspan = default) => throw null; + + public static Sparrow Sparrow(int wingspan = default) => throw null; + + public static Goose Goose(int wingspan = default) => throw null; + + public static Eagle Eagle(int wingspan = default, IEnumerable friends = default, IDictionary hate = default, Bird partner = default) => throw null; + + public static Dinosaur Dinosaur(string kind = default, int size = default) => throw null; + + public static TRex TRex(int size = default) => throw null; + } +} From ee6de3375ec9e8e7e8adcdf35d5b73cfecd76d9e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 22:36:30 +0000 Subject: [PATCH 14/16] fix: downgrade fast-xml-parser to 5.5.10 in package-lock.json Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/a645f4e2-c224-4061-a8a9-41b7462d3ce4 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com> --- packages/http-client-csharp/package-lock.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/http-client-csharp/package-lock.json b/packages/http-client-csharp/package-lock.json index c6578f0a3c9..2fd76aa25cf 100644 --- a/packages/http-client-csharp/package-lock.json +++ b/packages/http-client-csharp/package-lock.json @@ -3894,9 +3894,9 @@ } }, "node_modules/fast-xml-parser": { - "version": "5.5.11", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.5.11.tgz", - "integrity": "sha512-QL0eb0YbSTVWF6tTf1+LEMSgtCEjBYPpnAjoLC8SscESlAjXEIRJ7cHtLG0pLeDFaZLa4VKZLArtA/60ZS7vyA==", + "version": "5.5.10", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.5.10.tgz", + "integrity": "sha512-go2J2xODMc32hT+4Xr/bBGXMaIoiCwrwp2mMtAvKyvEFW6S/v5Gn2pBmE4nvbwNjGhpcAiOwEv7R6/GZ6XRa9w==", "dev": true, "funding": [ { @@ -3907,8 +3907,8 @@ "license": "MIT", "dependencies": { "fast-xml-builder": "^1.1.4", - "path-expression-matcher": "^1.4.0", - "strnum": "^2.2.3" + "path-expression-matcher": "^1.2.1", + "strnum": "^2.2.2" }, "bin": { "fxparser": "src/cli/cli.js" From 3af966d42198909164930bc3e26a9302b7c31310 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 03:10:56 +0000 Subject: [PATCH 15/16] chore: bump TCGC from 0.67.0 to 0.67.1 Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/ecdb15eb-9720-44ee-af9d-ea506ec886f3 Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> --- packages/http-client-csharp/package-lock.json | 8 ++++---- packages/http-client-csharp/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/http-client-csharp/package-lock.json b/packages/http-client-csharp/package-lock.json index 2fd76aa25cf..c3f460d3845 100644 --- a/packages/http-client-csharp/package-lock.json +++ b/packages/http-client-csharp/package-lock.json @@ -11,7 +11,7 @@ "devDependencies": { "@azure-tools/azure-http-specs": "0.1.0-alpha.39", "@azure-tools/typespec-azure-core": "0.67.0", - "@azure-tools/typespec-client-generator-core": "0.67.0", + "@azure-tools/typespec-client-generator-core": "0.67.1", "@microsoft/api-extractor": "^7.52.2", "@types/node": "~22.12.0", "@typespec/compiler": "1.11.0", @@ -134,9 +134,9 @@ } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.67.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.67.0.tgz", - "integrity": "sha512-cJZHRDnSSNhx8DpHudUMDpajpDQD3+lsAXI633dsQYIKdTuP10UEgRUgIKSkF0+ck0kJOeI25r/TBH2P+V/k6Q==", + "version": "0.67.1", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.67.1.tgz", + "integrity": "sha512-Bh7M1KSrgBOMeueK+YiJiaZ+uo3119mNIcbHgU8006CSToDHSTeIM7rndUmCSn+leAKonpXhQ6eElOWj0teBWA==", "dev": true, "license": "MIT", "dependencies": { diff --git a/packages/http-client-csharp/package.json b/packages/http-client-csharp/package.json index f85e6cde0a9..4ff9d2d8bf4 100644 --- a/packages/http-client-csharp/package.json +++ b/packages/http-client-csharp/package.json @@ -64,7 +64,7 @@ "devDependencies": { "@azure-tools/azure-http-specs": "0.1.0-alpha.39", "@azure-tools/typespec-azure-core": "0.67.0", - "@azure-tools/typespec-client-generator-core": "0.67.0", + "@azure-tools/typespec-client-generator-core": "0.67.1", "@microsoft/api-extractor": "^7.52.2", "@types/node": "~22.12.0", "@typespec/compiler": "1.11.0", From 5730a200b986d271dd5d99ad0654842f367012e6 Mon Sep 17 00:00:00 2001 From: Jorge Rangel Date: Thu, 9 Apr 2026 10:08:45 -0500 Subject: [PATCH 16/16] fix deps --- packages/http-client-csharp/package-lock.json | 84 +++++-------------- packages/http-client-csharp/package.json | 5 +- 2 files changed, 25 insertions(+), 64 deletions(-) diff --git a/packages/http-client-csharp/package-lock.json b/packages/http-client-csharp/package-lock.json index c3f460d3845..1ffd108419d 100644 --- a/packages/http-client-csharp/package-lock.json +++ b/packages/http-client-csharp/package-lock.json @@ -8,6 +8,9 @@ "name": "@typespec/http-client-csharp", "version": "1.0.0", "license": "MIT", + "dependencies": { + "@azure/identity": "^4.13.0" + }, "devDependencies": { "@azure-tools/azure-http-specs": "0.1.0-alpha.39", "@azure-tools/typespec-azure-core": "0.67.0", @@ -35,7 +38,7 @@ "vitest": "^3.0.5" }, "peerDependencies": { - "@azure-tools/typespec-client-generator-core": ">=0.67.0 <0.68.0 || ~0.68.0-0", + "@azure-tools/typespec-client-generator-core": ">=0.67.1 <0.68.0 || ~0.68.0-0", "@typespec/compiler": "^1.11.0", "@typespec/http": "^1.11.0", "@typespec/openapi": "^1.11.0", @@ -164,7 +167,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", - "dev": true, "license": "MIT", "dependencies": { "tslib": "^2.6.2" @@ -177,7 +179,6 @@ "version": "1.10.1", "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.10.1.tgz", "integrity": "sha512-ykRMW8PjVAn+RS6ww5cmK9U2CyH9p4Q88YJwvUslfuMmN98w/2rdGRLPqJYObapBCdzBVeDgYWdJnFPFb7qzpg==", - "dev": true, "license": "MIT", "dependencies": { "@azure/abort-controller": "^2.1.2", @@ -192,7 +193,6 @@ "version": "1.10.1", "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.10.1.tgz", "integrity": "sha512-Nh5PhEOeY6PrnxNPsEHRr9eimxLwgLlpmguQaHKBinFYA/RU9+kOYVOQqOrTsCL+KSxrLLl1gD8Dk5BFW/7l/w==", - "dev": true, "license": "MIT", "dependencies": { "@azure/abort-controller": "^2.1.2", @@ -257,7 +257,6 @@ "version": "1.23.0", "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.23.0.tgz", "integrity": "sha512-Evs1INHo+jUjwHi1T6SG6Ua/LHOQBCLuKEEE6efIpt4ZOoNonaT1kP32GoOcdNDbfqsD2445CPri3MubBy5DEQ==", - "dev": true, "license": "MIT", "dependencies": { "@azure/abort-controller": "^2.1.2", @@ -276,7 +275,6 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.3.1.tgz", "integrity": "sha512-9MWKevR7Hz8kNzzPLfX4EAtGM2b8mr50HPDBvio96bURP/9C+HjdH3sBlLSNNrvRAr5/k/svoH457gB5IKpmwQ==", - "dev": true, "license": "MIT", "dependencies": { "tslib": "^2.6.2" @@ -289,7 +287,6 @@ "version": "1.13.1", "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.13.1.tgz", "integrity": "sha512-XPArKLzsvl0Hf0CaGyKHUyVgF7oDnhKoP85Xv6M4StF/1AhfORhZudHtOyf2s+FcbuQ9dPRAjB8J2KvRRMUK2A==", - "dev": true, "license": "MIT", "dependencies": { "@azure/abort-controller": "^2.1.2", @@ -315,10 +312,9 @@ } }, "node_modules/@azure/identity": { - "version": "4.13.1", - "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.13.1.tgz", - "integrity": "sha512-5C/2WD5Vb1lHnZS16dNQRPMjN6oV/Upba+C9nBIs15PmOi6A3ZGs4Lr2u60zw4S04gi+u3cEXiqTVP7M4Pz3kw==", - "dev": true, + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.13.0.tgz", + "integrity": "sha512-uWC0fssc+hs1TGGVkkghiaFkkS7NkTxfnCH+Hdg+yTehTpMcehpok4PgUKKdyCH+9ldu6FhiHRv84Ntqj1vVcw==", "license": "MIT", "dependencies": { "@azure/abort-controller": "^2.0.0", @@ -328,8 +324,8 @@ "@azure/core-tracing": "^1.0.0", "@azure/core-util": "^1.11.0", "@azure/logger": "^1.0.0", - "@azure/msal-browser": "^5.5.0", - "@azure/msal-node": "^5.1.0", + "@azure/msal-browser": "^4.2.0", + "@azure/msal-node": "^3.5.0", "open": "^10.1.0", "tslib": "^2.2.0" }, @@ -341,7 +337,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.3.0.tgz", "integrity": "sha512-fCqPIfOcLE+CGqGPd66c8bZpwAji98tZ4JI9i/mlTNTlsIWslCfpg48s/ypyLxZTump5sypjrKn2/kY7q8oAbA==", - "dev": true, "license": "MIT", "dependencies": { "@typespec/ts-http-runtime": "^0.3.0", @@ -352,41 +347,38 @@ } }, "node_modules/@azure/msal-browser": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-5.6.3.tgz", - "integrity": "sha512-sTjMtUm+bJpENU/1WlRzHEsgEHppZDZ1EtNyaOODg/sQBtMxxJzGB+MOCM+T2Q5Qe1fKBrdxUmjyRxm0r7Ez9w==", - "dev": true, + "version": "4.30.0", + "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-4.30.0.tgz", + "integrity": "sha512-HBBKfbZkMVzzF5bofvS1cXuNHFVc+gt4/HOnCmG/0hsHuZRJvJvDg/+7nTwIpoqvJc8BQp5o23rBUfisOLxR+w==", "license": "MIT", "dependencies": { - "@azure/msal-common": "16.4.1" + "@azure/msal-common": "15.17.0" }, "engines": { "node": ">=0.8.0" } }, "node_modules/@azure/msal-common": { - "version": "16.4.1", - "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-16.4.1.tgz", - "integrity": "sha512-Bl8f+w37xkXsYh7QRkAKCFGYtWMYuOVO7Lv+BxILrvGz3HbIEF22Pt0ugyj0QPOl6NLrHcnNUQ9yeew98P/5iw==", - "dev": true, + "version": "15.17.0", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-15.17.0.tgz", + "integrity": "sha512-VQ5/gTLFADkwue+FohVuCqlzFPUq4xSrX8jeZe+iwZuY6moliNC8xt86qPVNYdtbQfELDf2Nu6LI+demFPHGgw==", "license": "MIT", "engines": { "node": ">=0.8.0" } }, "node_modules/@azure/msal-node": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-5.1.2.tgz", - "integrity": "sha512-DoeSJ9U5KPAIZoHsPywvfEj2MhBniQe0+FSpjLUTdWoIkI999GB5USkW6nNEHnIaLVxROHXvprWA1KzdS1VQ4A==", - "dev": true, + "version": "3.8.10", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-3.8.10.tgz", + "integrity": "sha512-0Hz7Kx4hs70KZWep/Rd7aw/qOLUF92wUOhn7ZsOuB5xNR/06NL1E2RAI9+UKH1FtvN8nD6mFjH7UKSjv6vOWvQ==", "license": "MIT", "dependencies": { - "@azure/msal-common": "16.4.1", + "@azure/msal-common": "15.17.0", "jsonwebtoken": "^9.0.0", "uuid": "^8.3.0" }, "engines": { - "node": ">=20" + "node": ">=16" } }, "node_modules/@azure/storage-blob": { @@ -2393,7 +2385,6 @@ "version": "0.3.4", "resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.4.tgz", "integrity": "sha512-CI0NhTrz4EBaa0U+HaaUZrJhPoso8sG7ZFya8uQoBA57fjzrjRSv87ekCjLZOFExN+gXE/z0xuN2QfH4H2HrLQ==", - "dev": true, "license": "MIT", "dependencies": { "http-proxy-agent": "^7.0.0", @@ -2665,7 +2656,6 @@ "version": "7.1.4", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", - "dev": true, "license": "MIT", "engines": { "node": ">= 14" @@ -2902,7 +2892,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", - "dev": true, "license": "BSD-3-Clause" }, "node_modules/buffer-from": { @@ -2916,7 +2905,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==", - "dev": true, "license": "MIT", "dependencies": { "run-applescript": "^7.0.0" @@ -3364,7 +3352,6 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -3425,7 +3412,6 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.5.0.tgz", "integrity": "sha512-H9LMLr5zwIbSxrmvikGuI/5KGhZ8E2zH3stkMgM5LpOWDutGM2JZaj460Udnf1a+946zc7YBgrqEWwbk7zHvGw==", - "dev": true, "license": "MIT", "dependencies": { "bundle-name": "^4.1.0", @@ -3442,7 +3428,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz", "integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -3473,7 +3458,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -3546,7 +3530,6 @@ "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", - "dev": true, "license": "Apache-2.0", "dependencies": { "safe-buffer": "^5.0.1" @@ -4344,7 +4327,6 @@ "version": "7.0.2", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", - "dev": true, "license": "MIT", "dependencies": { "agent-base": "^7.1.0", @@ -4358,7 +4340,6 @@ "version": "7.0.6", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", - "dev": true, "license": "MIT", "dependencies": { "agent-base": "^7.1.2", @@ -4555,7 +4536,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", - "dev": true, "license": "MIT", "bin": { "is-docker": "cli.js" @@ -4604,7 +4584,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", - "dev": true, "license": "MIT", "dependencies": { "is-docker": "^3.0.0" @@ -4822,7 +4801,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz", "integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==", - "dev": true, "license": "MIT", "dependencies": { "is-inside-container": "^1.0.0" @@ -4969,7 +4947,6 @@ "version": "9.0.3", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", - "dev": true, "license": "MIT", "dependencies": { "jws": "^4.0.1", @@ -4992,7 +4969,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", - "dev": true, "license": "MIT", "dependencies": { "buffer-equal-constant-time": "^1.0.1", @@ -5004,7 +4980,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", - "dev": true, "license": "MIT", "dependencies": { "jwa": "^2.0.1", @@ -5048,49 +5023,42 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", - "dev": true, "license": "MIT" }, "node_modules/lodash.isboolean": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", - "dev": true, "license": "MIT" }, "node_modules/lodash.isinteger": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", - "dev": true, "license": "MIT" }, "node_modules/lodash.isnumber": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", - "dev": true, "license": "MIT" }, "node_modules/lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", - "dev": true, "license": "MIT" }, "node_modules/lodash.isstring": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", - "dev": true, "license": "MIT" }, "node_modules/lodash.once": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", - "dev": true, "license": "MIT" }, "node_modules/loupe": { @@ -5394,7 +5362,6 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, "license": "MIT" }, "node_modules/multer": { @@ -5611,7 +5578,6 @@ "version": "10.2.0", "resolved": "https://registry.npmjs.org/open/-/open-10.2.0.tgz", "integrity": "sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==", - "dev": true, "license": "MIT", "dependencies": { "default-browser": "^5.2.1", @@ -6109,7 +6075,6 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz", "integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -6146,7 +6111,6 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, "funding": [ { "type": "github", @@ -6202,7 +6166,6 @@ "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" @@ -6218,7 +6181,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "license": "ISC", "dependencies": { "yallist": "^4.0.0" @@ -6231,7 +6193,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true, "license": "ISC" }, "node_modules/send": { @@ -7053,7 +7014,6 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, "license": "0BSD" }, "node_modules/type-is": { @@ -7203,7 +7163,6 @@ "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, "license": "MIT", "bin": { "uuid": "dist/bin/uuid" @@ -7709,7 +7668,6 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-0.1.0.tgz", "integrity": "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==", - "dev": true, "license": "MIT", "dependencies": { "is-wsl": "^3.1.0" diff --git a/packages/http-client-csharp/package.json b/packages/http-client-csharp/package.json index 4ff9d2d8bf4..2d02f7cfdb8 100644 --- a/packages/http-client-csharp/package.json +++ b/packages/http-client-csharp/package.json @@ -52,7 +52,7 @@ "emitter/lib/*.tsp" ], "peerDependencies": { - "@azure-tools/typespec-client-generator-core": ">=0.67.0 <0.68.0 || ~0.68.0-0", + "@azure-tools/typespec-client-generator-core": ">=0.67.1 <0.68.0 || ~0.68.0-0", "@typespec/compiler": "^1.11.0", "@typespec/http": "^1.11.0", "@typespec/openapi": "^1.11.0", @@ -86,5 +86,8 @@ "rimraf": "~6.0.1", "typescript": "~5.8.2", "vitest": "^3.0.5" + }, + "dependencies": { + "@azure/identity": "^4.13.0" } }