diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props
index b146da432249..844cff89e794 100644
--- a/eng/Packages.Data.props
+++ b/eng/Packages.Data.props
@@ -458,6 +458,6 @@
1.0.0-dev.20250805.1
1.0.0-alpha.20250813.2
- 1.0.0-alpha.20250729.4
+ 1.0.0-alpha.20250812.2
diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Azure.Generator.Management.csproj b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Azure.Generator.Management.csproj
index 5a64851e3b5c..0b27c3fd6b5f 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Azure.Generator.Management.csproj
+++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Azure.Generator.Management.csproj
@@ -12,12 +12,6 @@
-
-
-
-
-
-
diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Visitors/PaginationVisitor.cs b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Visitors/PaginationVisitor.cs
index 2fa6d3611ddf..c442374f1d2b 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Visitors/PaginationVisitor.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Visitors/PaginationVisitor.cs
@@ -6,6 +6,7 @@
using Microsoft.TypeSpec.Generator.Providers;
using Microsoft.TypeSpec.Generator.Statements;
using System;
+using System.Collections.Generic;
using System.Linq;
using static Microsoft.TypeSpec.Generator.Snippets.Snippet;
@@ -37,25 +38,54 @@ internal class PaginationVisitor : ScmLibraryVisitor
}
private static bool IsAsPagesMethod(MethodProvider method) => method.Signature.Name.Equals("AsPages");
- private static bool IsGetNextResponseMethod(MethodProvider method) => method.Signature.Name.Equals("GetNextResponse");
+ private static bool IsGetNextResponseMethod(MethodProvider method)
+ => method.Signature.Name.Equals("GetNextResponseAsync") || method.Signature.Name.Equals("GetNextResponse");
private void DoVisitAsPagesMethodStatements(MethodBodyStatements statements, MethodProvider method)
{
- var doWhileStatement = statements.OfType().FirstOrDefault();
- if (doWhileStatement is not null)
+ var whileStatement = statements.OfType().FirstOrDefault();
+ if (whileStatement is not null)
{
// we manually go over the body statements because currently the framework does not do this.
// TODO -- we do not have to do this once https://github.com/microsoft/typespec/issues/8177 is fixed.
- foreach (var statement in doWhileStatement.Body)
+ foreach (var statement in whileStatement.Body)
{
- if (statement is ExpressionStatement { Expression: AssignmentExpression assignment } expressionStatement)
+ if (statement is YieldReturnStatement
+ {
+ Value: InvokeMethodExpression
+ {
+ MethodName: "FromValues",
+ Arguments: [CastExpression castExpression, ..]
+ } invokeMethodExpression
+ } &&
+ castExpression.Inner is MemberExpression
+ {
+ Inner: CastExpression innerCastExpression,
+ MemberName: var memberName
+ } &&
+ IsResponseToModelCastExpression(innerCastExpression))
+ {
+ // convert the implicit cast expression to a method call
+ var updatedExpression = ConvertCastToMethodCall(innerCastExpression)
+ .Property(memberName) // wrap back by a MemberExpression
+ .CastTo(castExpression.Type); // wrap back by the outer CastExpression
+ // use the above updated expression as the first argument of this method call inside the yield return
+ IReadOnlyList newArguments = [updatedExpression, .. invokeMethodExpression.Arguments.Skip(1)];
+ invokeMethodExpression.Update(arguments: newArguments);
+ }
+ else if (statement is ExpressionStatement
{
- var updatedExpression = DoVisitAssignmentExpressionForAsPagesMethod(assignment, method);
- if (updatedExpression is not null)
+ Expression: AssignmentExpression
{
- // update the expression in the statement.
- expressionStatement.Update(updatedExpression);
+ Variable: var variable,
+ Value: MemberExpression { Inner: CastExpression castExpression1, MemberName: var memberName1 }
}
+ } expressionStatement)
+ {
+ var updatedExpression = variable.Assign(
+ ConvertCastToMethodCall(castExpression1)
+ .Property(memberName1)); // wrap back by a MemberExpression
+ expressionStatement.Update(updatedExpression);
}
}
}
@@ -89,23 +119,17 @@ private void DoVisitAsPagesMethodStatements(MethodBodyStatements statements, Met
{
if (expression.Value is CastExpression castExpression && IsResponseToModelCastExpression(castExpression))
{
- var value = Static(castExpression.Type!).Invoke(SerializationVisitor.FromResponseMethodName, [castExpression.Inner!]);
+ var value = ConvertCastToMethodCall(castExpression);
var variable = expression.Variable;
return variable.Assign(value);
}
// do nothing if nothing is changed.
return null;
+ }
- static bool IsResponseToModelCastExpression(CastExpression castExpression)
- {
- if (castExpression.Inner is VariableExpression variableExpression &&
- variableExpression.Type is { IsFrameworkType: true, FrameworkType: { } frameworkType } &&
- frameworkType == typeof(Response))
- {
- return true;
- }
- return false;
- }
+ private static ValueExpression ConvertCastToMethodCall(CastExpression castExpression)
+ {
+ return Static(castExpression.Type!).Invoke(SerializationVisitor.FromResponseMethodName, [castExpression.Inner!]);
}
private ValueExpression? DoVisitAssignmentExpressionForGetNextResponseMethod(AssignmentExpression expression, MethodProvider method)
@@ -131,4 +155,9 @@ static bool IsResponseToModelCastExpression(CastExpression castExpression)
// do nothing if nothing is changed.
return null;
}
+
+ private static bool IsResponseToModelCastExpression(CastExpression castExpression)
+ => castExpression.Inner is VariableExpression variableExpression
+ && variableExpression.Type is { IsFrameworkType: true, FrameworkType: { } frameworkType }
+ && frameworkType == typeof(Response);
}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Azure.Generator.Mgmt.Tests.csproj b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Azure.Generator.Mgmt.Tests.csproj
index c6f1b1cb3e3d..75f055b11508 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Azure.Generator.Mgmt.Tests.csproj
+++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Azure.Generator.Mgmt.Tests.csproj
@@ -32,10 +32,4 @@
-
-
-
-
-
-
diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/Azure.Generator.Management.Tests.Common.csproj b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/Azure.Generator.Management.Tests.Common.csproj
index 60e082cb68c3..85f01df9d0e2 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/Azure.Generator.Management.Tests.Common.csproj
+++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/Azure.Generator.Management.Tests.Common.csproj
@@ -18,10 +18,4 @@
-
-
-
-
-
-
diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/InputFactory.cs b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/InputFactory.cs
index 25de3b257f1b..46e9ea3137de 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/InputFactory.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/InputFactory.cs
@@ -221,6 +221,7 @@ public static InputModelProperty Property(
access: null,
isDiscriminator,
serializedName ?? wireName ?? name.ToVariableName(),
+ false,
new(json: new(wireName ?? name)));
}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetAsyncCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetAsyncCollectionResult.cs
deleted file mode 100644
index 0924fb337517..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetAsyncCollectionResult.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class BarsGetAsyncCollectionResult : AsyncPageable
- {
- private readonly Bars _client;
- private readonly Guid _subscriptionId;
- private readonly string _resourceGroupName;
- private readonly string _fooName;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of BarsGetAsyncCollectionResult, which is used to iterate over the pages of a collection.
- /// The Bars client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The name of the resource group. The name is case insensitive.
- /// The name of the Foo.
- /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
- public BarsGetAsyncCollectionResult(Bars client, Guid subscriptionId, string resourceGroupName, string fooName, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
- Argument.AssertNotNullOrEmpty(fooName, nameof(fooName));
-
- _client = client;
- _subscriptionId = subscriptionId;
- _resourceGroupName = resourceGroupName;
- _fooName = fooName;
- _context = context;
- }
-
- /// Gets the pages of BarsGetAsyncCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of BarsGetAsyncCollectionResult as an enumerable collection.
- public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
- if (response is null)
- {
- yield break;
- }
- BarListResult responseWithType = BarListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _subscriptionId, _resourceGroupName, _fooName, _context) : _client.CreateGetRequest(_subscriptionId, _resourceGroupName, _fooName, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Bars.Get");
- scope.Start();
- try
- {
- return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetAsyncCollectionResultOfT.cs
index 12913030e787..c8be6c2c0655 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetAsyncCollectionResultOfT.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetAsyncCollectionResultOfT.cs
@@ -50,24 +50,26 @@ public BarsGetAsyncCollectionResultOfT(Bars client, Guid subscriptionId, string
public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
{
Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
+ while (true)
{
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
+ Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false);
if (response is null)
{
yield break;
}
- BarListResult responseWithType = BarListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
+ yield return Page.FromValues((IReadOnlyList)BarListResult.FromResponse(response).Value, nextPage?.AbsoluteUri, response);
+ nextPage = BarListResult.FromResponse(response).NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
}
- while (nextPage != null);
}
/// Get next page.
/// The number of items per page.
/// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
+ private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink)
{
HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _subscriptionId, _resourceGroupName, _fooName, _context) : _client.CreateGetRequest(_subscriptionId, _resourceGroupName, _fooName, _context);
using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("BarCollection.GetAll");
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetCollectionResult.cs
deleted file mode 100644
index 3fd8752162c1..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetCollectionResult.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class BarsGetCollectionResult : Pageable
- {
- private readonly Bars _client;
- private readonly Guid _subscriptionId;
- private readonly string _resourceGroupName;
- private readonly string _fooName;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of BarsGetCollectionResult, which is used to iterate over the pages of a collection.
- /// The Bars client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The name of the resource group. The name is case insensitive.
- /// The name of the Foo.
- /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
- /// or is null.
- /// or is an empty string, and was expected to be non-empty.
- public BarsGetCollectionResult(Bars client, Guid subscriptionId, string resourceGroupName, string fooName, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
- Argument.AssertNotNullOrEmpty(fooName, nameof(fooName));
-
- _client = client;
- _subscriptionId = subscriptionId;
- _resourceGroupName = resourceGroupName;
- _fooName = fooName;
- _context = context;
- }
-
- /// Gets the pages of BarsGetCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of BarsGetCollectionResult as an enumerable collection.
- public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = GetNextResponse(pageSizeHint, nextPage);
- if (response is null)
- {
- yield break;
- }
- BarListResult responseWithType = BarListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private Response GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _subscriptionId, _resourceGroupName, _fooName, _context) : _client.CreateGetRequest(_subscriptionId, _resourceGroupName, _fooName, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Bars.Get");
- scope.Start();
- try
- {
- return _client.Pipeline.ProcessMessage(message, _context);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetCollectionResultOfT.cs
index 24dc305c130c..a6b31d836a5b 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetCollectionResultOfT.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/BarsGetCollectionResultOfT.cs
@@ -49,18 +49,20 @@ public BarsGetCollectionResultOfT(Bars client, Guid subscriptionId, string resou
public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
{
Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
+ while (true)
{
Response response = GetNextResponse(pageSizeHint, nextPage);
if (response is null)
{
yield break;
}
- BarListResult responseWithType = BarListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
+ yield return Page.FromValues((IReadOnlyList)BarListResult.FromResponse(response).Value, nextPage?.AbsoluteUri, response);
+ nextPage = BarListResult.FromResponse(response).NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
}
- while (nextPage != null);
}
/// Get next page.
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetAsyncCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetAsyncCollectionResult.cs
deleted file mode 100644
index 1c3c804d96ba..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetAsyncCollectionResult.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class FoosGetAsyncCollectionResult : AsyncPageable
- {
- private readonly Foos _client;
- private readonly Guid _subscriptionId;
- private readonly string _resourceGroupName;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of FoosGetAsyncCollectionResult, which is used to iterate over the pages of a collection.
- /// The Foos client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The name of the resource group. The name is case insensitive.
- /// 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.
- public FoosGetAsyncCollectionResult(Foos client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
-
- _client = client;
- _subscriptionId = subscriptionId;
- _resourceGroupName = resourceGroupName;
- _context = context;
- }
-
- /// Gets the pages of FoosGetAsyncCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of FoosGetAsyncCollectionResult as an enumerable collection.
- public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
- if (response is null)
- {
- yield break;
- }
- FooListResult responseWithType = FooListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetRequest(_subscriptionId, _resourceGroupName, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Foos.Get");
- scope.Start();
- try
- {
- return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetAsyncCollectionResultOfT.cs
index bb19e1ca675f..45493abc32ff 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetAsyncCollectionResultOfT.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetAsyncCollectionResultOfT.cs
@@ -46,24 +46,26 @@ public FoosGetAsyncCollectionResultOfT(Foos client, Guid subscriptionId, string
public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
{
Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
+ while (true)
{
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
+ Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false);
if (response is null)
{
yield break;
}
- FooListResult responseWithType = FooListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
+ yield return Page.FromValues((IReadOnlyList)FooListResult.FromResponse(response).Value, nextPage?.AbsoluteUri, response);
+ nextPage = FooListResult.FromResponse(response).NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
}
- while (nextPage != null);
}
/// Get next page.
/// The number of items per page.
/// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
+ private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink)
{
HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetRequest(_subscriptionId, _resourceGroupName, _context);
using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("FooCollection.GetAll");
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetCollectionResult.cs
deleted file mode 100644
index f63ee3bb26f0..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetCollectionResult.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class FoosGetCollectionResult : Pageable
- {
- private readonly Foos _client;
- private readonly Guid _subscriptionId;
- private readonly string _resourceGroupName;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of FoosGetCollectionResult, which is used to iterate over the pages of a collection.
- /// The Foos client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The name of the resource group. The name is case insensitive.
- /// 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.
- public FoosGetCollectionResult(Foos client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
-
- _client = client;
- _subscriptionId = subscriptionId;
- _resourceGroupName = resourceGroupName;
- _context = context;
- }
-
- /// Gets the pages of FoosGetCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of FoosGetCollectionResult as an enumerable collection.
- public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = GetNextResponse(pageSizeHint, nextPage);
- if (response is null)
- {
- yield break;
- }
- FooListResult responseWithType = FooListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private Response GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetRequest(_subscriptionId, _resourceGroupName, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Foos.Get");
- scope.Start();
- try
- {
- return _client.Pipeline.ProcessMessage(message, _context);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetCollectionResultOfT.cs
index 8e19c1342b67..d7ad90adb289 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetCollectionResultOfT.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FoosGetCollectionResultOfT.cs
@@ -45,18 +45,20 @@ public FoosGetCollectionResultOfT(Foos client, Guid subscriptionId, string resou
public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
{
Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
+ while (true)
{
Response response = GetNextResponse(pageSizeHint, nextPage);
if (response is null)
{
yield break;
}
- FooListResult responseWithType = FooListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
+ yield return Page.FromValues((IReadOnlyList)FooListResult.FromResponse(response).Value, nextPage?.AbsoluteUri, response);
+ nextPage = FooListResult.FromResponse(response).NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
}
- while (nextPage != null);
}
/// Get next page.
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/MgmtTypeSpecModelFactory.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/MgmtTypeSpecModelFactory.cs
index 6269ef08f47e..b755df5983ee 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/MgmtTypeSpecModelFactory.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/MgmtTypeSpecModelFactory.cs
@@ -152,6 +152,17 @@ public static ZooPatch ZooPatch(IDictionary tags = default, stri
return new ZooPatch(tags, zooUpdateSomething is null ? default : new ZooUpdateProperties(zooUpdateSomething, new Dictionary()), additionalBinaryDataProperties: null);
}
+ /// Paged collection of ZooAddress items.
+ /// The ZooAddress items on this page.
+ /// The link to the next page of items.
+ /// A new instance for mocking.
+ public static ZooAddressListListResult ZooAddressListListResult(IEnumerable value = default, Uri nextLink = default)
+ {
+ value ??= new ChangeTrackingList();
+
+ return new ZooAddressListListResult(value.ToList(), nextLink, additionalBinaryDataProperties: null);
+ }
+
/// The FooPreviewAction.
/// The action to be performed.
///
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ActionType.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ActionType.cs
deleted file mode 100644
index 746df575fdf0..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ActionType.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ComponentModel;
-using MgmtTypeSpec;
-
-namespace MgmtTypeSpec.Models
-{
- /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.
- internal readonly partial struct ActionType : IEquatable
- {
- private readonly string _value;
- /// Actions are for internal-only APIs.
- private const string InternalValue = "Internal";
-
- /// Initializes a new instance of .
- /// The value.
- /// is null.
- public ActionType(string value)
- {
- Argument.AssertNotNull(value, nameof(value));
-
- _value = value;
- }
-
- /// Actions are for internal-only APIs.
- public static ActionType Internal { get; } = new ActionType(InternalValue);
-
- /// Determines if two values are the same.
- /// The left value to compare.
- /// The right value to compare.
- public static bool operator ==(ActionType left, ActionType right) => left.Equals(right);
-
- /// Determines if two values are not the same.
- /// The left value to compare.
- /// The right value to compare.
- public static bool operator !=(ActionType left, ActionType right) => !left.Equals(right);
-
- /// Converts a string to a .
- /// The value.
- public static implicit operator ActionType(string value) => new ActionType(value);
-
- /// Converts a string to a .
- /// The value.
- public static implicit operator ActionType?(string value) => value == null ? null : new ActionType(value);
-
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override bool Equals(object obj) => obj is ActionType other && Equals(other);
-
- ///
- public bool Equals(ActionType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
-
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
-
- ///
- public override string ToString() => _value;
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecContext.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecContext.cs
index 53aab0cfa192..0ba1cf0b288d 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecContext.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecContext.cs
@@ -16,28 +16,17 @@ namespace MgmtTypeSpec
/// Context class which will be filled in by the System.ClientModel.SourceGeneration.
/// For more information
///
- [ModelReaderWriterBuildable(typeof(OperationListResult))]
- [ModelReaderWriterBuildable(typeof(Operation))]
- [ModelReaderWriterBuildable(typeof(OperationDisplay))]
- [ModelReaderWriterBuildable(typeof(PrivateLinkListResult))]
- [ModelReaderWriterBuildable(typeof(PrivateLink))]
- [ModelReaderWriterBuildable(typeof(MgmtTypeSpecPrivateLinkResourceProperties))]
[ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))]
- [ModelReaderWriterBuildable(typeof(FooData))]
[ModelReaderWriterBuildable(typeof(FooProperties))]
[ModelReaderWriterBuildable(typeof(ExtendedLocation))]
[ModelReaderWriterBuildable(typeof(FooListResult))]
- [ModelReaderWriterBuildable(typeof(FooSettingsData))]
[ModelReaderWriterBuildable(typeof(FooSettingsProperties))]
[ModelReaderWriterBuildable(typeof(FooSettingsPropertiesMetaData))]
[ModelReaderWriterBuildable(typeof(FooSettingsPatch))]
[ModelReaderWriterBuildable(typeof(FooSettingsUpdateProperties))]
- [ModelReaderWriterBuildable(typeof(BarData))]
[ModelReaderWriterBuildable(typeof(BarProperties))]
[ModelReaderWriterBuildable(typeof(BarListResult))]
- [ModelReaderWriterBuildable(typeof(BarSettingsResourceData))]
[ModelReaderWriterBuildable(typeof(BarSettingsProperties))]
- [ModelReaderWriterBuildable(typeof(ZooData))]
[ModelReaderWriterBuildable(typeof(ZooProperties))]
[ModelReaderWriterBuildable(typeof(ZooPatch))]
[ModelReaderWriterBuildable(typeof(ZooUpdateProperties))]
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceProperties.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceProperties.Serialization.cs
deleted file mode 100644
index e5022c0b3666..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceProperties.Serialization.cs
+++ /dev/null
@@ -1,215 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ClientModel.Primitives;
-using System.Collections.Generic;
-using System.Text.Json;
-using MgmtTypeSpec;
-
-namespace MgmtTypeSpec.Models
-{
- /// Properties of a private link resource.
- internal partial class MgmtTypeSpecPrivateLinkResourceProperties : IJsonModel
- {
- /// 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(MgmtTypeSpecPrivateLinkResourceProperties)} does not support writing '{format}' format.");
- }
- if (options.Format != "W" && Optional.IsDefined(GroupId))
- {
- writer.WritePropertyName("groupId"u8);
- writer.WriteStringValue(GroupId);
- }
- if (options.Format != "W" && Optional.IsCollectionDefined(RequiredMembers))
- {
- writer.WritePropertyName("requiredMembers"u8);
- writer.WriteStartArray();
- foreach (string item in RequiredMembers)
- {
- if (item == null)
- {
- writer.WriteNullValue();
- continue;
- }
- writer.WriteStringValue(item);
- }
- writer.WriteEndArray();
- }
- if (Optional.IsCollectionDefined(RequiredZoneNames))
- {
- writer.WritePropertyName("requiredZoneNames"u8);
- writer.WriteStartArray();
- foreach (string item in RequiredZoneNames)
- {
- if (item == null)
- {
- writer.WriteNullValue();
- continue;
- }
- writer.WriteStringValue(item);
- }
- 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
- }
- }
- }
-
- /// The JSON reader.
- /// The client options for reading and writing models.
- MgmtTypeSpecPrivateLinkResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options);
-
- /// The JSON reader.
- /// The client options for reading and writing models.
- protected virtual MgmtTypeSpecPrivateLinkResourceProperties 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(MgmtTypeSpecPrivateLinkResourceProperties)} does not support reading '{format}' format.");
- }
- using JsonDocument document = JsonDocument.ParseValue(ref reader);
- return DeserializeMgmtTypeSpecPrivateLinkResourceProperties(document.RootElement, options);
- }
-
- /// The JSON element to deserialize.
- /// The client options for reading and writing models.
- internal static MgmtTypeSpecPrivateLinkResourceProperties DeserializeMgmtTypeSpecPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options)
- {
- if (element.ValueKind == JsonValueKind.Null)
- {
- return null;
- }
- string groupId = default;
- IReadOnlyList requiredMembers = default;
- IList requiredZoneNames = default;
- IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary();
- foreach (var prop in element.EnumerateObject())
- {
- if (prop.NameEquals("groupId"u8))
- {
- groupId = prop.Value.GetString();
- continue;
- }
- if (prop.NameEquals("requiredMembers"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- List array = new List();
- foreach (var item in prop.Value.EnumerateArray())
- {
- if (item.ValueKind == JsonValueKind.Null)
- {
- array.Add(null);
- }
- else
- {
- array.Add(item.GetString());
- }
- }
- requiredMembers = array;
- continue;
- }
- if (prop.NameEquals("requiredZoneNames"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- List array = new List();
- foreach (var item in prop.Value.EnumerateArray())
- {
- if (item.ValueKind == JsonValueKind.Null)
- {
- array.Add(null);
- }
- else
- {
- array.Add(item.GetString());
- }
- }
- requiredZoneNames = array;
- continue;
- }
- if (options.Format != "W")
- {
- additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
- }
- }
- return new MgmtTypeSpecPrivateLinkResourceProperties(groupId, requiredMembers ?? new ChangeTrackingList(), requiredZoneNames ?? new ChangeTrackingList(), additionalBinaryDataProperties);
- }
-
- /// The client options for reading and writing models.
- BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
-
- /// 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, MgmtTypeSpecContext.Default);
- default:
- throw new FormatException($"The model {nameof(MgmtTypeSpecPrivateLinkResourceProperties)} does not support writing '{options.Format}' format.");
- }
- }
-
- /// The data to parse.
- /// The client options for reading and writing models.
- MgmtTypeSpecPrivateLinkResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options);
-
- /// The data to parse.
- /// The client options for reading and writing models.
- protected virtual MgmtTypeSpecPrivateLinkResourceProperties 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))
- {
- return DeserializeMgmtTypeSpecPrivateLinkResourceProperties(document.RootElement, options);
- }
- default:
- throw new FormatException($"The model {nameof(MgmtTypeSpecPrivateLinkResourceProperties)} does not support reading '{options.Format}' format.");
- }
- }
-
- /// The client options for reading and writing models.
- string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceProperties.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceProperties.cs
deleted file mode 100644
index 860627a52b0b..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceProperties.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using MgmtTypeSpec;
-
-namespace MgmtTypeSpec.Models
-{
- /// Properties of a private link resource.
- internal partial class MgmtTypeSpecPrivateLinkResourceProperties
- {
- /// Keeps track of any properties unknown to the library.
- private protected readonly IDictionary _additionalBinaryDataProperties;
-
- /// Initializes a new instance of .
- internal MgmtTypeSpecPrivateLinkResourceProperties()
- {
- RequiredMembers = new ChangeTrackingList();
- RequiredZoneNames = new ChangeTrackingList();
- }
-
- /// Initializes a new instance of .
- /// The private link resource group id.
- /// The private link resource required member names.
- /// The private link resource private link DNS zone name.
- /// Keeps track of any properties unknown to the library.
- internal MgmtTypeSpecPrivateLinkResourceProperties(string groupId, IReadOnlyList requiredMembers, IList requiredZoneNames, IDictionary additionalBinaryDataProperties)
- {
- GroupId = groupId;
- RequiredMembers = requiredMembers;
- RequiredZoneNames = requiredZoneNames;
- _additionalBinaryDataProperties = additionalBinaryDataProperties;
- }
-
- /// The private link resource group id.
- public string GroupId { get; }
-
- /// The private link resource required member names.
- public IReadOnlyList RequiredMembers { get; }
-
- /// The private link resource private link DNS zone name.
- public IList RequiredZoneNames { get; }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/Operation.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/Operation.Serialization.cs
deleted file mode 100644
index 9178ba91917c..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/Operation.Serialization.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ClientModel.Primitives;
-using System.Collections.Generic;
-using System.Text.Json;
-using MgmtTypeSpec;
-
-namespace MgmtTypeSpec.Models
-{
- /// REST API Operation.
- internal partial class Operation : IJsonModel
- {
- /// 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(Operation)} does not support writing '{format}' format.");
- }
- if (options.Format != "W" && Optional.IsDefined(Name))
- {
- writer.WritePropertyName("name"u8);
- writer.WriteStringValue(Name);
- }
- if (options.Format != "W" && Optional.IsDefined(IsDataAction))
- {
- writer.WritePropertyName("isDataAction"u8);
- writer.WriteBooleanValue(IsDataAction.Value);
- }
- if (Optional.IsDefined(Display))
- {
- writer.WritePropertyName("display"u8);
- writer.WriteObjectValue(Display, options);
- }
- if (options.Format != "W" && Optional.IsDefined(Origin))
- {
- writer.WritePropertyName("origin"u8);
- writer.WriteStringValue(Origin.Value.ToString());
- }
- if (options.Format != "W" && Optional.IsDefined(ActionType))
- {
- writer.WritePropertyName("actionType"u8);
- writer.WriteStringValue(ActionType.Value.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.
- Operation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options);
-
- /// The JSON reader.
- /// The client options for reading and writing models.
- protected virtual Operation 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(Operation)} does not support reading '{format}' format.");
- }
- using JsonDocument document = JsonDocument.ParseValue(ref reader);
- return DeserializeOperation(document.RootElement, options);
- }
-
- /// The JSON element to deserialize.
- /// The client options for reading and writing models.
- internal static Operation DeserializeOperation(JsonElement element, ModelReaderWriterOptions options)
- {
- if (element.ValueKind == JsonValueKind.Null)
- {
- return null;
- }
- string name = default;
- bool? isDataAction = default;
- OperationDisplay display = default;
- Origin? origin = default;
- ActionType? actionType = default;
- IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary();
- foreach (var prop in element.EnumerateObject())
- {
- if (prop.NameEquals("name"u8))
- {
- name = prop.Value.GetString();
- continue;
- }
- if (prop.NameEquals("isDataAction"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- isDataAction = prop.Value.GetBoolean();
- continue;
- }
- if (prop.NameEquals("display"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- display = OperationDisplay.DeserializeOperationDisplay(prop.Value, options);
- continue;
- }
- if (prop.NameEquals("origin"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- origin = new Origin(prop.Value.GetString());
- continue;
- }
- if (prop.NameEquals("actionType"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- actionType = new ActionType(prop.Value.GetString());
- continue;
- }
- if (options.Format != "W")
- {
- additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
- }
- }
- return new Operation(
- name,
- isDataAction,
- display,
- origin,
- actionType,
- additionalBinaryDataProperties);
- }
-
- /// The client options for reading and writing models.
- BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
-
- /// 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, MgmtTypeSpecContext.Default);
- default:
- throw new FormatException($"The model {nameof(Operation)} does not support writing '{options.Format}' format.");
- }
- }
-
- /// The data to parse.
- /// The client options for reading and writing models.
- Operation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options);
-
- /// The data to parse.
- /// The client options for reading and writing models.
- protected virtual Operation 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))
- {
- return DeserializeOperation(document.RootElement, options);
- }
- default:
- throw new FormatException($"The model {nameof(Operation)} does not support reading '{options.Format}' format.");
- }
- }
-
- /// The client options for reading and writing models.
- string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/Operation.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/Operation.cs
deleted file mode 100644
index ab686c8f85fc..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/Operation.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-
-namespace MgmtTypeSpec.Models
-{
- /// REST API Operation.
- internal partial class Operation
- {
- /// Keeps track of any properties unknown to the library.
- private protected readonly IDictionary _additionalBinaryDataProperties;
-
- /// Initializes a new instance of .
- internal Operation()
- {
- }
-
- /// Initializes a new instance of .
- /// The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action".
- /// Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations.
- /// Localized display information for this particular operation.
- /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system".
- /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.
- /// Keeps track of any properties unknown to the library.
- internal Operation(string name, bool? isDataAction, OperationDisplay display, Origin? origin, ActionType? actionType, IDictionary additionalBinaryDataProperties)
- {
- Name = name;
- IsDataAction = isDataAction;
- Display = display;
- Origin = origin;
- ActionType = actionType;
- _additionalBinaryDataProperties = additionalBinaryDataProperties;
- }
-
- /// The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action".
- public string Name { get; }
-
- /// Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations.
- public bool? IsDataAction { get; }
-
- /// Localized display information for this particular operation.
- public OperationDisplay Display { get; }
-
- /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system".
- public Origin? Origin { get; }
-
- /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.
- public ActionType? ActionType { get; }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationDisplay.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationDisplay.Serialization.cs
deleted file mode 100644
index 7e8401702ecf..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationDisplay.Serialization.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ClientModel.Primitives;
-using System.Collections.Generic;
-using System.Text.Json;
-using MgmtTypeSpec;
-
-namespace MgmtTypeSpec.Models
-{
- /// Localized display information for and operation.
- internal partial class OperationDisplay : IJsonModel
- {
- /// 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(OperationDisplay)} does not support writing '{format}' format.");
- }
- if (options.Format != "W" && Optional.IsDefined(Provider))
- {
- writer.WritePropertyName("provider"u8);
- writer.WriteStringValue(Provider);
- }
- if (options.Format != "W" && Optional.IsDefined(Resource))
- {
- writer.WritePropertyName("resource"u8);
- writer.WriteStringValue(Resource);
- }
- if (options.Format != "W" && Optional.IsDefined(Operation))
- {
- writer.WritePropertyName("operation"u8);
- writer.WriteStringValue(Operation);
- }
- if (options.Format != "W" && Optional.IsDefined(Description))
- {
- writer.WritePropertyName("description"u8);
- writer.WriteStringValue(Description);
- }
- 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.
- OperationDisplay IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options);
-
- /// The JSON reader.
- /// The client options for reading and writing models.
- protected virtual OperationDisplay 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(OperationDisplay)} does not support reading '{format}' format.");
- }
- using JsonDocument document = JsonDocument.ParseValue(ref reader);
- return DeserializeOperationDisplay(document.RootElement, options);
- }
-
- /// The JSON element to deserialize.
- /// The client options for reading and writing models.
- internal static OperationDisplay DeserializeOperationDisplay(JsonElement element, ModelReaderWriterOptions options)
- {
- if (element.ValueKind == JsonValueKind.Null)
- {
- return null;
- }
- string provider = default;
- string resource = default;
- string operation = default;
- string description = default;
- IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary();
- foreach (var prop in element.EnumerateObject())
- {
- if (prop.NameEquals("provider"u8))
- {
- provider = prop.Value.GetString();
- continue;
- }
- if (prop.NameEquals("resource"u8))
- {
- resource = prop.Value.GetString();
- continue;
- }
- if (prop.NameEquals("operation"u8))
- {
- operation = prop.Value.GetString();
- continue;
- }
- if (prop.NameEquals("description"u8))
- {
- description = prop.Value.GetString();
- continue;
- }
- if (options.Format != "W")
- {
- additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
- }
- }
- return new OperationDisplay(provider, resource, operation, description, additionalBinaryDataProperties);
- }
-
- /// The client options for reading and writing models.
- BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
-
- /// 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, MgmtTypeSpecContext.Default);
- default:
- throw new FormatException($"The model {nameof(OperationDisplay)} does not support writing '{options.Format}' format.");
- }
- }
-
- /// The data to parse.
- /// The client options for reading and writing models.
- OperationDisplay IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options);
-
- /// The data to parse.
- /// The client options for reading and writing models.
- protected virtual OperationDisplay 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))
- {
- return DeserializeOperationDisplay(document.RootElement, options);
- }
- default:
- throw new FormatException($"The model {nameof(OperationDisplay)} does not support reading '{options.Format}' format.");
- }
- }
-
- /// The client options for reading and writing models.
- string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationDisplay.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationDisplay.cs
deleted file mode 100644
index 3fc5966834d7..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationDisplay.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-
-namespace MgmtTypeSpec.Models
-{
- /// Localized display information for and operation.
- internal partial class OperationDisplay
- {
- /// Keeps track of any properties unknown to the library.
- private protected readonly IDictionary _additionalBinaryDataProperties;
-
- /// Initializes a new instance of .
- internal OperationDisplay()
- {
- }
-
- /// Initializes a new instance of .
- /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute".
- /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections".
- /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine".
- /// The short, localized friendly description of the operation; suitable for tool tips and detailed views.
- /// Keeps track of any properties unknown to the library.
- internal OperationDisplay(string provider, string resource, string operation, string description, IDictionary additionalBinaryDataProperties)
- {
- Provider = provider;
- Resource = resource;
- Operation = operation;
- Description = description;
- _additionalBinaryDataProperties = additionalBinaryDataProperties;
- }
-
- /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute".
- public string Provider { get; }
-
- /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections".
- public string Resource { get; }
-
- /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine".
- public string Operation { get; }
-
- /// The short, localized friendly description of the operation; suitable for tool tips and detailed views.
- public string Description { get; }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationListResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationListResult.Serialization.cs
deleted file mode 100644
index 61de1cad24e7..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationListResult.Serialization.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ClientModel.Primitives;
-using System.Collections.Generic;
-using System.Text.Json;
-using Azure;
-using MgmtTypeSpec;
-
-namespace MgmtTypeSpec.Models
-{
- /// A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results.
- internal partial class OperationListResult : IJsonModel
- {
- /// Initializes a new instance of for deserialization.
- internal OperationListResult()
- {
- }
-
- /// 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(OperationListResult)} does not support writing '{format}' format.");
- }
- writer.WritePropertyName("value"u8);
- writer.WriteStartArray();
- foreach (Operation item in Value)
- {
- writer.WriteObjectValue(item, options);
- }
- writer.WriteEndArray();
- if (Optional.IsDefined(NextLink))
- {
- writer.WritePropertyName("nextLink"u8);
- writer.WriteStringValue(NextLink.AbsoluteUri);
- }
- 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.
- OperationListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options);
-
- /// The JSON reader.
- /// The client options for reading and writing models.
- protected virtual OperationListResult 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(OperationListResult)} does not support reading '{format}' format.");
- }
- using JsonDocument document = JsonDocument.ParseValue(ref reader);
- return DeserializeOperationListResult(document.RootElement, options);
- }
-
- /// The JSON element to deserialize.
- /// The client options for reading and writing models.
- internal static OperationListResult DeserializeOperationListResult(JsonElement element, ModelReaderWriterOptions options)
- {
- if (element.ValueKind == JsonValueKind.Null)
- {
- return null;
- }
- IList value = default;
- Uri nextLink = default;
- IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary();
- foreach (var prop in element.EnumerateObject())
- {
- if (prop.NameEquals("value"u8))
- {
- List array = new List();
- foreach (var item in prop.Value.EnumerateArray())
- {
- array.Add(Operation.DeserializeOperation(item, options));
- }
- value = array;
- continue;
- }
- if (prop.NameEquals("nextLink"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- nextLink = new Uri(prop.Value.GetString());
- continue;
- }
- if (options.Format != "W")
- {
- additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
- }
- }
- return new OperationListResult(value, nextLink, additionalBinaryDataProperties);
- }
-
- /// The client options for reading and writing models.
- BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
-
- /// 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, MgmtTypeSpecContext.Default);
- default:
- throw new FormatException($"The model {nameof(OperationListResult)} does not support writing '{options.Format}' format.");
- }
- }
-
- /// The data to parse.
- /// The client options for reading and writing models.
- OperationListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options);
-
- /// The data to parse.
- /// The client options for reading and writing models.
- protected virtual OperationListResult 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))
- {
- return DeserializeOperationListResult(document.RootElement, options);
- }
- default:
- throw new FormatException($"The model {nameof(OperationListResult)} does not support reading '{options.Format}' format.");
- }
- }
-
- /// The client options for reading and writing models.
- string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
-
- /// The to deserialize the from.
- internal static OperationListResult FromResponse(Response result)
- {
- using Response response = result;
- using JsonDocument document = JsonDocument.Parse(response.Content);
- return DeserializeOperationListResult(document.RootElement, ModelSerializationExtensions.WireOptions);
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationListResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationListResult.cs
deleted file mode 100644
index d565b2932eed..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/OperationListResult.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace MgmtTypeSpec.Models
-{
- /// A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results.
- internal partial class OperationListResult
- {
- /// Keeps track of any properties unknown to the library.
- private protected readonly IDictionary _additionalBinaryDataProperties;
-
- /// Initializes a new instance of .
- /// The Operation items on this page.
- internal OperationListResult(IEnumerable value)
- {
- Value = value.ToList();
- }
-
- /// Initializes a new instance of .
- /// The Operation items on this page.
- /// The link to the next page of items.
- /// Keeps track of any properties unknown to the library.
- internal OperationListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties)
- {
- Value = value;
- NextLink = nextLink;
- _additionalBinaryDataProperties = additionalBinaryDataProperties;
- }
-
- /// The Operation items on this page.
- public IList Value { get; }
-
- /// The link to the next page of items.
- public Uri NextLink { get; }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/Origin.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/Origin.cs
deleted file mode 100644
index ce10e48c4a6e..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/Origin.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ComponentModel;
-using MgmtTypeSpec;
-
-namespace MgmtTypeSpec.Models
-{
- /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system".
- internal readonly partial struct Origin : IEquatable
- {
- private readonly string _value;
- /// Indicates the operation is initiated by a user.
- private const string UserValue = "user";
- /// Indicates the operation is initiated by a system.
- private const string SystemValue = "system";
- /// Indicates the operation is initiated by a user or system.
- private const string UserSystemValue = "user,system";
-
- /// Initializes a new instance of .
- /// The value.
- /// is null.
- public Origin(string value)
- {
- Argument.AssertNotNull(value, nameof(value));
-
- _value = value;
- }
-
- /// Indicates the operation is initiated by a user.
- public static Origin User { get; } = new Origin(UserValue);
-
- /// Indicates the operation is initiated by a system.
- public static Origin System { get; } = new Origin(SystemValue);
-
- /// Indicates the operation is initiated by a user or system.
- public static Origin UserSystem { get; } = new Origin(UserSystemValue);
-
- /// Determines if two values are the same.
- /// The left value to compare.
- /// The right value to compare.
- public static bool operator ==(Origin left, Origin right) => left.Equals(right);
-
- /// Determines if two values are not the same.
- /// The left value to compare.
- /// The right value to compare.
- public static bool operator !=(Origin left, Origin right) => !left.Equals(right);
-
- /// Converts a string to a .
- /// The value.
- public static implicit operator Origin(string value) => new Origin(value);
-
- /// Converts a string to a .
- /// The value.
- public static implicit operator Origin?(string value) => value == null ? null : new Origin(value);
-
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override bool Equals(object obj) => obj is Origin other && Equals(other);
-
- ///
- public bool Equals(Origin other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
-
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
-
- ///
- public override string ToString() => _value;
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLink.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLink.Serialization.cs
deleted file mode 100644
index 00040035bb9a..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLink.Serialization.cs
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ClientModel.Primitives;
-using System.Collections.Generic;
-using System.Text;
-using System.Text.Json;
-using Azure.Core;
-using Azure.ResourceManager.Models;
-using MgmtTypeSpec;
-
-namespace MgmtTypeSpec.Models
-{
- /// Concrete proxy resource types can be created by aliasing this type using a specific property type.
- internal partial class PrivateLink : IJsonModel
- {
- /// 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 override 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(PrivateLink)} does not support writing '{format}' format.");
- }
- base.JsonModelWriteCore(writer, options);
- if (Optional.IsDefined(Properties))
- {
- writer.WritePropertyName("properties"u8);
- writer.WriteObjectValue(Properties, options);
- }
- if (Optional.IsDefined(Identity))
- {
- writer.WritePropertyName("identity"u8);
- ((IJsonModel)Identity).Write(writer, options);
- }
- }
-
- /// The JSON reader.
- /// The client options for reading and writing models.
- PrivateLink IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (PrivateLink)JsonModelCreateCore(ref reader, options);
-
- /// The JSON reader.
- /// The client options for reading and writing models.
- protected virtual ResourceData 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(PrivateLink)} does not support reading '{format}' format.");
- }
- using JsonDocument document = JsonDocument.ParseValue(ref reader);
- return DeserializePrivateLink(document.RootElement, options);
- }
-
- /// The JSON element to deserialize.
- /// The client options for reading and writing models.
- internal static PrivateLink DeserializePrivateLink(JsonElement element, ModelReaderWriterOptions options)
- {
- if (element.ValueKind == JsonValueKind.Null)
- {
- return null;
- }
- ResourceIdentifier id = default;
- string name = default;
- ResourceType resourceType = default;
- SystemData systemData = default;
- IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary();
- MgmtTypeSpecPrivateLinkResourceProperties properties = default;
- ManagedServiceIdentity identity = default;
- foreach (var prop in element.EnumerateObject())
- {
- if (prop.NameEquals("id"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- id = new ResourceIdentifier(prop.Value.GetString());
- continue;
- }
- if (prop.NameEquals("name"u8))
- {
- name = prop.Value.GetString();
- continue;
- }
- if (prop.NameEquals("type"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- resourceType = new ResourceType(prop.Value.GetString());
- continue;
- }
- if (prop.NameEquals("systemData"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtTypeSpecContext.Default);
- continue;
- }
- if (prop.NameEquals("properties"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- properties = MgmtTypeSpecPrivateLinkResourceProperties.DeserializeMgmtTypeSpecPrivateLinkResourceProperties(prop.Value, options);
- continue;
- }
- if (prop.NameEquals("identity"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtTypeSpecContext.Default);
- continue;
- }
- if (options.Format != "W")
- {
- additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
- }
- }
- return new PrivateLink(
- id,
- name,
- resourceType,
- systemData,
- additionalBinaryDataProperties,
- properties,
- identity);
- }
-
- /// The client options for reading and writing models.
- BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
-
- /// 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, MgmtTypeSpecContext.Default);
- default:
- throw new FormatException($"The model {nameof(PrivateLink)} does not support writing '{options.Format}' format.");
- }
- }
-
- /// The data to parse.
- /// The client options for reading and writing models.
- PrivateLink IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (PrivateLink)PersistableModelCreateCore(data, options);
-
- /// The data to parse.
- /// The client options for reading and writing models.
- protected virtual ResourceData 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))
- {
- return DeserializePrivateLink(document.RootElement, options);
- }
- default:
- throw new FormatException($"The model {nameof(PrivateLink)} does not support reading '{options.Format}' format.");
- }
- }
-
- /// The client options for reading and writing models.
- string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLink.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLink.cs
deleted file mode 100644
index 702308b04fdd..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLink.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using Azure.Core;
-using Azure.ResourceManager.Models;
-
-namespace MgmtTypeSpec.Models
-{
- /// Concrete proxy resource types can be created by aliasing this type using a specific property type.
- internal partial class PrivateLink : ResourceData
- {
- /// Keeps track of any properties unknown to the library.
- private protected readonly IDictionary _additionalBinaryDataProperties;
-
- /// Initializes a new instance of .
- internal PrivateLink()
- {
- }
-
- /// Initializes a new instance of .
- /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
- /// The name of the resource.
- /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".
- /// Azure Resource Manager metadata containing createdBy and modifiedBy information.
- /// Keeps track of any properties unknown to the library.
- /// The resource-specific properties for this resource.
- /// The managed service identities assigned to this resource.
- internal PrivateLink(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, MgmtTypeSpecPrivateLinkResourceProperties properties, ManagedServiceIdentity identity) : base(id, name, resourceType, systemData)
- {
- _additionalBinaryDataProperties = additionalBinaryDataProperties;
- Properties = properties;
- Identity = identity;
- }
-
- /// The resource-specific properties for this resource.
- public MgmtTypeSpecPrivateLinkResourceProperties Properties { get; }
-
- /// The managed service identities assigned to this resource.
- public ManagedServiceIdentity Identity { get; }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkListResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkListResult.Serialization.cs
deleted file mode 100644
index 80d7f9058a95..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkListResult.Serialization.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ClientModel.Primitives;
-using System.Collections.Generic;
-using System.Text.Json;
-using Azure;
-using MgmtTypeSpec;
-
-namespace MgmtTypeSpec.Models
-{
- /// The response of a PrivateLink list operation.
- internal partial class PrivateLinkListResult : IJsonModel
- {
- /// Initializes a new instance of for deserialization.
- internal PrivateLinkListResult()
- {
- }
-
- /// 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(PrivateLinkListResult)} does not support writing '{format}' format.");
- }
- writer.WritePropertyName("value"u8);
- writer.WriteStartArray();
- foreach (PrivateLink item in Value)
- {
- writer.WriteObjectValue(item, options);
- }
- writer.WriteEndArray();
- if (Optional.IsDefined(NextLink))
- {
- writer.WritePropertyName("nextLink"u8);
- writer.WriteStringValue(NextLink.AbsoluteUri);
- }
- 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.
- PrivateLinkListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options);
-
- /// The JSON reader.
- /// The client options for reading and writing models.
- protected virtual PrivateLinkListResult 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(PrivateLinkListResult)} does not support reading '{format}' format.");
- }
- using JsonDocument document = JsonDocument.ParseValue(ref reader);
- return DeserializePrivateLinkListResult(document.RootElement, options);
- }
-
- /// The JSON element to deserialize.
- /// The client options for reading and writing models.
- internal static PrivateLinkListResult DeserializePrivateLinkListResult(JsonElement element, ModelReaderWriterOptions options)
- {
- if (element.ValueKind == JsonValueKind.Null)
- {
- return null;
- }
- IList value = default;
- Uri nextLink = default;
- IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary();
- foreach (var prop in element.EnumerateObject())
- {
- if (prop.NameEquals("value"u8))
- {
- List array = new List();
- foreach (var item in prop.Value.EnumerateArray())
- {
- array.Add(PrivateLink.DeserializePrivateLink(item, options));
- }
- value = array;
- continue;
- }
- if (prop.NameEquals("nextLink"u8))
- {
- if (prop.Value.ValueKind == JsonValueKind.Null)
- {
- continue;
- }
- nextLink = new Uri(prop.Value.GetString());
- continue;
- }
- if (options.Format != "W")
- {
- additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
- }
- }
- return new PrivateLinkListResult(value, nextLink, additionalBinaryDataProperties);
- }
-
- /// The client options for reading and writing models.
- BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
-
- /// 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, MgmtTypeSpecContext.Default);
- default:
- throw new FormatException($"The model {nameof(PrivateLinkListResult)} does not support writing '{options.Format}' format.");
- }
- }
-
- /// The data to parse.
- /// The client options for reading and writing models.
- PrivateLinkListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options);
-
- /// The data to parse.
- /// The client options for reading and writing models.
- protected virtual PrivateLinkListResult 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))
- {
- return DeserializePrivateLinkListResult(document.RootElement, options);
- }
- default:
- throw new FormatException($"The model {nameof(PrivateLinkListResult)} does not support reading '{options.Format}' format.");
- }
- }
-
- /// The client options for reading and writing models.
- string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
-
- /// The to deserialize the from.
- internal static PrivateLinkListResult FromResponse(Response result)
- {
- using Response response = result;
- using JsonDocument document = JsonDocument.Parse(response.Content);
- return DeserializePrivateLinkListResult(document.RootElement, ModelSerializationExtensions.WireOptions);
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkListResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkListResult.cs
deleted file mode 100644
index 2dd0037af4c5..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkListResult.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace MgmtTypeSpec.Models
-{
- /// The response of a PrivateLink list operation.
- internal partial class PrivateLinkListResult
- {
- /// Keeps track of any properties unknown to the library.
- private protected readonly IDictionary _additionalBinaryDataProperties;
-
- /// Initializes a new instance of .
- /// The PrivateLink items on this page.
- internal PrivateLinkListResult(IEnumerable value)
- {
- Value = value.ToList();
- }
-
- /// Initializes a new instance of .
- /// The PrivateLink items on this page.
- /// The link to the next page of items.
- /// Keeps track of any properties unknown to the library.
- internal PrivateLinkListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties)
- {
- Value = value;
- NextLink = nextLink;
- _additionalBinaryDataProperties = additionalBinaryDataProperties;
- }
-
- /// The PrivateLink items on this page.
- public IList Value { get; }
-
- /// The link to the next page of items.
- public Uri NextLink { get; }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.Serialization.cs
index d5aff1d140a8..5cb44c394161 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.Serialization.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.Serialization.cs
@@ -17,7 +17,7 @@
namespace MgmtTypeSpec.Models
{
/// Paged collection of ZooAddress items.
- internal partial class ZooAddressListListResult : IJsonModel
+ public partial class ZooAddressListListResult : IJsonModel
{
/// Initializes a new instance of for deserialization.
internal ZooAddressListListResult()
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.cs
index d0ec8d2ae49d..3f327f6db5c6 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/ZooAddressListListResult.cs
@@ -13,7 +13,7 @@
namespace MgmtTypeSpec.Models
{
/// Paged collection of ZooAddress items.
- internal partial class ZooAddressListListResult
+ public partial class ZooAddressListListResult
{
/// Keeps track of any properties unknown to the library.
private protected readonly IDictionary _additionalBinaryDataProperties;
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetAsyncCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetAsyncCollectionResult.cs
deleted file mode 100644
index fee1c8f21eb3..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetAsyncCollectionResult.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class OperationsGetAsyncCollectionResult : AsyncPageable
- {
- private readonly Operations _client;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of OperationsGetAsyncCollectionResult, which is used to iterate over the pages of a collection.
- /// The Operations client used to send requests.
- /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
- public OperationsGetAsyncCollectionResult(Operations client, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- _client = client;
- _context = context;
- }
-
- /// Gets the pages of OperationsGetAsyncCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of OperationsGetAsyncCollectionResult as an enumerable collection.
- public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
- if (response is null)
- {
- yield break;
- }
- OperationListResult responseWithType = OperationListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _context) : _client.CreateGetRequest(_context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Operations.Get");
- scope.Start();
- try
- {
- return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetAsyncCollectionResultOfT.cs
deleted file mode 100644
index bda7cfbf4d0b..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetAsyncCollectionResultOfT.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class OperationsGetAsyncCollectionResultOfT : AsyncPageable
- {
- private readonly Operations _client;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of OperationsGetAsyncCollectionResultOfT, which is used to iterate over the pages of a collection.
- /// The Operations client used to send requests.
- /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
- public OperationsGetAsyncCollectionResultOfT(Operations client, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- _client = client;
- _context = context;
- }
-
- /// Gets the pages of OperationsGetAsyncCollectionResultOfT as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of OperationsGetAsyncCollectionResultOfT as an enumerable collection.
- public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
- if (response is null)
- {
- yield break;
- }
- OperationListResult responseWithType = OperationListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _context) : _client.CreateGetRequest(_context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Operations.Get");
- scope.Start();
- try
- {
- return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetCollectionResult.cs
deleted file mode 100644
index a50d741ef6f0..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetCollectionResult.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class OperationsGetCollectionResult : Pageable
- {
- private readonly Operations _client;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of OperationsGetCollectionResult, which is used to iterate over the pages of a collection.
- /// The Operations client used to send requests.
- /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
- public OperationsGetCollectionResult(Operations client, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- _client = client;
- _context = context;
- }
-
- /// Gets the pages of OperationsGetCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of OperationsGetCollectionResult as an enumerable collection.
- public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = GetNextResponse(pageSizeHint, nextPage);
- if (response is null)
- {
- yield break;
- }
- OperationListResult responseWithType = OperationListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private Response GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _context) : _client.CreateGetRequest(_context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Operations.Get");
- scope.Start();
- try
- {
- return _client.Pipeline.ProcessMessage(message, _context);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetCollectionResultOfT.cs
deleted file mode 100644
index 6ad1957b1b5e..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/OperationsGetCollectionResultOfT.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class OperationsGetCollectionResultOfT : Pageable
- {
- private readonly Operations _client;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of OperationsGetCollectionResultOfT, which is used to iterate over the pages of a collection.
- /// The Operations client used to send requests.
- /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
- public OperationsGetCollectionResultOfT(Operations client, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- _client = client;
- _context = context;
- }
-
- /// Gets the pages of OperationsGetCollectionResultOfT as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of OperationsGetCollectionResultOfT as an enumerable collection.
- public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = GetNextResponse(pageSizeHint, nextPage);
- if (response is null)
- {
- yield break;
- }
- OperationListResult responseWithType = OperationListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private Response GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _context) : _client.CreateGetRequest(_context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Operations.Get");
- scope.Start();
- try
- {
- return _client.Pipeline.ProcessMessage(message, _context);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResult.cs
deleted file mode 100644
index 485969e2aff2..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResult.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResult : AsyncPageable
- {
- private readonly PrivateLinks _client;
- private readonly Guid _subscriptionId;
- private readonly string _resourceGroupName;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResult, which is used to iterate over the pages of a collection.
- /// The PrivateLinks client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The name of the resource group. The name is case insensitive.
- /// 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.
- public PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResult(PrivateLinks client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
-
- _client = client;
- _subscriptionId = subscriptionId;
- _resourceGroupName = resourceGroupName;
- _context = context;
- }
-
- /// Gets the pages of PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResult as an enumerable collection.
- public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
- if (response is null)
- {
- yield break;
- }
- PrivateLinkListResult responseWithType = PrivateLinkListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetAllPrivateLinkResourcesRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetAllPrivateLinkResourcesRequest(_subscriptionId, _resourceGroupName, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("PrivateLinks.GetAllPrivateLinkResources");
- scope.Start();
- try
- {
- return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResultOfT.cs
deleted file mode 100644
index d39a7935f640..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResultOfT.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResultOfT : AsyncPageable
- {
- private readonly PrivateLinks _client;
- private readonly Guid _subscriptionId;
- private readonly string _resourceGroupName;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResultOfT, which is used to iterate over the pages of a collection.
- /// The PrivateLinks client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The name of the resource group. The name is case insensitive.
- /// 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.
- public PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResultOfT(PrivateLinks client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
-
- _client = client;
- _subscriptionId = subscriptionId;
- _resourceGroupName = resourceGroupName;
- _context = context;
- }
-
- /// Gets the pages of PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResultOfT as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of PrivateLinksGetAllPrivateLinkResourcesAsyncCollectionResultOfT as an enumerable collection.
- public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
- if (response is null)
- {
- yield break;
- }
- PrivateLinkListResult responseWithType = PrivateLinkListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetAllPrivateLinkResourcesRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetAllPrivateLinkResourcesRequest(_subscriptionId, _resourceGroupName, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("PrivateLinks.GetAllPrivateLinkResources");
- scope.Start();
- try
- {
- return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesCollectionResult.cs
deleted file mode 100644
index eda6cb4ea22f..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesCollectionResult.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class PrivateLinksGetAllPrivateLinkResourcesCollectionResult : Pageable
- {
- private readonly PrivateLinks _client;
- private readonly Guid _subscriptionId;
- private readonly string _resourceGroupName;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of PrivateLinksGetAllPrivateLinkResourcesCollectionResult, which is used to iterate over the pages of a collection.
- /// The PrivateLinks client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The name of the resource group. The name is case insensitive.
- /// 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.
- public PrivateLinksGetAllPrivateLinkResourcesCollectionResult(PrivateLinks client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
-
- _client = client;
- _subscriptionId = subscriptionId;
- _resourceGroupName = resourceGroupName;
- _context = context;
- }
-
- /// Gets the pages of PrivateLinksGetAllPrivateLinkResourcesCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of PrivateLinksGetAllPrivateLinkResourcesCollectionResult as an enumerable collection.
- public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = GetNextResponse(pageSizeHint, nextPage);
- if (response is null)
- {
- yield break;
- }
- PrivateLinkListResult responseWithType = PrivateLinkListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private Response GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetAllPrivateLinkResourcesRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetAllPrivateLinkResourcesRequest(_subscriptionId, _resourceGroupName, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("PrivateLinks.GetAllPrivateLinkResources");
- scope.Start();
- try
- {
- return _client.Pipeline.ProcessMessage(message, _context);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesCollectionResultOfT.cs
deleted file mode 100644
index b83dc4ffe516..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinksGetAllPrivateLinkResourcesCollectionResultOfT.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class PrivateLinksGetAllPrivateLinkResourcesCollectionResultOfT : Pageable
- {
- private readonly PrivateLinks _client;
- private readonly Guid _subscriptionId;
- private readonly string _resourceGroupName;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of PrivateLinksGetAllPrivateLinkResourcesCollectionResultOfT, which is used to iterate over the pages of a collection.
- /// The PrivateLinks client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The name of the resource group. The name is case insensitive.
- /// 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.
- public PrivateLinksGetAllPrivateLinkResourcesCollectionResultOfT(PrivateLinks client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
-
- _client = client;
- _subscriptionId = subscriptionId;
- _resourceGroupName = resourceGroupName;
- _context = context;
- }
-
- /// Gets the pages of PrivateLinksGetAllPrivateLinkResourcesCollectionResultOfT as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of PrivateLinksGetAllPrivateLinkResourcesCollectionResultOfT as an enumerable collection.
- public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = GetNextResponse(pageSizeHint, nextPage);
- if (response is null)
- {
- yield break;
- }
- PrivateLinkListResult responseWithType = PrivateLinkListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private Response GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetAllPrivateLinkResourcesRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetAllPrivateLinkResourcesRequest(_subscriptionId, _resourceGroupName, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("PrivateLinks.GetAllPrivateLinkResources");
- scope.Start();
- try
- {
- return _client.Pipeline.ProcessMessage(message, _context);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/BarsRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/BarsRestOperations.cs
index 919db8a488fd..6b28962221b7 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/BarsRestOperations.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/BarsRestOperations.cs
@@ -102,7 +102,6 @@ internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGro
uri.AppendPath(barName, true);
uri.AppendQuery("api-version", _apiVersion, true);
request.Uri = uri;
- request.Headers.SetValue("Accept", "application/json");
return message;
}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/FooSettingsOperationsRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/FooSettingsOperationsRestOperations.cs
index 529129794c15..00b80ecf5329 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/FooSettingsOperationsRestOperations.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/FooSettingsOperationsRestOperations.cs
@@ -113,7 +113,6 @@ internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGro
uri.AppendPath("/providers/MgmtTypeSpec/FooSettings/default", false);
uri.AppendQuery("api-version", _apiVersion, true);
request.Uri = uri;
- request.Headers.SetValue("Accept", "application/json");
return message;
}
}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/FoosRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/FoosRestOperations.cs
index 7925c1a6ad3a..f8185e1f1a50 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/FoosRestOperations.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/FoosRestOperations.cs
@@ -96,7 +96,6 @@ internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGro
uri.AppendPath(fooName, true);
uri.AppendQuery("api-version", _apiVersion, true);
request.Uri = uri;
- request.Headers.SetValue("Accept", "application/json");
return message;
}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/OperationsRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/OperationsRestOperations.cs
deleted file mode 100644
index 4f43b8013a8b..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/OperationsRestOperations.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-
-namespace MgmtTypeSpec
-{
- internal partial class Operations
- {
- private readonly Uri _endpoint;
- private readonly string _apiVersion;
-
- /// Initializes a new instance of Operations for mocking.
- protected Operations()
- {
- }
-
- /// Initializes a new instance of Operations.
- /// The ClientDiagnostics is used to provide tracing support for the client library.
- /// The HTTP pipeline for sending and receiving REST requests and responses.
- /// Service endpoint.
- ///
- internal Operations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion)
- {
- ClientDiagnostics = clientDiagnostics;
- _endpoint = endpoint;
- Pipeline = pipeline;
- _apiVersion = apiVersion;
- }
-
- /// The HTTP pipeline for sending and receiving REST requests and responses.
- public virtual HttpPipeline Pipeline { get; }
-
- /// The ClientDiagnostics is used to provide tracing support for the client library.
- internal ClientDiagnostics ClientDiagnostics { get; }
-
- internal HttpMessage CreateGetRequest(RequestContext context)
- {
- HttpMessage message = Pipeline.CreateMessage();
- Request request = message.Request;
- request.Method = RequestMethod.Get;
- RawRequestUriBuilder uri = new RawRequestUriBuilder();
- uri.Reset(_endpoint);
- uri.AppendPath("/providers/MgmtTypeSpec/operations", false);
- uri.AppendQuery("api-version", _apiVersion, true);
- request.Uri = uri;
- request.Headers.SetValue("Accept", "application/json");
- return message;
- }
-
- internal HttpMessage CreateNextGetRequest(Uri nextPage, RequestContext context)
- {
- HttpMessage message = Pipeline.CreateMessage();
- Request request = message.Request;
- request.Method = RequestMethod.Get;
- RawRequestUriBuilder uri = new RawRequestUriBuilder();
- uri.Reset(nextPage);
- request.Uri = uri;
- request.Headers.SetValue("Accept", "application/json");
- return message;
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/PrivateLinksRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/PrivateLinksRestOperations.cs
deleted file mode 100644
index c71b5d3d610b..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/PrivateLinksRestOperations.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-
-namespace MgmtTypeSpec
-{
- internal partial class PrivateLinks
- {
- private readonly Uri _endpoint;
- private readonly string _apiVersion;
-
- /// Initializes a new instance of PrivateLinks for mocking.
- protected PrivateLinks()
- {
- }
-
- /// Initializes a new instance of PrivateLinks.
- /// The ClientDiagnostics is used to provide tracing support for the client library.
- /// The HTTP pipeline for sending and receiving REST requests and responses.
- /// Service endpoint.
- ///
- internal PrivateLinks(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion)
- {
- ClientDiagnostics = clientDiagnostics;
- _endpoint = endpoint;
- Pipeline = pipeline;
- _apiVersion = apiVersion;
- }
-
- /// The HTTP pipeline for sending and receiving REST requests and responses.
- public virtual HttpPipeline Pipeline { get; }
-
- /// The ClientDiagnostics is used to provide tracing support for the client library.
- internal ClientDiagnostics ClientDiagnostics { get; }
-
- internal HttpMessage CreateGetAllPrivateLinkResourcesRequest(Guid subscriptionId, string resourceGroupName, RequestContext context)
- {
- HttpMessage message = Pipeline.CreateMessage();
- Request request = message.Request;
- request.Method = RequestMethod.Get;
- RawRequestUriBuilder uri = new RawRequestUriBuilder();
- uri.Reset(_endpoint);
- uri.AppendPath("/subscriptions/", false);
- uri.AppendPath(subscriptionId.ToString(), true);
- uri.AppendPath("/resourceGroups/", false);
- uri.AppendPath(resourceGroupName, true);
- uri.AppendPath("/providers/MgmtTypeSpec/privateLinkResources", false);
- uri.AppendQuery("api-version", _apiVersion, true);
- request.Uri = uri;
- request.Headers.SetValue("Accept", "application/json");
- return message;
- }
-
- internal HttpMessage CreateNextGetAllPrivateLinkResourcesRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, RequestContext context)
- {
- HttpMessage message = Pipeline.CreateMessage();
- Request request = message.Request;
- request.Method = RequestMethod.Get;
- RawRequestUriBuilder uri = new RawRequestUriBuilder();
- uri.Reset(nextPage);
- request.Uri = uri;
- request.Headers.SetValue("Accept", "application/json");
- return message;
- }
-
- internal HttpMessage CreateStartRequest(Guid subscriptionId, string resourceGroupName, string privateLinkResourceName, RequestContent content, RequestContext context)
- {
- HttpMessage message = Pipeline.CreateMessage();
- Request request = message.Request;
- request.Method = RequestMethod.Post;
- RawRequestUriBuilder uri = new RawRequestUriBuilder();
- uri.Reset(_endpoint);
- uri.AppendPath("/subscriptions/", false);
- uri.AppendPath(subscriptionId.ToString(), true);
- uri.AppendPath("/resourceGroups/", false);
- uri.AppendPath(resourceGroupName, true);
- uri.AppendPath("/providers/MgmtTypeSpec/privateLinkResources/", false);
- uri.AppendPath(privateLinkResourceName, true);
- uri.AppendPath("/start", false);
- uri.AppendQuery("api-version", _apiVersion, true);
- request.Uri = uri;
- if ("application/json" != null)
- {
- request.Headers.SetValue("Content-Type", "application/json");
- }
- request.Headers.SetValue("Accept", "application/json");
- request.Content = content;
- return message;
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/ZoosRestOperations.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/ZoosRestOperations.cs
index 930bfe56c071..6c268ccce8c2 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/ZoosRestOperations.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/RestOperations/ZoosRestOperations.cs
@@ -96,7 +96,6 @@ internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGro
uri.AppendPath(zooName, true);
uri.AppendQuery("api-version", _apiVersion, true);
request.Uri = uri;
- request.Headers.SetValue("Accept", "application/json");
return message;
}
@@ -202,17 +201,5 @@ internal HttpMessage CreateZooAddressListRequest(Guid subscriptionId, string res
request.Headers.SetValue("Accept", "application/json");
return message;
}
-
- internal HttpMessage CreateNextZooAddressListRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string zooName, int? maxpagesize, RequestContext context)
- {
- HttpMessage message = Pipeline.CreateMessage();
- Request request = message.Request;
- request.Method = RequestMethod.Get;
- RawRequestUriBuilder uri = new RawRequestUriBuilder();
- uri.Reset(nextPage);
- request.Uri = uri;
- request.Headers.SetValue("Accept", "application/json");
- return message;
- }
}
}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZooResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZooResource.cs
index a33d80b56d36..cceadd7a541c 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZooResource.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZooResource.cs
@@ -15,7 +15,6 @@
using Azure.Core.Pipeline;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
-using Azure.ResourceManager.Resources.Models;
using MgmtTypeSpec.Models;
namespace MgmtTypeSpec
@@ -293,39 +292,59 @@ public virtual ArmOperation Update(WaitUntil waitUntil, ZooPatch pa
/// A synchronous resource action.
///
/// The cancellation token to use.
- /// A collection of that may take multiple service requests to iterate over.
- public virtual AsyncPageable ZooAddressListAsync(int? maxpagesize = default, CancellationToken cancellationToken = default)
+ public virtual async Task> ZooAddressListAsync(int? maxpagesize = default, CancellationToken cancellationToken = default)
{
- RequestContext context = new RequestContext
- {
- CancellationToken = cancellationToken
- };
- return new ZoosZooAddressListAsyncCollectionResultOfT(
- _zoosRestClient,
- Guid.Parse(Id.SubscriptionId),
- Id.ResourceGroupName,
- Id.Name,
- maxpagesize,
- context);
+ using DiagnosticScope scope = _zoosClientDiagnostics.CreateScope("ZooResource.ZooAddressList");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _zoosRestClient.CreateZooAddressListRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, maxpagesize, context);
+ Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ Response response = Response.FromValue(ZooAddressListListResult.FromResponse(result), result);
+ if (response.Value == null)
+ {
+ throw new RequestFailedException(response.GetRawResponse());
+ }
+ return response;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
}
/// A synchronous resource action.
///
/// The cancellation token to use.
- /// A collection of that may take multiple service requests to iterate over.
- public virtual Pageable ZooAddressList(int? maxpagesize = default, CancellationToken cancellationToken = default)
+ public virtual Response ZooAddressList(int? maxpagesize = default, CancellationToken cancellationToken = default)
{
- RequestContext context = new RequestContext
- {
- CancellationToken = cancellationToken
- };
- return new ZoosZooAddressListCollectionResultOfT(
- _zoosRestClient,
- Guid.Parse(Id.SubscriptionId),
- Id.ResourceGroupName,
- Id.Name,
- maxpagesize,
- context);
+ using DiagnosticScope scope = _zoosClientDiagnostics.CreateScope("ZooResource.ZooAddressList");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _zoosRestClient.CreateZooAddressListRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, maxpagesize, context);
+ Response result = Pipeline.ProcessMessage(message, context);
+ Response response = Response.FromValue(ZooAddressListListResult.FromResponse(result), result);
+ if (response.Value == null)
+ {
+ throw new RequestFailedException(response.GetRawResponse());
+ }
+ return response;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
}
/// A synchronous resource action.
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetAsyncCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetAsyncCollectionResult.cs
deleted file mode 100644
index 720d3fe91e77..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetAsyncCollectionResult.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class ZoosGetAsyncCollectionResult : AsyncPageable
- {
- private readonly Zoos _client;
- private readonly Guid _subscriptionId;
- private readonly string _resourceGroupName;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of ZoosGetAsyncCollectionResult, which is used to iterate over the pages of a collection.
- /// The Zoos client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The name of the resource group. The name is case insensitive.
- /// 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.
- public ZoosGetAsyncCollectionResult(Zoos client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
-
- _client = client;
- _subscriptionId = subscriptionId;
- _resourceGroupName = resourceGroupName;
- _context = context;
- }
-
- /// Gets the pages of ZoosGetAsyncCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of ZoosGetAsyncCollectionResult as an enumerable collection.
- public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
- if (response is null)
- {
- yield break;
- }
- ZooListResult responseWithType = ZooListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetRequest(_subscriptionId, _resourceGroupName, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Zoos.Get");
- scope.Start();
- try
- {
- return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetAsyncCollectionResultOfT.cs
index a32a7cbc140a..463e39a6ce6c 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetAsyncCollectionResultOfT.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetAsyncCollectionResultOfT.cs
@@ -46,24 +46,26 @@ public ZoosGetAsyncCollectionResultOfT(Zoos client, Guid subscriptionId, string
public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
{
Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
+ while (true)
{
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
+ Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false);
if (response is null)
{
yield break;
}
- ZooListResult responseWithType = ZooListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
+ yield return Page.FromValues((IReadOnlyList)ZooListResult.FromResponse(response).Value, nextPage?.AbsoluteUri, response);
+ nextPage = ZooListResult.FromResponse(response).NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
}
- while (nextPage != null);
}
/// Get next page.
/// The number of items per page.
/// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
+ private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink)
{
HttpMessage message = nextLink != null ? _client.CreateNextGetRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetRequest(_subscriptionId, _resourceGroupName, _context);
using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ZooCollection.GetAll");
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionAsyncCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionAsyncCollectionResult.cs
deleted file mode 100644
index 113b37cb5ed1..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionAsyncCollectionResult.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class ZoosGetBySubscriptionAsyncCollectionResult : AsyncPageable
- {
- private readonly Zoos _client;
- private readonly Guid _subscriptionId;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of ZoosGetBySubscriptionAsyncCollectionResult, which is used to iterate over the pages of a collection.
- /// The Zoos client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
- public ZoosGetBySubscriptionAsyncCollectionResult(Zoos client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- _client = client;
- _subscriptionId = subscriptionId;
- _context = context;
- }
-
- /// Gets the pages of ZoosGetBySubscriptionAsyncCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of ZoosGetBySubscriptionAsyncCollectionResult as an enumerable collection.
- public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
- if (response is null)
- {
- yield break;
- }
- ZooListResult responseWithType = ZooListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Zoos.GetBySubscription");
- scope.Start();
- try
- {
- return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionAsyncCollectionResultOfT.cs
index 2c81cc6b0ead..99c02db362ef 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionAsyncCollectionResultOfT.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionAsyncCollectionResultOfT.cs
@@ -39,24 +39,26 @@ public ZoosGetBySubscriptionAsyncCollectionResultOfT(Zoos client, Guid subscript
public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
{
Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
+ while (true)
{
- Response response = await GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
+ Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false);
if (response is null)
{
yield break;
}
- ZooListResult responseWithType = ZooListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
+ yield return Page.FromValues((IReadOnlyList)ZooListResult.FromResponse(response).Value, nextPage?.AbsoluteUri, response);
+ nextPage = ZooListResult.FromResponse(response).NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
}
- while (nextPage != null);
}
/// Get next page.
/// The number of items per page.
/// The next link to use for the next page of results.
- private async ValueTask GetNextResponse(int? pageSizeHint, Uri nextLink)
+ private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink)
{
HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context);
using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableMgmtTypeSpecSubscriptionResource.GetBySubscription");
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionCollectionResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionCollectionResult.cs
deleted file mode 100644
index bf9a2ac18d3c..000000000000
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionCollectionResult.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-using MgmtTypeSpec.Models;
-
-namespace MgmtTypeSpec
-{
- internal partial class ZoosGetBySubscriptionCollectionResult : Pageable
- {
- private readonly Zoos _client;
- private readonly Guid _subscriptionId;
- private readonly RequestContext _context;
-
- /// Initializes a new instance of ZoosGetBySubscriptionCollectionResult, which is used to iterate over the pages of a collection.
- /// The Zoos client used to send requests.
- /// The ID of the target subscription. The value must be an UUID.
- /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
- public ZoosGetBySubscriptionCollectionResult(Zoos client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default)
- {
- _client = client;
- _subscriptionId = subscriptionId;
- _context = context;
- }
-
- /// Gets the pages of ZoosGetBySubscriptionCollectionResult as an enumerable collection.
- /// A continuation token indicating where to resume paging.
- /// The number of items per page.
- /// The pages of ZoosGetBySubscriptionCollectionResult as an enumerable collection.
- public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
- {
- Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
- {
- Response response = GetNextResponse(pageSizeHint, nextPage);
- if (response is null)
- {
- yield break;
- }
- ZooListResult responseWithType = ZooListResult.FromResponse(response);
- List items = new List();
- foreach (var item in responseWithType.Value)
- {
- items.Add(BinaryData.FromObjectAsJson(item));
- }
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
- }
- while (nextPage != null);
- }
-
- /// Get next page.
- /// The number of items per page.
- /// The next link to use for the next page of results.
- private Response GetNextResponse(int? pageSizeHint, Uri nextLink)
- {
- HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context);
- using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("Zoos.GetBySubscription");
- scope.Start();
- try
- {
- return _client.Pipeline.ProcessMessage(message, _context);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
- }
-}
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionCollectionResultOfT.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionCollectionResultOfT.cs
index b8aa6bc9972a..d5d911d843a6 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionCollectionResultOfT.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/ZoosGetBySubscriptionCollectionResultOfT.cs
@@ -38,18 +38,20 @@ public ZoosGetBySubscriptionCollectionResultOfT(Zoos client, Guid subscriptionId
public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
{
Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
- do
+ while (true)
{
Response response = GetNextResponse(pageSizeHint, nextPage);
if (response is null)
{
yield break;
}
- ZooListResult responseWithType = ZooListResult.FromResponse(response);
- nextPage = responseWithType.NextLink;
- yield return Page.FromValues((IReadOnlyList)responseWithType.Value, nextPage?.AbsoluteUri, response);
+ yield return Page.FromValues((IReadOnlyList