From eb97f3b4e214bcb50b5850eec2123e492d4a0a92 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Thu, 31 Aug 2023 08:34:09 -0700 Subject: [PATCH 1/3] Remove LLPH and update PH --- Directory.Build.targets | 1 - eng/DownloadSharedSource.ps1 | 1 - .../LowLevelPageableHelpers.cs | 11 ----- .../Azure.Core.Shared/PageableHelpers.cs | 40 ------------------- 4 files changed, 53 deletions(-) delete mode 100644 src/assets/Azure.Core.Shared/LowLevelPageableHelpers.cs diff --git a/Directory.Build.targets b/Directory.Build.targets index 2343c750f21..ae07a2cc714 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -33,7 +33,6 @@ - diff --git a/eng/DownloadSharedSource.ps1 b/eng/DownloadSharedSource.ps1 index b3d5f9119c0..8ebd387b1b6 100644 --- a/eng/DownloadSharedSource.ps1 +++ b/eng/DownloadSharedSource.ps1 @@ -46,7 +46,6 @@ $files = @('AsyncLockWithValue.cs', 'ClientDiagnostics.cs', 'DiagnosticScope.cs' 'IUtf8JsonSerializable.cs', 'IXmlSerializable.cs', 'JsonElementExtensions.cs', - 'LowLevelPageableHelpers.cs', 'NextLinkOperationImplementation.cs', 'OperationFinalStateVia.cs', 'Optional.cs', diff --git a/src/assets/Azure.Core.Shared/LowLevelPageableHelpers.cs b/src/assets/Azure.Core.Shared/LowLevelPageableHelpers.cs deleted file mode 100644 index 17f06dc282c..00000000000 --- a/src/assets/Azure.Core.Shared/LowLevelPageableHelpers.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#nullable enable - -namespace Azure.Core -{ - internal static class LowLevelPageableHelpers - { - } -} diff --git a/src/assets/Azure.Core.Shared/PageableHelpers.cs b/src/assets/Azure.Core.Shared/PageableHelpers.cs index 4d15951fef1..edff77b7bc1 100644 --- a/src/assets/Azure.Core.Shared/PageableHelpers.cs +++ b/src/assets/Azure.Core.Shared/PageableHelpers.cs @@ -19,46 +19,6 @@ internal static class PageableHelpers private static readonly byte[] DefaultItemPropertyName = Encoding.UTF8.GetBytes("value"); private static readonly byte[] DefaultNextLinkPropertyName = Encoding.UTF8.GetBytes("nextLink"); - public static AsyncPageable CreateAsyncPageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func? Values, string? NextLink)> responseParser, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, RequestContext? requestContext = null) where T : notnull - { - return new AsyncPageableWrapper(new PageableImplementation(createFirstPageRequest, createNextPageRequest, responseParser, pipeline, clientDiagnostics, scopeName, null, requestContext)); - } - - public static AsyncPageable CreateAsyncPageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, CancellationToken cancellationToken) where T : notnull - { - return new AsyncPageableWrapper(new PageableImplementation(null, createFirstPageRequest, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, cancellationToken, null)); - } - - public static AsyncPageable CreateAsyncPageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, RequestContext? requestContext = null) where T : notnull - { - return new AsyncPageableWrapper(new PageableImplementation(null, createFirstPageRequest, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, requestContext?.CancellationToken, requestContext?.ErrorOptions)); - } - - public static AsyncPageable CreateAsyncPageable(Response initialResponse, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, CancellationToken cancellationToken) where T : notnull - { - return new AsyncPageableWrapper(new PageableImplementation(initialResponse, null, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, cancellationToken, null)); - } - - public static Pageable CreatePageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func? Values, string? NextLink)> responseParser, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, RequestContext? requestContext = null) where T : notnull - { - return new PageableWrapper(new PageableImplementation(createFirstPageRequest, createNextPageRequest, responseParser, pipeline, clientDiagnostics, scopeName, null, requestContext)); - } - - public static Pageable CreatePageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, CancellationToken cancellationToken) where T : notnull - { - return new PageableWrapper(new PageableImplementation(null, createFirstPageRequest, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, cancellationToken, null)); - } - - public static Pageable CreatePageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, RequestContext? requestContext = null) where T : notnull - { - return new PageableWrapper(new PageableImplementation(null, createFirstPageRequest, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, requestContext?.CancellationToken, requestContext?.ErrorOptions)); - } - - public static Pageable CreatePageable(Response initialResponse, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, CancellationToken cancellationToken) where T : notnull - { - return new PageableWrapper(new PageableImplementation(initialResponse, null, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, cancellationToken, null)); - } - public static async ValueTask>> CreateAsyncPageable(WaitUntil waitUntil, HttpMessage message, Func? createNextPageMethod, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, OperationFinalStateVia finalStateVia, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, RequestContext? requestContext = null) where T : notnull { AsyncPageable ResultSelector(Response r) => new AsyncPageableWrapper(new PageableImplementation(r, null, createNextPageMethod, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, requestContext?.CancellationToken, requestContext?.ErrorOptions)); From 4553f81d183d434fe78170722b956fb42ef5e53d Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Thu, 31 Aug 2023 08:45:50 -0700 Subject: [PATCH 2/3] update --- .../dpg-customization/src/Customization/DPGClient.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/TestServerProjectsLowLevel/dpg-customization/src/Customization/DPGClient.cs b/test/TestServerProjectsLowLevel/dpg-customization/src/Customization/DPGClient.cs index 9a6d877ef81..fe0ff718fc9 100644 --- a/test/TestServerProjectsLowLevel/dpg-customization/src/Customization/DPGClient.cs +++ b/test/TestServerProjectsLowLevel/dpg-customization/src/Customization/DPGClient.cs @@ -6,6 +6,7 @@ using System; using System.Threading; using System.Threading.Tasks; +using Autorest.CSharp.Core; using Azure; using Azure.Core; using dpg_customization_LowLevel.Models; @@ -141,7 +142,7 @@ public virtual AsyncPageable GetPageValuesAsync(string mode, Cancellati Argument.AssertNotNull(mode, nameof(mode)); var requestContext = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : default; - return PageableHelpers.CreateAsyncPageable + return GeneratorPageableHelpers.CreateAsyncPageable ( _ => CreateGetPagesRequest(mode, requestContext), (_, nextLink) => CreateGetPagesNextPageRequest(nextLink, mode, requestContext), @@ -164,7 +165,7 @@ public virtual Pageable GetPageValues(string mode, CancellationToken ca Argument.AssertNotNull(mode, nameof(mode)); var requestContext = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : default; - return PageableHelpers.CreatePageable + return GeneratorPageableHelpers.CreatePageable ( _ => CreateGetPagesRequest(mode, requestContext), (_, nextLink) => CreateGetPagesNextPageRequest(nextLink, mode, requestContext), From 0ff74ee2bb1c5cd62a204debac4f38c71862c59a Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Fri, 1 Sep 2023 13:13:22 -0700 Subject: [PATCH 3/3] Revert PageableHelpers --- .../Azure.Core.Shared/PageableHelpers.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/assets/Azure.Core.Shared/PageableHelpers.cs b/src/assets/Azure.Core.Shared/PageableHelpers.cs index edff77b7bc1..4d15951fef1 100644 --- a/src/assets/Azure.Core.Shared/PageableHelpers.cs +++ b/src/assets/Azure.Core.Shared/PageableHelpers.cs @@ -19,6 +19,46 @@ internal static class PageableHelpers private static readonly byte[] DefaultItemPropertyName = Encoding.UTF8.GetBytes("value"); private static readonly byte[] DefaultNextLinkPropertyName = Encoding.UTF8.GetBytes("nextLink"); + public static AsyncPageable CreateAsyncPageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func? Values, string? NextLink)> responseParser, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, RequestContext? requestContext = null) where T : notnull + { + return new AsyncPageableWrapper(new PageableImplementation(createFirstPageRequest, createNextPageRequest, responseParser, pipeline, clientDiagnostics, scopeName, null, requestContext)); + } + + public static AsyncPageable CreateAsyncPageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, CancellationToken cancellationToken) where T : notnull + { + return new AsyncPageableWrapper(new PageableImplementation(null, createFirstPageRequest, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, cancellationToken, null)); + } + + public static AsyncPageable CreateAsyncPageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, RequestContext? requestContext = null) where T : notnull + { + return new AsyncPageableWrapper(new PageableImplementation(null, createFirstPageRequest, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, requestContext?.CancellationToken, requestContext?.ErrorOptions)); + } + + public static AsyncPageable CreateAsyncPageable(Response initialResponse, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, CancellationToken cancellationToken) where T : notnull + { + return new AsyncPageableWrapper(new PageableImplementation(initialResponse, null, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, cancellationToken, null)); + } + + public static Pageable CreatePageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func? Values, string? NextLink)> responseParser, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, RequestContext? requestContext = null) where T : notnull + { + return new PageableWrapper(new PageableImplementation(createFirstPageRequest, createNextPageRequest, responseParser, pipeline, clientDiagnostics, scopeName, null, requestContext)); + } + + public static Pageable CreatePageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, CancellationToken cancellationToken) where T : notnull + { + return new PageableWrapper(new PageableImplementation(null, createFirstPageRequest, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, cancellationToken, null)); + } + + public static Pageable CreatePageable(Func? createFirstPageRequest, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, RequestContext? requestContext = null) where T : notnull + { + return new PageableWrapper(new PageableImplementation(null, createFirstPageRequest, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, requestContext?.CancellationToken, requestContext?.ErrorOptions)); + } + + public static Pageable CreatePageable(Response initialResponse, Func? createNextPageRequest, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, CancellationToken cancellationToken) where T : notnull + { + return new PageableWrapper(new PageableImplementation(initialResponse, null, createNextPageRequest, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, cancellationToken, null)); + } + public static async ValueTask>> CreateAsyncPageable(WaitUntil waitUntil, HttpMessage message, Func? createNextPageMethod, Func valueFactory, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, OperationFinalStateVia finalStateVia, string scopeName, string? itemPropertyName, string? nextLinkPropertyName, RequestContext? requestContext = null) where T : notnull { AsyncPageable ResultSelector(Response r) => new AsyncPageableWrapper(new PageableImplementation(r, null, createNextPageMethod, valueFactory, pipeline, clientDiagnostics, scopeName, itemPropertyName, nextLinkPropertyName, null, requestContext?.CancellationToken, requestContext?.ErrorOptions));