Skip to content

Commit 9077cfe

Browse files
Upgrade to latest MTG (Azure#50613)
* Upgrade to latest MTG * revert
1 parent 3228637 commit 9077cfe

18 files changed

+99
-98
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@
442442

443443
<PropertyGroup>
444444
<TestProxyVersion>1.0.0-dev.20250501.1</TestProxyVersion>
445-
<UnbrandedGeneratorVersion>1.0.0-alpha.20250611.5</UnbrandedGeneratorVersion>
445+
<UnbrandedGeneratorVersion>1.0.0-alpha.20250613.2</UnbrandedGeneratorVersion>
446446
<AzureGeneratorVersion>1.0.0-alpha.20250527.2</AzureGeneratorVersion>
447447
</PropertyGroup>
448448
</Project>

eng/packages/http-client-csharp/generator/Azure.Generator/src/Providers/CollectionResultDefinition.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ internal class CollectionResultDefinition : TypeProvider
4444
private static readonly ParameterProvider ContinuationTokenParameter =
4545
new("continuationToken", $"A continuation token indicating where to resume paging.", new CSharpType(typeof(string)));
4646
private static readonly ParameterProvider NextLinkParameter =
47-
new("nextLink", $"The next link to use for the next page of results.", new CSharpType(typeof(Uri)));
47+
new("nextLink", $"The next link to use for the next page of results.", new CSharpType(typeof(Uri), isNullable: true));
4848
private static readonly ParameterProvider PageSizeHintParameter =
4949
new("pageSizeHint", $"The number of items per page.", new CSharpType(typeof(int?)));
5050

@@ -177,7 +177,7 @@ private MethodBodyStatement[] BuildAsPagesMethodBody()
177177
: _requestFields[_nextTokenParameterIndex!.Value].Type;
178178

179179
statements.Add(Declare("nextPage", nextPageType, _paging.NextLink != null ?
180-
new TernaryConditionalExpression(ContinuationTokenParameter.NotEqual(Null), New.Instance<Uri>(ContinuationTokenParameter), _requestFields[0]) :
180+
new TernaryConditionalExpression(ContinuationTokenParameter.NotEqual(Null), New.Instance<Uri>(ContinuationTokenParameter), Null) :
181181
ContinuationTokenParameter.NullCoalesce(_requestFields[_nextTokenParameterIndex!.Value]), out var nextPageVariable));
182182

183183
var doWhileStatement = _paging.NextLink != null ?
@@ -334,11 +334,19 @@ private MethodBodyStatement[] BuildGetResponse(ValueExpression messageVariable)
334334
};
335335
}
336336

337-
private ScopedApi<HttpMessage> InvokeCreateRequestForNextLink(ValueExpression nextPageUri) => _clientField.Invoke(
338-
_createRequestMethodName,
339-
// we replace the first argument (the initialUri) with the nextPageUri
340-
[nextPageUri, .. _requestFields.Skip(1)])
341-
.As<HttpMessage>();
337+
private ScopedApi<HttpMessage> InvokeCreateRequestForNextLink(ValueExpression nextPageUri)
338+
{
339+
var createNextLinkRequestMethodName =
340+
_client.RestClient.GetCreateNextLinkRequestMethod(_operation).Signature.Name;
341+
return new TernaryConditionalExpression(
342+
nextPageUri.NotEqual(Null),
343+
_clientField.Invoke(
344+
createNextLinkRequestMethodName,
345+
[nextPageUri, .. _requestFields.Select(f => f.AsValueExpression)]),
346+
_clientField.Invoke(
347+
_createRequestMethodName,
348+
[.. _requestFields.Select(f => f.AsValueExpression)])).As<HttpMessage>();
349+
}
342350

343351
private ScopedApi<HttpMessage> InvokeCreateRequestForContinuationToken(ValueExpression continuationToken)
344352
{

eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBody.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@ namespace Samples
1717
internal partial class CatClientGetCatsCollectionResult : global::Azure.Pageable<global::System.BinaryData>
1818
{
1919
private readonly global::Samples.CatClient _client;
20-
private readonly global::System.Uri _nextPage;
2120
private readonly global::Azure.RequestContext _context;
2221

2322
/// <summary> Initializes a new instance of CatClientGetCatsCollectionResult, which is used to iterate over the pages of a collection. </summary>
2423
/// <param name="client"> The CatClient client used to send requests. </param>
25-
/// <param name="nextPage"> The url of the next page of responses. </param>
2624
/// <param name="context"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
27-
public CatClientGetCatsCollectionResult(global::Samples.CatClient client, global::System.Uri nextPage, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
25+
public CatClientGetCatsCollectionResult(global::Samples.CatClient client, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
2826
{
2927
_client = client;
30-
_nextPage = nextPage;
3128
_context = context;
3229
}
3330

@@ -37,7 +34,7 @@ public CatClientGetCatsCollectionResult(global::Samples.CatClient client, global
3734
/// <returns> The pages of CatClientGetCatsCollectionResult as an enumerable collection. </returns>
3835
public override global::System.Collections.Generic.IEnumerable<global::Azure.Page<global::System.BinaryData>> AsPages(string continuationToken, int? pageSizeHint)
3936
{
40-
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : _nextPage;
37+
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : null;
4138
do
4239
{
4340
global::Azure.Response response = this.GetNextResponse(pageSizeHint, nextPage);
@@ -62,7 +59,7 @@ public CatClientGetCatsCollectionResult(global::Samples.CatClient client, global
6259
/// <param name="nextLink"> The next link to use for the next page of results. </param>
6360
private global::Azure.Response GetNextResponse(int? pageSizeHint, global::System.Uri nextLink)
6461
{
65-
global::Azure.Core.HttpMessage message = _client.CreateGetCatsRequest(nextLink, _context);
62+
global::Azure.Core.HttpMessage message = (nextLink != null) ? _client.CreateNextGetCatsRequest(nextLink, _context) : _client.CreateGetCatsRequest(_context);
6663
using global::Azure.Core.Pipeline.DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("CatClient.GetCats");
6764
scope.Start();
6865
try

eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyAsync.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ namespace Samples
1818
internal partial class CatClientGetCatsAsyncCollectionResult : global::Azure.AsyncPageable<global::System.BinaryData>
1919
{
2020
private readonly global::Samples.CatClient _client;
21-
private readonly global::System.Uri _nextPage;
2221
private readonly global::Azure.RequestContext _context;
2322

2423
/// <summary> Initializes a new instance of CatClientGetCatsAsyncCollectionResult, which is used to iterate over the pages of a collection. </summary>
2524
/// <param name="client"> The CatClient client used to send requests. </param>
26-
/// <param name="nextPage"> The url of the next page of responses. </param>
2725
/// <param name="context"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
28-
public CatClientGetCatsAsyncCollectionResult(global::Samples.CatClient client, global::System.Uri nextPage, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
26+
public CatClientGetCatsAsyncCollectionResult(global::Samples.CatClient client, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
2927
{
3028
_client = client;
31-
_nextPage = nextPage;
3229
_context = context;
3330
}
3431

@@ -38,7 +35,7 @@ public CatClientGetCatsAsyncCollectionResult(global::Samples.CatClient client, g
3835
/// <returns> The pages of CatClientGetCatsAsyncCollectionResult as an enumerable collection. </returns>
3936
public override async global::System.Collections.Generic.IAsyncEnumerable<global::Azure.Page<global::System.BinaryData>> AsPages(string continuationToken, int? pageSizeHint)
4037
{
41-
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : _nextPage;
38+
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : null;
4239
do
4340
{
4441
global::Azure.Response response = await this.GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
@@ -63,7 +60,7 @@ public CatClientGetCatsAsyncCollectionResult(global::Samples.CatClient client, g
6360
/// <param name="nextLink"> The next link to use for the next page of results. </param>
6461
private async global::System.Threading.Tasks.ValueTask<global::Azure.Response> GetNextResponse(int? pageSizeHint, global::System.Uri nextLink)
6562
{
66-
global::Azure.Core.HttpMessage message = _client.CreateGetCatsRequest(nextLink, _context);
63+
global::Azure.Core.HttpMessage message = (nextLink != null) ? _client.CreateNextGetCatsRequest(nextLink, _context) : _client.CreateGetCatsRequest(_context);
6764
using global::Azure.Core.Pipeline.DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("CatClient.GetCats");
6865
scope.Start();
6966
try

eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfT.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@ namespace Samples
1717
internal partial class CatClientGetCatsCollectionResultOfT : global::Azure.Pageable<global::Samples.Models.Cat>
1818
{
1919
private readonly global::Samples.CatClient _client;
20-
private readonly global::System.Uri _nextPage;
2120
private readonly global::Azure.RequestContext _context;
2221

2322
/// <summary> Initializes a new instance of CatClientGetCatsCollectionResultOfT, which is used to iterate over the pages of a collection. </summary>
2423
/// <param name="client"> The CatClient client used to send requests. </param>
25-
/// <param name="nextPage"> The url of the next page of responses. </param>
2624
/// <param name="context"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
27-
public CatClientGetCatsCollectionResultOfT(global::Samples.CatClient client, global::System.Uri nextPage, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
25+
public CatClientGetCatsCollectionResultOfT(global::Samples.CatClient client, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
2826
{
2927
_client = client;
30-
_nextPage = nextPage;
3128
_context = context;
3229
}
3330

@@ -37,7 +34,7 @@ public CatClientGetCatsCollectionResultOfT(global::Samples.CatClient client, glo
3734
/// <returns> The pages of CatClientGetCatsCollectionResultOfT as an enumerable collection. </returns>
3835
public override global::System.Collections.Generic.IEnumerable<global::Azure.Page<global::Samples.Models.Cat>> AsPages(string continuationToken, int? pageSizeHint)
3936
{
40-
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : _nextPage;
37+
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : null;
4138
do
4239
{
4340
global::Azure.Response response = this.GetNextResponse(pageSizeHint, nextPage);
@@ -57,7 +54,7 @@ public CatClientGetCatsCollectionResultOfT(global::Samples.CatClient client, glo
5754
/// <param name="nextLink"> The next link to use for the next page of results. </param>
5855
private global::Azure.Response GetNextResponse(int? pageSizeHint, global::System.Uri nextLink)
5956
{
60-
global::Azure.Core.HttpMessage message = _client.CreateGetCatsRequest(nextLink, _context);
57+
global::Azure.Core.HttpMessage message = (nextLink != null) ? _client.CreateNextGetCatsRequest(nextLink, _context) : _client.CreateGetCatsRequest(_context);
6158
using global::Azure.Core.Pipeline.DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("CatClient.GetCats");
6259
scope.Start();
6360
try

eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfTAsync.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ namespace Samples
1818
internal partial class CatClientGetCatsAsyncCollectionResultOfT : global::Azure.AsyncPageable<global::Samples.Models.Cat>
1919
{
2020
private readonly global::Samples.CatClient _client;
21-
private readonly global::System.Uri _nextPage;
2221
private readonly global::Azure.RequestContext _context;
2322

2423
/// <summary> Initializes a new instance of CatClientGetCatsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. </summary>
2524
/// <param name="client"> The CatClient client used to send requests. </param>
26-
/// <param name="nextPage"> The url of the next page of responses. </param>
2725
/// <param name="context"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
28-
public CatClientGetCatsAsyncCollectionResultOfT(global::Samples.CatClient client, global::System.Uri nextPage, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
26+
public CatClientGetCatsAsyncCollectionResultOfT(global::Samples.CatClient client, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
2927
{
3028
_client = client;
31-
_nextPage = nextPage;
3229
_context = context;
3330
}
3431

@@ -38,7 +35,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Samples.CatClient client
3835
/// <returns> The pages of CatClientGetCatsAsyncCollectionResultOfT as an enumerable collection. </returns>
3936
public override async global::System.Collections.Generic.IAsyncEnumerable<global::Azure.Page<global::Samples.Models.Cat>> AsPages(string continuationToken, int? pageSizeHint)
4037
{
41-
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : _nextPage;
38+
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : null;
4239
do
4340
{
4441
global::Azure.Response response = await this.GetNextResponse(pageSizeHint, nextPage).ConfigureAwait(false);
@@ -58,7 +55,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Samples.CatClient client
5855
/// <param name="nextLink"> The next link to use for the next page of results. </param>
5956
private async global::System.Threading.Tasks.ValueTask<global::Azure.Response> GetNextResponse(int? pageSizeHint, global::System.Uri nextLink)
6057
{
61-
global::Azure.Core.HttpMessage message = _client.CreateGetCatsRequest(nextLink, _context);
58+
global::Azure.Core.HttpMessage message = (nextLink != null) ? _client.CreateNextGetCatsRequest(nextLink, _context) : _client.CreateGetCatsRequest(_context);
6259
using global::Azure.Core.Pipeline.DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("CatClient.GetCats");
6360
scope.Start();
6461
try

eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeader.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@ namespace Samples
1717
internal partial class CatClientGetCatsCollectionResult : global::Azure.Pageable<global::System.BinaryData>
1818
{
1919
private readonly global::Samples.CatClient _client;
20-
private readonly global::System.Uri _nextPage;
2120
private readonly global::Azure.RequestContext _context;
2221

2322
/// <summary> Initializes a new instance of CatClientGetCatsCollectionResult, which is used to iterate over the pages of a collection. </summary>
2423
/// <param name="client"> The CatClient client used to send requests. </param>
25-
/// <param name="nextPage"> The url of the next page of responses. </param>
2624
/// <param name="context"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
27-
public CatClientGetCatsCollectionResult(global::Samples.CatClient client, global::System.Uri nextPage, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
25+
public CatClientGetCatsCollectionResult(global::Samples.CatClient client, global::Azure.RequestContext context) : base((context?.CancellationToken ?? default))
2826
{
2927
_client = client;
30-
_nextPage = nextPage;
3128
_context = context;
3229
}
3330

@@ -37,7 +34,7 @@ public CatClientGetCatsCollectionResult(global::Samples.CatClient client, global
3734
/// <returns> The pages of CatClientGetCatsCollectionResult as an enumerable collection. </returns>
3835
public override global::System.Collections.Generic.IEnumerable<global::Azure.Page<global::System.BinaryData>> AsPages(string continuationToken, int? pageSizeHint)
3936
{
40-
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : _nextPage;
37+
global::System.Uri nextPage = (continuationToken != null) ? new global::System.Uri(continuationToken) : null;
4138
do
4239
{
4340
global::Azure.Response response = this.GetNextResponse(pageSizeHint, nextPage);
@@ -62,7 +59,7 @@ public CatClientGetCatsCollectionResult(global::Samples.CatClient client, global
6259
/// <param name="nextLink"> The next link to use for the next page of results. </param>
6360
private global::Azure.Response GetNextResponse(int? pageSizeHint, global::System.Uri nextLink)
6461
{
65-
global::Azure.Core.HttpMessage message = _client.CreateGetCatsRequest(nextLink, _context);
62+
global::Azure.Core.HttpMessage message = (nextLink != null) ? _client.CreateNextGetCatsRequest(nextLink, _context) : _client.CreateGetCatsRequest(_context);
6663
using global::Azure.Core.Pipeline.DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("CatClient.GetCats");
6764
scope.Start();
6865
try

0 commit comments

Comments
 (0)