diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/CollectionResultDefinition.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/CollectionResultDefinition.cs index f6723882a32..ae617957bf5 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/CollectionResultDefinition.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/CollectionResultDefinition.cs @@ -31,6 +31,8 @@ public class CollectionResultDefinition : TypeProvider protected InputOperation Operation { get; } protected InputPagingServiceMetadata Paging { get; } + public string ScopeName { get; } + protected internal FieldProvider? PageSizeField { get; } protected FieldProvider RequestOptionsField => _requestOptionsField ??= RequestFields @@ -77,6 +79,7 @@ public CollectionResultDefinition(ClientProvider client, InputPagingServiceMetho Paging = serviceMethod.PagingMetadata; IsAsync = isAsync; ItemModelType = itemModelType; + ScopeName = $"{Client.Name}.{Operation.Name.ToIdentifierName()}"; var response = Operation.Responses.FirstOrDefault(r => !r.IsErrorResponse); ResponseModel = ScmCodeModelGenerator.Instance.TypeFactory.CreateModel((InputModelType)response!.BodyType!)!; @@ -272,6 +275,8 @@ private MethodBodyStatement[] BuildConstructorBody(ParameterProvider clientParam return statements.ToArray(); } + private string GetNextResponseMethodName => IsAsync ? "GetNextResponseAsync" : "GetNextResponse"; + protected override MethodProvider[] BuildMethods() { MethodBodyStatement[] getRawPagesMethodBody = (Paging.NextLink, Paging.ContinuationToken) switch @@ -328,9 +333,40 @@ protected override MethodProvider[] BuildMethods() this)); } + methods.Add(BuildGetNextResponseMethod()); + return methods.ToArray(); } + private MethodProvider BuildGetNextResponseMethod() + { + var messageParameter = new ParameterProvider( + "message", + $"The pipeline message containing the request to send.", + ScmCodeModelGenerator.Instance.TypeFactory.HttpMessageApi.HttpMessageType); + + var signature = new MethodSignature( + GetNextResponseMethodName, + $"Sends the request in the pipeline message and returns the response.", + IsAsync ? MethodSignatureModifiers.Private | MethodSignatureModifiers.Async : MethodSignatureModifiers.Private, + IsAsync + ? new CSharpType(typeof(ValueTask<>), typeof(ClientResult)) + : new CSharpType(typeof(ClientResult)), + null, + [messageParameter]); + + var processMessageExpression = ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse( + ClientField.Property("Pipeline").ToApi().ProcessMessage( + messageParameter.ToApi(), + RequestOptionsField.AsValueExpression.ToApi(), + IsAsync)).ToApi(); + + return new MethodProvider( + signature, + Return(processMessageExpression), + this); + } + private MethodBodyStatement[] BuildGetValuesFromPages() { var items = GetPropertyExpression(Paging.ItemPropertySegments, PageParameter.AsVariable()); @@ -426,11 +462,7 @@ private MethodBodyStatement[] BuildGetRawPagesForNextLink() { Declare( "result", - ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse( - ClientField.Property("Pipeline").ToApi().ProcessMessage( - message.ToApi(), - RequestOptionsField.AsValueExpression.ToApi(), - IsAsync)).ToApi(), + This.Invoke(GetNextResponseMethodName, [message], IsAsync).ToApi(), out ClientResponseApi result), // Yield return result @@ -465,11 +497,7 @@ private MethodBodyStatement[] BuildGetRawPagesForContinuationToken() { Declare( "result", - ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse( - ClientField.Property("Pipeline").ToApi().ProcessMessage( - message.ToApi(), - RequestOptionsField.AsValueExpression.ToApi(), - IsAsync)).ToApi(), + This.Invoke(GetNextResponseMethodName, [message], IsAsync).ToApi(), out ClientResponseApi result), // Yield return result @@ -491,16 +519,12 @@ private MethodBodyStatement[] BuildGetRawPagesForSingle() "message", InvokeCreateInitialRequest(), out ScopedApi m); - var pipelineResponse = ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse( - ClientField.Property("Pipeline").ToApi().ProcessMessage( - m.ToApi(), - RequestOptionsField.AsValueExpression.ToApi(), - IsAsync)).ToApi(); + var result = This.Invoke(GetNextResponseMethodName, [m], IsAsync).ToApi(); return [ pipelineMessageDeclaration, // Yield return result - YieldReturn(pipelineResponse), + YieldReturn(result), ]; } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBody.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBody.cs index 5b46c63769f..4233475bb27 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBody.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBody.cs @@ -29,7 +29,7 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, string string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextToken = ((global::Sample.Models.Page)result).NextPage; @@ -53,5 +53,10 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, string return null; } } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyAsync.cs index 7d72955fb56..5f5cff04a6f 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyAsync.cs @@ -6,6 +6,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; using Sample.Models; namespace Sample @@ -29,7 +30,7 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, st string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextToken = ((global::Sample.Models.Page)result).NextPage; @@ -53,5 +54,10 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, st return null; } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyOfT.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyOfT.cs index 0f34bae6765..4f36757aac3 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyOfT.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyOfT.cs @@ -29,7 +29,7 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, stri string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextToken = ((global::Sample.Models.Page)result).NextPage; @@ -58,5 +58,10 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, stri { return ((global::Sample.Models.Page)page).Cats; } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyOfTAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyOfTAsync.cs index eb7cf347cb2..9b5efe704c7 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyOfTAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInBodyOfTAsync.cs @@ -30,7 +30,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextToken = ((global::Sample.Models.Page)result).NextPage; @@ -63,5 +63,10 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, await global::System.Threading.Tasks.Task.Yield(); } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeader.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeader.cs index 9d0e78d72a4..e9a9ca657c9 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeader.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeader.cs @@ -28,7 +28,7 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, string string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; if ((result.GetRawResponse().Headers.TryGetValue("nextPage", out string value) && !string.IsNullOrEmpty(value))) @@ -54,5 +54,10 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, string return null; } } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderAsync.cs index 4f3a5e39dc3..1eb510af463 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderAsync.cs @@ -6,6 +6,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; namespace Sample { @@ -28,7 +29,7 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, st string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; if ((result.GetRawResponse().Headers.TryGetValue("nextPage", out string value) && !string.IsNullOrEmpty(value))) @@ -54,5 +55,10 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, st return null; } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderOfT.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderOfT.cs index 86f0fa61a4c..37b39ba49df 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderOfT.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderOfT.cs @@ -29,7 +29,7 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, stri string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; if ((result.GetRawResponse().Headers.TryGetValue("nextPage", out string value) && !string.IsNullOrEmpty(value))) @@ -60,5 +60,10 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, stri { return ((global::Sample.Models.Page)page).Cats; } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderOfTAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderOfTAsync.cs index d678537d70c..100adfd6448 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderOfTAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/ContinuationTokenInHeaderOfTAsync.cs @@ -30,7 +30,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; if ((result.GetRawResponse().Headers.TryGetValue("nextPage", out string value) && !string.IsNullOrEmpty(value))) @@ -65,5 +65,10 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, await global::System.Threading.Tasks.Task.Yield(); } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBody.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBody.cs index cebf8a007c8..df0444e754e 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBody.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBody.cs @@ -29,7 +29,7 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, string string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextToken = ((global::Sample.Models.Page)result).NestedNext?.NextPage; @@ -53,5 +53,10 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, string return null; } } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyAsync.cs index c6a3bddf38f..96c501d3cae 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyAsync.cs @@ -6,6 +6,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; using Sample.Models; namespace Sample @@ -29,7 +30,7 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, st string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextToken = ((global::Sample.Models.Page)result).NestedNext?.NextPage; @@ -53,5 +54,10 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, st return null; } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyOfT.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyOfT.cs index 322d7ebe480..0859204216f 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyOfT.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyOfT.cs @@ -29,7 +29,7 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, stri string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextToken = ((global::Sample.Models.Page)result).NestedNext?.NextPage; @@ -58,5 +58,10 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, stri { return ((global::Sample.Models.Page)page).NestedItems?.Cats; } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyOfTAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyOfTAsync.cs index c4084c3f67a..8d76e7e615b 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyOfTAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ContinuationTokenTests/NestedContinuationTokenInBodyOfTAsync.cs @@ -30,7 +30,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, string nextToken = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextToken = ((global::Sample.Models.Page)result).NestedNext?.NextPage; @@ -63,5 +63,10 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, await global::System.Threading.Tasks.Task.Yield(); } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationToken.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationToken.cs index a1e9970637f..be79971e212 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationToken.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationToken.cs @@ -24,12 +24,17 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, string public override global::System.Collections.Generic.IEnumerable GetRawPages() { global::System.ClientModel.Primitives.PipelineMessage message = _client.CreateGetCatsRequest(_animalKind, _options); - yield return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return this.GetNextResponse(message); } public override global::System.ClientModel.ContinuationToken GetContinuationToken(global::System.ClientModel.ClientResult page) { return null; } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenAsync.cs index 9069bb98016..622d18d500d 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenAsync.cs @@ -5,6 +5,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; namespace Sample { @@ -24,12 +25,17 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, st public override async global::System.Collections.Generic.IAsyncEnumerable GetRawPagesAsync() { global::System.ClientModel.Primitives.PipelineMessage message = _client.CreateGetCatsRequest(_animalKind, _options); - yield return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return await this.GetNextResponseAsync(message).ConfigureAwait(false); } public override global::System.ClientModel.ContinuationToken GetContinuationToken(global::System.ClientModel.ClientResult page) { return null; } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenOfT.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenOfT.cs index d7ac7f6b765..2dee0b1ed72 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenOfT.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenOfT.cs @@ -25,7 +25,7 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, stri public override global::System.Collections.Generic.IEnumerable GetRawPages() { global::System.ClientModel.Primitives.PipelineMessage message = _client.CreateGetCatsRequest(_animalKind, _options); - yield return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return this.GetNextResponse(message); } public override global::System.ClientModel.ContinuationToken GetContinuationToken(global::System.ClientModel.ClientResult page) @@ -37,5 +37,10 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, stri { return ((global::Sample.Models.Page)page).Cats; } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenOfTAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenOfTAsync.cs index fcb8c65b25b..6c82884dc73 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenOfTAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/ListPageableTests/NoNextLinkOrContinuationTokenOfTAsync.cs @@ -26,7 +26,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, public override async global::System.Collections.Generic.IAsyncEnumerable GetRawPagesAsync() { global::System.ClientModel.Primitives.PipelineMessage message = _client.CreateGetCatsRequest(_animalKind, _options); - yield return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return await this.GetNextResponseAsync(message).ConfigureAwait(false); } public override global::System.ClientModel.ContinuationToken GetContinuationToken(global::System.ClientModel.ClientResult page) @@ -42,5 +42,10 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, await global::System.Threading.Tasks.Task.Yield(); } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBody.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBody.cs index e1f78cc8679..6c2fbb79051 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBody.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBody.cs @@ -27,7 +27,7 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, global: global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NextCat; @@ -51,5 +51,10 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, global: return null; } } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyAsync.cs index 0491709e3c8..86d2adfba2f 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyAsync.cs @@ -6,6 +6,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; using Sample.Models; namespace Sample @@ -27,7 +28,7 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, gl global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NextCat; @@ -51,5 +52,10 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, gl return null; } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyOfT.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyOfT.cs index 33d94bd80a9..ea15f35606f 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyOfT.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyOfT.cs @@ -27,7 +27,7 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, glob global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NextCat; @@ -56,5 +56,10 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, glob { return ((global::Sample.Models.Page)page).Cats; } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyOfTAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyOfTAsync.cs index 020919ead77..6e4695ff104 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyOfTAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/InheritedNextLinkInBodyOfTAsync.cs @@ -28,7 +28,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NextCat; @@ -61,5 +61,10 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, await global::System.Threading.Tasks.Task.Yield(); } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBody.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBody.cs index 0b2e4c398a3..72bdccbd446 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBody.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBody.cs @@ -27,7 +27,7 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, global: global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NestedNext?.NextCat; @@ -51,5 +51,10 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, global: return null; } } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyAsync.cs index 82f8d0a8341..cbcf2b4ee78 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyAsync.cs @@ -6,6 +6,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; using Sample.Models; namespace Sample @@ -27,7 +28,7 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, gl global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NestedNext?.NextCat; @@ -51,5 +52,10 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, gl return null; } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyOfT.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyOfT.cs index cf2c5317d2f..d5b0b644c1d 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyOfT.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyOfT.cs @@ -27,7 +27,7 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, glob global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NestedNext?.NextCat; @@ -56,5 +56,10 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, glob { return ((global::Sample.Models.Page)page).NestedItems?.Cats; } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyOfTAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyOfTAsync.cs index 7397512821b..b4fce30004f 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyOfTAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NestedNextLinkInBodyOfTAsync.cs @@ -28,7 +28,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NestedNext?.NextCat; @@ -61,5 +61,10 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, await global::System.Threading.Tasks.Task.Yield(); } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBody.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBody.cs index e1f78cc8679..6c2fbb79051 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBody.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBody.cs @@ -27,7 +27,7 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, global: global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NextCat; @@ -51,5 +51,10 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, global: return null; } } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyAsync.cs index 0491709e3c8..86d2adfba2f 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyAsync.cs @@ -6,6 +6,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; using Sample.Models; namespace Sample @@ -27,7 +28,7 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, gl global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NextCat; @@ -51,5 +52,10 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, gl return null; } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfT.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfT.cs index 33d94bd80a9..ea15f35606f 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfT.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfT.cs @@ -27,7 +27,7 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, glob global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NextCat; @@ -56,5 +56,10 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, glob { return ((global::Sample.Models.Page)page).Cats; } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfTAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfTAsync.cs index 020919ead77..6e4695ff104 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfTAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfTAsync.cs @@ -28,7 +28,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((global::Sample.Models.Page)result).NextCat; @@ -61,5 +61,10 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, await global::System.Threading.Tasks.Task.Yield(); } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeader.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeader.cs index 7ea1821acd6..98111f0fd7a 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeader.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeader.cs @@ -26,7 +26,7 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, global: global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; if ((result.GetRawResponse().Headers.TryGetValue("nextCat", out string value) && !string.IsNullOrEmpty(value))) @@ -52,5 +52,10 @@ public CatClientGetCatsCollectionResult(global::Sample.CatClient client, global: return null; } } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderAsync.cs index f1dc58323dd..75cf7c29d55 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderAsync.cs @@ -6,6 +6,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; namespace Sample { @@ -26,7 +27,7 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, gl global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; if ((result.GetRawResponse().Headers.TryGetValue("nextCat", out string value) && !string.IsNullOrEmpty(value))) @@ -52,5 +53,10 @@ public CatClientGetCatsAsyncCollectionResult(global::Sample.CatClient client, gl return null; } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderOfT.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderOfT.cs index d064505fef6..5cd6bbca8d5 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderOfT.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderOfT.cs @@ -27,7 +27,7 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, glob global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + global::System.ClientModel.ClientResult result = this.GetNextResponse(message); yield return result; if ((result.GetRawResponse().Headers.TryGetValue("nextCat", out string value) && !string.IsNullOrEmpty(value))) @@ -58,5 +58,10 @@ public CatClientGetCatsCollectionResultOfT(global::Sample.CatClient client, glob { return ((global::Sample.Models.Page)page).Cats; } + + private global::System.ClientModel.ClientResult GetNextResponse(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderOfTAsync.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderOfTAsync.cs index dfa872611cd..7f242e4f7a5 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderOfTAsync.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInHeaderOfTAsync.cs @@ -28,7 +28,7 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, global::System.Uri nextPageUri = null; while (true) { - global::System.ClientModel.ClientResult result = global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + global::System.ClientModel.ClientResult result = await this.GetNextResponseAsync(message).ConfigureAwait(false); yield return result; if ((result.GetRawResponse().Headers.TryGetValue("nextCat", out string value) && !string.IsNullOrEmpty(value))) @@ -63,5 +63,10 @@ public CatClientGetCatsAsyncCollectionResultOfT(global::Sample.CatClient client, await global::System.Threading.Tasks.Task.Yield(); } } + + private async global::System.Threading.Tasks.ValueTask GetNextResponseAsync(global::System.ClientModel.Primitives.PipelineMessage message) + { + return global::System.ClientModel.ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs index 89c5702b006..850e32848fd 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResult.cs @@ -9,6 +9,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; namespace SampleTypeSpec { @@ -37,7 +38,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextToken = ((ListWithContinuationTokenResponse)result).NextToken; @@ -64,5 +65,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs index 75eb97d46bb..9c3d3170ab2 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenAsyncCollectionResultOfT.cs @@ -38,7 +38,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextToken = ((ListWithContinuationTokenResponse)result).NextToken; @@ -77,5 +77,12 @@ protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientRe await Task.Yield(); } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResult.cs index 0c52e02a228..b1cfc1098f8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResult.cs @@ -37,7 +37,7 @@ public override IEnumerable GetRawPages() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = GetNextResponse(message); yield return result; nextToken = ((ListWithContinuationTokenResponse)result).NextToken; @@ -64,5 +64,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs index d5eabeb8a8e..69acd134fc1 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenCollectionResultOfT.cs @@ -37,7 +37,7 @@ public override IEnumerable GetRawPages() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = GetNextResponse(message); yield return result; nextToken = ((ListWithContinuationTokenResponse)result).NextToken; @@ -72,5 +72,12 @@ protected override IEnumerable GetValuesFromPage(ClientResult page) { return ((ListWithContinuationTokenResponse)page).Things; } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs index ca9ff340edf..d0de57b47ec 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResult.cs @@ -9,6 +9,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; namespace SampleTypeSpec { @@ -37,7 +38,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await GetNextResponseAsync(message).ConfigureAwait(false); yield return result; if (result.GetRawResponse().Headers.TryGetValue("next-token", out string value) && !string.IsNullOrEmpty(value)) @@ -66,5 +67,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT.cs index ebdce57e71a..c4a863befcb 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseAsyncCollectionResultOfT.cs @@ -38,7 +38,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await GetNextResponseAsync(message).ConfigureAwait(false); yield return result; if (result.GetRawResponse().Headers.TryGetValue("next-token", out string value) && !string.IsNullOrEmpty(value)) @@ -79,5 +79,12 @@ protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientRe await Task.Yield(); } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult.cs index f50dab79b40..7e8c2afe4c8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResult.cs @@ -37,7 +37,7 @@ public override IEnumerable GetRawPages() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = GetNextResponse(message); yield return result; if (result.GetRawResponse().Headers.TryGetValue("next-token", out string value) && !string.IsNullOrEmpty(value)) @@ -66,5 +66,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT.cs index b4e10128332..af88f217ecb 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithContinuationTokenHeaderResponseCollectionResultOfT.cs @@ -37,7 +37,7 @@ public override IEnumerable GetRawPages() string nextToken = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = GetNextResponse(message); yield return result; if (result.GetRawResponse().Headers.TryGetValue("next-token", out string value) && !string.IsNullOrEmpty(value)) @@ -74,5 +74,12 @@ protected override IEnumerable GetValuesFromPage(ClientResult page) { return ((ListWithContinuationTokenHeaderResponseResponse)page).Things; } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult.cs index 034facf2353..fcbb4f3315d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResult.cs @@ -9,6 +9,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; namespace SampleTypeSpec { @@ -34,7 +35,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((ListWithNextLinkResponse)result).Next; @@ -61,5 +62,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT.cs index 6ecde199e1c..366d3aac566 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkAsyncCollectionResultOfT.cs @@ -35,7 +35,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await GetNextResponseAsync(message).ConfigureAwait(false); yield return result; nextPageUri = ((ListWithNextLinkResponse)result).Next; @@ -74,5 +74,12 @@ protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientRe await Task.Yield(); } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResult.cs index e43d87a042a..a4f3f2aca9e 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResult.cs @@ -34,7 +34,7 @@ public override IEnumerable GetRawPages() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = GetNextResponse(message); yield return result; nextPageUri = ((ListWithNextLinkResponse)result).Next; @@ -61,5 +61,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResultOfT.cs index 51e1a2f5494..2384f493d80 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithNextLinkCollectionResultOfT.cs @@ -34,7 +34,7 @@ public override IEnumerable GetRawPages() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = GetNextResponse(message); yield return result; nextPageUri = ((ListWithNextLinkResponse)result).Next; @@ -69,5 +69,12 @@ protected override IEnumerable GetValuesFromPage(ClientResult page) { return ((ListWithNextLinkResponse)page).Things; } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResult.cs index b62bc4e45b0..da4c0c20dc0 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResult.cs @@ -8,6 +8,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; namespace SampleTypeSpec { @@ -30,7 +31,7 @@ public SampleTypeSpecClientGetWithPagingAsyncCollectionResult(SampleTypeSpecClie public override async IAsyncEnumerable GetRawPagesAsync() { PipelineMessage message = _client.CreateGetWithPagingRequest(_options); - yield return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return await GetNextResponseAsync(message).ConfigureAwait(false); } /// Gets the continuation token from the specified page. @@ -40,5 +41,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) { return null; } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT.cs index fa5e727fd26..aa1a1cdf328 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT.cs @@ -31,7 +31,7 @@ public SampleTypeSpecClientGetWithPagingAsyncCollectionResultOfT(SampleTypeSpecC public override async IAsyncEnumerable GetRawPagesAsync() { PipelineMessage message = _client.CreateGetWithPagingRequest(_options); - yield return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return await GetNextResponseAsync(message).ConfigureAwait(false); } /// Gets the continuation token from the specified page. @@ -53,5 +53,12 @@ protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientRe await Task.Yield(); } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResult.cs index 9fb94135cc9..42a964869c8 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResult.cs @@ -30,7 +30,7 @@ public SampleTypeSpecClientGetWithPagingCollectionResult(SampleTypeSpecClient cl public override IEnumerable GetRawPages() { PipelineMessage message = _client.CreateGetWithPagingRequest(_options); - yield return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return GetNextResponse(message); } /// Gets the continuation token from the specified page. @@ -40,5 +40,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) { return null; } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResultOfT.cs index 6031b02f615..fb3d1444543 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithPagingCollectionResultOfT.cs @@ -30,7 +30,7 @@ public SampleTypeSpecClientGetWithPagingCollectionResultOfT(SampleTypeSpecClient public override IEnumerable GetRawPages() { PipelineMessage message = _client.CreateGetWithPagingRequest(_options); - yield return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return GetNextResponse(message); } /// Gets the continuation token from the specified page. @@ -48,5 +48,12 @@ protected override IEnumerable GetValuesFromPage(ClientResult page) { return ((PageThing)page).Items; } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs index 5f2f970edc6..754698b6891 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs @@ -9,6 +9,7 @@ using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Threading.Tasks; namespace SampleTypeSpec { @@ -34,7 +35,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await GetNextResponseAsync(message).ConfigureAwait(false); yield return result; string nextPageString = ((ListWithStringNextLinkResponse)result).Next; @@ -62,5 +63,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs index b8b6c3524a1..b777d15a10a 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs @@ -35,7 +35,7 @@ public override async IAsyncEnumerable GetRawPagesAsync() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + ClientResult result = await GetNextResponseAsync(message).ConfigureAwait(false); yield return result; string nextPageString = ((ListWithStringNextLinkResponse)result).Next; @@ -75,5 +75,12 @@ protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientRe await Task.Yield(); } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private async ValueTask GetNextResponseAsync(PipelineMessage message) + { + return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResult.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResult.cs index 041284bd988..5402f8cac11 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResult.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResult.cs @@ -34,7 +34,7 @@ public override IEnumerable GetRawPages() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = GetNextResponse(message); yield return result; string nextPageString = ((ListWithStringNextLinkResponse)result).Next; @@ -62,5 +62,12 @@ public override ContinuationToken GetContinuationToken(ClientResult page) return null; } } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs index 5d4b31a80f6..3eae436b639 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/CollectionResults/SampleTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs @@ -34,7 +34,7 @@ public override IEnumerable GetRawPages() Uri nextPageUri = null; while (true) { - ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + ClientResult result = GetNextResponse(message); yield return result; string nextPageString = ((ListWithStringNextLinkResponse)result).Next; @@ -70,5 +70,12 @@ protected override IEnumerable GetValuesFromPage(ClientResult page) { return ((ListWithStringNextLinkResponse)page).Things; } + + /// Sends the request in the pipeline message and returns the response. + /// The pipeline message containing the request to send. + private ClientResult GetNextResponse(PipelineMessage message) + { + return ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + } } }