From 0ca32ce5937793e22bc63cd53194790abe6ae762 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Wed, 22 May 2024 15:39:54 -0700 Subject: [PATCH 01/10] Add LRO abstractions --- .../api/System.ClientModel.net6.0.cs | 26 +++++++++++++ .../api/System.ClientModel.netstandard2.0.cs | 26 +++++++++++++ .../src/Convenience/ClientOperation.cs | 38 +++++++++++++++++++ .../src/Convenience/ClientOperationOfT.cs | 26 +++++++++++++ .../src/Convenience/ReturnWhen.cs | 16 ++++++++ .../TestFramework/Mocks/MockLroClient.cs | 22 +++++++++++ 6 files changed, 154 insertions(+) create mode 100644 sdk/core/System.ClientModel/src/Convenience/ClientOperation.cs create mode 100644 sdk/core/System.ClientModel/src/Convenience/ClientOperationOfT.cs create mode 100644 sdk/core/System.ClientModel/src/Convenience/ReturnWhen.cs create mode 100644 sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index 53cdd65eb9a9..3ea16f02c69f 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -30,6 +30,27 @@ protected BinaryContent() { } public abstract void WriteTo(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.Task WriteToAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } + public abstract partial class ClientOperation : System.ClientModel.ClientResult + { + protected ClientOperation(string id) { } + public bool HasCompleted { get { throw null; } protected set { } } + public string Id { get { throw null; } } + public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + } + public abstract partial class ClientOperation : System.ClientModel.ClientOperation + { + protected ClientOperation(string id) : base (default(string)) { } + public T? Value { get { throw null; } protected set { } } + public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + } public partial class ClientResult { protected ClientResult() { } @@ -74,6 +95,11 @@ internal ResultPage() { } public static System.ClientModel.ResultPage Create(System.Collections.Generic.IEnumerable values, string? continuationToken, System.ClientModel.Primitives.PipelineResponse response) { throw null; } public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } } + public enum ReturnWhen + { + Started = 0, + Completed = 1, + } } namespace System.ClientModel.Primitives { diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index e43b75c72c1e..db7f3feb64c2 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -30,6 +30,27 @@ protected BinaryContent() { } public abstract void WriteTo(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.Task WriteToAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } + public abstract partial class ClientOperation : System.ClientModel.ClientResult + { + protected ClientOperation(string id) { } + public bool HasCompleted { get { throw null; } protected set { } } + public string Id { get { throw null; } } + public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + } + public abstract partial class ClientOperation : System.ClientModel.ClientOperation + { + protected ClientOperation(string id) : base (default(string)) { } + public T? Value { get { throw null; } protected set { } } + public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + } public partial class ClientResult { protected ClientResult() { } @@ -74,6 +95,11 @@ internal ResultPage() { } public static System.ClientModel.ResultPage Create(System.Collections.Generic.IEnumerable values, string? continuationToken, System.ClientModel.Primitives.PipelineResponse response) { throw null; } public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } } + public enum ReturnWhen + { + Started = 0, + Completed = 1, + } } namespace System.ClientModel.Primitives { diff --git a/sdk/core/System.ClientModel/src/Convenience/ClientOperation.cs b/sdk/core/System.ClientModel/src/Convenience/ClientOperation.cs new file mode 100644 index 000000000000..ea02436c06a5 --- /dev/null +++ b/sdk/core/System.ClientModel/src/Convenience/ClientOperation.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace System.ClientModel; + +#pragma warning disable CS1591 // public XML comments +public abstract class ClientOperation : ClientResult +{ + protected ClientOperation(string id) + { + Id = id; + } + + public string Id { get; } + + public bool HasCompleted { get; protected set; } + + public abstract ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default); + + public abstract PipelineResponse UpdateStatus(CancellationToken cancellationToken = default); + + // TODO: what is the use case for these? How do they differ from GetRawResponse() ? + public abstract ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default); + + public abstract PipelineResponse WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default); + + public abstract ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default); + + public abstract PipelineResponse WaitForCompletionResponse(CancellationToken cancellationToken = default); + + // TODO: should these be virtual with an internal poller implementation? + // TODO: should we have something like DelayStrategy? +} +#pragma warning restore CS1591 // public XML comments diff --git a/sdk/core/System.ClientModel/src/Convenience/ClientOperationOfT.cs b/sdk/core/System.ClientModel/src/Convenience/ClientOperationOfT.cs new file mode 100644 index 000000000000..c05ae73a26cc --- /dev/null +++ b/sdk/core/System.ClientModel/src/Convenience/ClientOperationOfT.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Threading; +using System.Threading.Tasks; + +namespace System.ClientModel; + +#pragma warning disable CS1591 // public XML comments +public abstract class ClientOperation : ClientOperation +{ + protected ClientOperation(string id) : base(id) + { + } + + public T? Value { get; protected set; } + + public abstract Task> WaitForCompletionAsync(CancellationToken cancellationToken = default); + + public abstract ClientResult WaitForCompletion(CancellationToken cancellationToken = default); + + public abstract Task> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken); + + public abstract ClientResult WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken); +} +#pragma warning restore CS1591 // public XML comments diff --git a/sdk/core/System.ClientModel/src/Convenience/ReturnWhen.cs b/sdk/core/System.ClientModel/src/Convenience/ReturnWhen.cs new file mode 100644 index 000000000000..ce8133f55be3 --- /dev/null +++ b/sdk/core/System.ClientModel/src/Convenience/ReturnWhen.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; + +namespace System.ClientModel; + +#pragma warning disable CS1591 // public XML comments +public enum ReturnWhen +{ + Started, + Completed +} +#pragma warning restore CS1591 // public XML comments diff --git a/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs b/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs new file mode 100644 index 000000000000..ad096b634b97 --- /dev/null +++ b/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using Azure.Core.TestFramework; + +namespace ClientModel.Tests.Mocks; + +public class MockLroClient +{ + public virtual ClientOperation GetModelLater(ReturnWhen returnWhen, string content) + { + throw new NotImplementedException(); + } + + public virtual ClientResult GetModelLater(string content, RequestOptions? options = default) + { + throw new NotImplementedException(); + } +} From cece50339201837404b53da3335e75c64c4214ec Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Wed, 22 May 2024 17:19:29 -0700 Subject: [PATCH 02/10] renames --- .../api/System.ClientModel.net6.0.cs | 42 +++++++++---------- .../api/System.ClientModel.netstandard2.0.cs | 42 +++++++++---------- .../{ClientOperation.cs => PollableResult.cs} | 6 +-- ...ntOperationOfT.cs => PollableResultOfT.cs} | 4 +- .../TestFramework/Mocks/MockLroClient.cs | 2 +- 5 files changed, 48 insertions(+), 48 deletions(-) rename sdk/core/System.ClientModel/src/Convenience/{ClientOperation.cs => PollableResult.cs} (91%) rename sdk/core/System.ClientModel/src/Convenience/{ClientOperationOfT.cs => PollableResultOfT.cs} (88%) diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index 3ea16f02c69f..3abea700ef93 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -30,27 +30,6 @@ protected BinaryContent() { } public abstract void WriteTo(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.Task WriteToAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } - public abstract partial class ClientOperation : System.ClientModel.ClientResult - { - protected ClientOperation(string id) { } - public bool HasCompleted { get { throw null; } protected set { } } - public string Id { get { throw null; } } - public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - } - public abstract partial class ClientOperation : System.ClientModel.ClientOperation - { - protected ClientOperation(string id) : base (default(string)) { } - public T? Value { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); - } public partial class ClientResult { protected ClientResult() { } @@ -81,6 +60,27 @@ protected PageableCollection() { } public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } } + public abstract partial class PollableResult : System.ClientModel.ClientResult + { + protected PollableResult(string id) { } + public bool HasCompleted { get { throw null; } protected set { } } + public string Id { get { throw null; } protected set { } } + public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + } + public abstract partial class PollableResult : System.ClientModel.PollableResult + { + protected PollableResult(string id) : base (default(string)) { } + public T? Value { get { throw null; } protected set { } } + public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + } public abstract partial class ResultCollection : System.ClientModel.ClientResult, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected internal ResultCollection() { } diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index db7f3feb64c2..0f0e0c66e7da 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -30,27 +30,6 @@ protected BinaryContent() { } public abstract void WriteTo(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.Task WriteToAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } - public abstract partial class ClientOperation : System.ClientModel.ClientResult - { - protected ClientOperation(string id) { } - public bool HasCompleted { get { throw null; } protected set { } } - public string Id { get { throw null; } } - public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - } - public abstract partial class ClientOperation : System.ClientModel.ClientOperation - { - protected ClientOperation(string id) : base (default(string)) { } - public T? Value { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); - } public partial class ClientResult { protected ClientResult() { } @@ -81,6 +60,27 @@ protected PageableCollection() { } public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } } + public abstract partial class PollableResult : System.ClientModel.ClientResult + { + protected PollableResult(string id) { } + public bool HasCompleted { get { throw null; } protected set { } } + public string Id { get { throw null; } protected set { } } + public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + } + public abstract partial class PollableResult : System.ClientModel.PollableResult + { + protected PollableResult(string id) : base (default(string)) { } + public T? Value { get { throw null; } protected set { } } + public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + } public abstract partial class ResultCollection : System.ClientModel.ClientResult, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected internal ResultCollection() { } diff --git a/sdk/core/System.ClientModel/src/Convenience/ClientOperation.cs b/sdk/core/System.ClientModel/src/Convenience/PollableResult.cs similarity index 91% rename from sdk/core/System.ClientModel/src/Convenience/ClientOperation.cs rename to sdk/core/System.ClientModel/src/Convenience/PollableResult.cs index ea02436c06a5..9cf8dc6eacc9 100644 --- a/sdk/core/System.ClientModel/src/Convenience/ClientOperation.cs +++ b/sdk/core/System.ClientModel/src/Convenience/PollableResult.cs @@ -8,14 +8,14 @@ namespace System.ClientModel; #pragma warning disable CS1591 // public XML comments -public abstract class ClientOperation : ClientResult +public abstract class PollableResult : ClientResult { - protected ClientOperation(string id) + protected PollableResult(string id) { Id = id; } - public string Id { get; } + public string Id { get; protected set; } public bool HasCompleted { get; protected set; } diff --git a/sdk/core/System.ClientModel/src/Convenience/ClientOperationOfT.cs b/sdk/core/System.ClientModel/src/Convenience/PollableResultOfT.cs similarity index 88% rename from sdk/core/System.ClientModel/src/Convenience/ClientOperationOfT.cs rename to sdk/core/System.ClientModel/src/Convenience/PollableResultOfT.cs index c05ae73a26cc..951370ed2f5c 100644 --- a/sdk/core/System.ClientModel/src/Convenience/ClientOperationOfT.cs +++ b/sdk/core/System.ClientModel/src/Convenience/PollableResultOfT.cs @@ -7,9 +7,9 @@ namespace System.ClientModel; #pragma warning disable CS1591 // public XML comments -public abstract class ClientOperation : ClientOperation +public abstract class PollableResult : PollableResult { - protected ClientOperation(string id) : base(id) + protected PollableResult(string id) : base(id) { } diff --git a/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs b/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs index ad096b634b97..0bd819dd8047 100644 --- a/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs +++ b/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs @@ -10,7 +10,7 @@ namespace ClientModel.Tests.Mocks; public class MockLroClient { - public virtual ClientOperation GetModelLater(ReturnWhen returnWhen, string content) + public virtual PollableResult GetModelLater(ReturnWhen returnWhen, string content) { throw new NotImplementedException(); } From e2b55c15f8b7604d2fa0f851b7e843f84365e70a Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Thu, 23 May 2024 09:06:16 -0700 Subject: [PATCH 03/10] rename and add response --- .../api/System.ClientModel.net6.0.cs | 20 +++++++++---------- .../api/System.ClientModel.netstandard2.0.cs | 20 +++++++++---------- .../{PollableResult.cs => FutureResult.cs} | 4 ++-- ...ollableResultOfT.cs => FutureResultOfT.cs} | 5 +++-- .../TestFramework/Mocks/MockLroClient.cs | 2 +- 5 files changed, 26 insertions(+), 25 deletions(-) rename sdk/core/System.ClientModel/src/Convenience/{PollableResult.cs => FutureResult.cs} (91%) rename sdk/core/System.ClientModel/src/Convenience/{PollableResultOfT.cs => FutureResultOfT.cs} (82%) diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index 3abea700ef93..5640b69fb50f 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -54,15 +54,9 @@ protected internal ClientResult(T value, System.ClientModel.Primitives.PipelineR public virtual T Value { get { throw null; } } public static implicit operator T (System.ClientModel.ClientResult result) { throw null; } } - public abstract partial class PageableCollection : System.ClientModel.ResultCollection - { - protected PageableCollection() { } - public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); - public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } - } - public abstract partial class PollableResult : System.ClientModel.ClientResult + public abstract partial class FutureResult : System.ClientModel.ClientResult { - protected PollableResult(string id) { } + protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse response) { } public bool HasCompleted { get { throw null; } protected set { } } public string Id { get { throw null; } protected set { } } public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); @@ -72,15 +66,21 @@ protected PollableResult(string id) { } public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } - public abstract partial class PollableResult : System.ClientModel.PollableResult + public abstract partial class FutureResult : System.ClientModel.FutureResult { - protected PollableResult(string id) : base (default(string)) { } + protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); } + public abstract partial class PageableCollection : System.ClientModel.ResultCollection + { + protected PageableCollection() { } + public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); + public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + } public abstract partial class ResultCollection : System.ClientModel.ClientResult, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected internal ResultCollection() { } diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index 0f0e0c66e7da..f63dfcdde943 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -54,15 +54,9 @@ protected internal ClientResult(T value, System.ClientModel.Primitives.PipelineR public virtual T Value { get { throw null; } } public static implicit operator T (System.ClientModel.ClientResult result) { throw null; } } - public abstract partial class PageableCollection : System.ClientModel.ResultCollection - { - protected PageableCollection() { } - public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); - public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } - } - public abstract partial class PollableResult : System.ClientModel.ClientResult + public abstract partial class FutureResult : System.ClientModel.ClientResult { - protected PollableResult(string id) { } + protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse response) { } public bool HasCompleted { get { throw null; } protected set { } } public string Id { get { throw null; } protected set { } } public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); @@ -72,15 +66,21 @@ protected PollableResult(string id) { } public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } - public abstract partial class PollableResult : System.ClientModel.PollableResult + public abstract partial class FutureResult : System.ClientModel.FutureResult { - protected PollableResult(string id) : base (default(string)) { } + protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); } + public abstract partial class PageableCollection : System.ClientModel.ResultCollection + { + protected PageableCollection() { } + public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); + public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + } public abstract partial class ResultCollection : System.ClientModel.ClientResult, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected internal ResultCollection() { } diff --git a/sdk/core/System.ClientModel/src/Convenience/PollableResult.cs b/sdk/core/System.ClientModel/src/Convenience/FutureResult.cs similarity index 91% rename from sdk/core/System.ClientModel/src/Convenience/PollableResult.cs rename to sdk/core/System.ClientModel/src/Convenience/FutureResult.cs index 9cf8dc6eacc9..91e1cf575f18 100644 --- a/sdk/core/System.ClientModel/src/Convenience/PollableResult.cs +++ b/sdk/core/System.ClientModel/src/Convenience/FutureResult.cs @@ -8,9 +8,9 @@ namespace System.ClientModel; #pragma warning disable CS1591 // public XML comments -public abstract class PollableResult : ClientResult +public abstract class FutureResult : ClientResult { - protected PollableResult(string id) + protected FutureResult(string id, PipelineResponse response) : base(response) { Id = id; } diff --git a/sdk/core/System.ClientModel/src/Convenience/PollableResultOfT.cs b/sdk/core/System.ClientModel/src/Convenience/FutureResultOfT.cs similarity index 82% rename from sdk/core/System.ClientModel/src/Convenience/PollableResultOfT.cs rename to sdk/core/System.ClientModel/src/Convenience/FutureResultOfT.cs index 951370ed2f5c..84e0f811d265 100644 --- a/sdk/core/System.ClientModel/src/Convenience/PollableResultOfT.cs +++ b/sdk/core/System.ClientModel/src/Convenience/FutureResultOfT.cs @@ -1,15 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System.ClientModel.Primitives; using System.Threading; using System.Threading.Tasks; namespace System.ClientModel; #pragma warning disable CS1591 // public XML comments -public abstract class PollableResult : PollableResult +public abstract class FutureResult : FutureResult { - protected PollableResult(string id) : base(id) + protected FutureResult(string id, PipelineResponse response) : base(id, response) { } diff --git a/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs b/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs index 0bd819dd8047..a9aecebd0dec 100644 --- a/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs +++ b/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs @@ -10,7 +10,7 @@ namespace ClientModel.Tests.Mocks; public class MockLroClient { - public virtual PollableResult GetModelLater(ReturnWhen returnWhen, string content) + public virtual FutureResult GetModelLater(ReturnWhen returnWhen, string content) { throw new NotImplementedException(); } From e2ae9783dca7df9ef05540d03af82539d2ff5f72 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Thu, 23 May 2024 09:26:17 -0700 Subject: [PATCH 04/10] rename to ResultOperation --- .../api/System.ClientModel.net6.0.cs | 34 +++++++++---------- .../api/System.ClientModel.netstandard2.0.cs | 34 +++++++++---------- .../{FutureResult.cs => ResultOperation.cs} | 4 +-- ...tureResultOfT.cs => ResultOperationOfT.cs} | 4 +-- .../TestFramework/Mocks/MockLroClient.cs | 2 +- 5 files changed, 39 insertions(+), 39 deletions(-) rename sdk/core/System.ClientModel/src/Convenience/{FutureResult.cs => ResultOperation.cs} (91%) rename sdk/core/System.ClientModel/src/Convenience/{FutureResultOfT.cs => ResultOperationOfT.cs} (85%) diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index 5640b69fb50f..edfced6c91db 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -54,9 +54,22 @@ protected internal ClientResult(T value, System.ClientModel.Primitives.PipelineR public virtual T Value { get { throw null; } } public static implicit operator T (System.ClientModel.ClientResult result) { throw null; } } - public abstract partial class FutureResult : System.ClientModel.ClientResult + public abstract partial class PageableCollection : System.ClientModel.ResultCollection + { + protected PageableCollection() { } + public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); + public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + } + public abstract partial class ResultCollection : System.ClientModel.ClientResult, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected internal ResultCollection() { } + protected internal ResultCollection(System.ClientModel.Primitives.PipelineResponse response) { } + public abstract System.Collections.Generic.IEnumerator GetEnumerator(); + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public abstract partial class ResultOperation : System.ClientModel.ClientResult { - protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse response) { } + protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) { } public bool HasCompleted { get { throw null; } protected set { } } public string Id { get { throw null; } protected set { } } public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); @@ -66,28 +79,15 @@ protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } - public abstract partial class FutureResult : System.ClientModel.FutureResult + public abstract partial class ResultOperation : System.ClientModel.ResultOperation { - protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } + protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); } - public abstract partial class PageableCollection : System.ClientModel.ResultCollection - { - protected PageableCollection() { } - public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); - public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } - } - public abstract partial class ResultCollection : System.ClientModel.ClientResult, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable - { - protected internal ResultCollection() { } - protected internal ResultCollection(System.ClientModel.Primitives.PipelineResponse response) { } - public abstract System.Collections.Generic.IEnumerator GetEnumerator(); - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - } public partial class ResultPage : System.ClientModel.ResultCollection { internal ResultPage() { } diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index f63dfcdde943..38dd9756e612 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -54,9 +54,22 @@ protected internal ClientResult(T value, System.ClientModel.Primitives.PipelineR public virtual T Value { get { throw null; } } public static implicit operator T (System.ClientModel.ClientResult result) { throw null; } } - public abstract partial class FutureResult : System.ClientModel.ClientResult + public abstract partial class PageableCollection : System.ClientModel.ResultCollection + { + protected PageableCollection() { } + public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); + public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + } + public abstract partial class ResultCollection : System.ClientModel.ClientResult, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected internal ResultCollection() { } + protected internal ResultCollection(System.ClientModel.Primitives.PipelineResponse response) { } + public abstract System.Collections.Generic.IEnumerator GetEnumerator(); + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public abstract partial class ResultOperation : System.ClientModel.ClientResult { - protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse response) { } + protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) { } public bool HasCompleted { get { throw null; } protected set { } } public string Id { get { throw null; } protected set { } } public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); @@ -66,28 +79,15 @@ protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } - public abstract partial class FutureResult : System.ClientModel.FutureResult + public abstract partial class ResultOperation : System.ClientModel.ResultOperation { - protected FutureResult(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } + protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); } - public abstract partial class PageableCollection : System.ClientModel.ResultCollection - { - protected PageableCollection() { } - public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); - public override System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } - } - public abstract partial class ResultCollection : System.ClientModel.ClientResult, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable - { - protected internal ResultCollection() { } - protected internal ResultCollection(System.ClientModel.Primitives.PipelineResponse response) { } - public abstract System.Collections.Generic.IEnumerator GetEnumerator(); - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - } public partial class ResultPage : System.ClientModel.ResultCollection { internal ResultPage() { } diff --git a/sdk/core/System.ClientModel/src/Convenience/FutureResult.cs b/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs similarity index 91% rename from sdk/core/System.ClientModel/src/Convenience/FutureResult.cs rename to sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs index 91e1cf575f18..dafffe0990f9 100644 --- a/sdk/core/System.ClientModel/src/Convenience/FutureResult.cs +++ b/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs @@ -8,9 +8,9 @@ namespace System.ClientModel; #pragma warning disable CS1591 // public XML comments -public abstract class FutureResult : ClientResult +public abstract class ResultOperation : ClientResult { - protected FutureResult(string id, PipelineResponse response) : base(response) + protected ResultOperation(string id, PipelineResponse response) : base(response) { Id = id; } diff --git a/sdk/core/System.ClientModel/src/Convenience/FutureResultOfT.cs b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs similarity index 85% rename from sdk/core/System.ClientModel/src/Convenience/FutureResultOfT.cs rename to sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs index 84e0f811d265..3a251251b6bb 100644 --- a/sdk/core/System.ClientModel/src/Convenience/FutureResultOfT.cs +++ b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs @@ -8,9 +8,9 @@ namespace System.ClientModel; #pragma warning disable CS1591 // public XML comments -public abstract class FutureResult : FutureResult +public abstract class ResultOperation : ResultOperation { - protected FutureResult(string id, PipelineResponse response) : base(id, response) + protected ResultOperation(string id, PipelineResponse response) : base(id, response) { } diff --git a/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs b/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs index a9aecebd0dec..385f8564723a 100644 --- a/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs +++ b/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockLroClient.cs @@ -10,7 +10,7 @@ namespace ClientModel.Tests.Mocks; public class MockLroClient { - public virtual FutureResult GetModelLater(ReturnWhen returnWhen, string content) + public virtual ResultOperation GetModelLater(ReturnWhen returnWhen, string content) { throw new NotImplementedException(); } From 4288e930d604557b2005faec7e727128269632d7 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Thu, 23 May 2024 10:17:32 -0700 Subject: [PATCH 05/10] change to WaitForCompletionResult --- .../api/System.ClientModel.net6.0.cs | 20 +++++++++---------- .../api/System.ClientModel.netstandard2.0.cs | 20 +++++++++---------- .../src/Convenience/ResultOperation.cs | 16 +++++++++------ .../src/Convenience/ResultOperationOfT.cs | 8 ++++---- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index edfced6c91db..730ef46e8ecc 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -72,21 +72,21 @@ public abstract partial class ResultOperation : System.ClientModel.ClientResult protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) { } public bool HasCompleted { get { throw null; } protected set { } } public string Id { get { throw null; } protected set { } } - public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult UpdateStatus(); + public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(); + public abstract System.ClientModel.ClientResult WaitForCompletionResult(); + public abstract System.ClientModel.ClientResult WaitForCompletionResult(System.TimeSpan pollingInterval); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(System.TimeSpan pollingInterval); } public abstract partial class ResultOperation : System.ClientModel.ResultOperation { protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + public abstract System.ClientModel.ClientResult WaitForCompletion(); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval); } public partial class ResultPage : System.ClientModel.ResultCollection { diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index 38dd9756e612..18bc4f93eff4 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -72,21 +72,21 @@ public abstract partial class ResultOperation : System.ClientModel.ClientResult protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) { } public bool HasCompleted { get { throw null; } protected set { } } public string Id { get { throw null; } protected set { } } - public abstract System.ClientModel.Primitives.PipelineResponse UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.Primitives.PipelineResponse WaitForCompletionResponse(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult UpdateStatus(); + public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(); + public abstract System.ClientModel.ClientResult WaitForCompletionResult(); + public abstract System.ClientModel.ClientResult WaitForCompletionResult(System.TimeSpan pollingInterval); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(System.TimeSpan pollingInterval); } public abstract partial class ResultOperation : System.ClientModel.ResultOperation { protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken); + public abstract System.ClientModel.ClientResult WaitForCompletion(); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval); } public partial class ResultPage : System.ClientModel.ResultCollection { diff --git a/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs b/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs index dafffe0990f9..fb3ce9082741 100644 --- a/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs +++ b/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs @@ -19,18 +19,22 @@ protected ResultOperation(string id, PipelineResponse response) : base(response) public bool HasCompleted { get; protected set; } - public abstract ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default); + // TODO: Should we take a cancellationToken, since third-party convenience methods don't? + // TODO: Should we take a RequestOptions? + // i.e. Is the non-T version of this for protocol-level, or only for operations that + // don't have an output value? + public abstract ValueTask UpdateStatusAsync(); - public abstract PipelineResponse UpdateStatus(CancellationToken cancellationToken = default); + public abstract ClientResult UpdateStatus(); // TODO: what is the use case for these? How do they differ from GetRawResponse() ? - public abstract ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default); + public abstract ValueTask WaitForCompletionResultAsync(TimeSpan pollingInterval); - public abstract PipelineResponse WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default); + public abstract ClientResult WaitForCompletionResult(TimeSpan pollingInterval); - public abstract ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default); + public abstract ValueTask WaitForCompletionResultAsync(); - public abstract PipelineResponse WaitForCompletionResponse(CancellationToken cancellationToken = default); + public abstract ClientResult WaitForCompletionResult(); // TODO: should these be virtual with an internal poller implementation? // TODO: should we have something like DelayStrategy? diff --git a/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs index 3a251251b6bb..8e72ec9eb083 100644 --- a/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs +++ b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs @@ -16,12 +16,12 @@ protected ResultOperation(string id, PipelineResponse response) : base(id, respo public T? Value { get; protected set; } - public abstract Task> WaitForCompletionAsync(CancellationToken cancellationToken = default); + public abstract Task> WaitForCompletionAsync(); - public abstract ClientResult WaitForCompletion(CancellationToken cancellationToken = default); + public abstract ClientResult WaitForCompletion(); - public abstract Task> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken); + public abstract Task> WaitForCompletionAsync(TimeSpan pollingInterval); - public abstract ClientResult WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken); + public abstract ClientResult WaitForCompletion(TimeSpan pollingInterval); } #pragma warning restore CS1591 // public XML comments From c14cfbd7024e40fe83cd21f97db8c735f101f449 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Thu, 23 May 2024 10:30:33 -0700 Subject: [PATCH 06/10] Add CancellationTokens back for Wait operations --- .../api/System.ClientModel.net6.0.cs | 16 ++++++++-------- .../api/System.ClientModel.netstandard2.0.cs | 16 ++++++++-------- .../src/Convenience/ResultOperation.cs | 8 ++++---- .../src/Convenience/ResultOperationOfT.cs | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index 730ef46e8ecc..b41bdd6e5710 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -74,19 +74,19 @@ protected ResultOperation(string id, System.ClientModel.Primitives.PipelineRespo public string Id { get { throw null; } protected set { } } public abstract System.ClientModel.ClientResult UpdateStatus(); public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(); - public abstract System.ClientModel.ClientResult WaitForCompletionResult(); - public abstract System.ClientModel.ClientResult WaitForCompletionResult(System.TimeSpan pollingInterval); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(System.TimeSpan pollingInterval); + public abstract System.ClientModel.ClientResult WaitForCompletionResult(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletionResult(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public abstract partial class ResultOperation : System.ClientModel.ResultOperation { protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult WaitForCompletion(); - public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public partial class ResultPage : System.ClientModel.ResultCollection { diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index 18bc4f93eff4..884001cdc0ba 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -74,19 +74,19 @@ protected ResultOperation(string id, System.ClientModel.Primitives.PipelineRespo public string Id { get { throw null; } protected set { } } public abstract System.ClientModel.ClientResult UpdateStatus(); public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(); - public abstract System.ClientModel.ClientResult WaitForCompletionResult(); - public abstract System.ClientModel.ClientResult WaitForCompletionResult(System.TimeSpan pollingInterval); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(); - public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(System.TimeSpan pollingInterval); + public abstract System.ClientModel.ClientResult WaitForCompletionResult(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletionResult(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask WaitForCompletionResultAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public abstract partial class ResultOperation : System.ClientModel.ResultOperation { protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult WaitForCompletion(); - public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public partial class ResultPage : System.ClientModel.ResultCollection { diff --git a/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs b/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs index fb3ce9082741..4a6047beb391 100644 --- a/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs +++ b/sdk/core/System.ClientModel/src/Convenience/ResultOperation.cs @@ -28,13 +28,13 @@ protected ResultOperation(string id, PipelineResponse response) : base(response) public abstract ClientResult UpdateStatus(); // TODO: what is the use case for these? How do they differ from GetRawResponse() ? - public abstract ValueTask WaitForCompletionResultAsync(TimeSpan pollingInterval); + public abstract ValueTask WaitForCompletionResultAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default); - public abstract ClientResult WaitForCompletionResult(TimeSpan pollingInterval); + public abstract ClientResult WaitForCompletionResult(TimeSpan pollingInterval, CancellationToken cancellationToken = default); - public abstract ValueTask WaitForCompletionResultAsync(); + public abstract ValueTask WaitForCompletionResultAsync(CancellationToken cancellationToken = default); - public abstract ClientResult WaitForCompletionResult(); + public abstract ClientResult WaitForCompletionResult(CancellationToken cancellationToken = default); // TODO: should these be virtual with an internal poller implementation? // TODO: should we have something like DelayStrategy? diff --git a/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs index 8e72ec9eb083..9048ed65afff 100644 --- a/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs +++ b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs @@ -16,12 +16,12 @@ protected ResultOperation(string id, PipelineResponse response) : base(id, respo public T? Value { get; protected set; } - public abstract Task> WaitForCompletionAsync(); + public abstract Task> WaitForCompletionAsync(CancellationToken cancellationToken = default); - public abstract ClientResult WaitForCompletion(); + public abstract ClientResult WaitForCompletion(CancellationToken cancellationToken = default); - public abstract Task> WaitForCompletionAsync(TimeSpan pollingInterval); + public abstract Task> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default); - public abstract ClientResult WaitForCompletion(TimeSpan pollingInterval); + public abstract ClientResult WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default); } #pragma warning restore CS1591 // public XML comments From abf738766ec7d4ec7d249e86bd6d3119fceec592 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Thu, 23 May 2024 14:31:12 -0700 Subject: [PATCH 07/10] APIView feedback --- sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs | 4 ++-- .../api/System.ClientModel.netstandard2.0.cs | 4 ++-- .../System.ClientModel/src/Convenience/ResultOperationOfT.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index b41bdd6e5710..7b2b23d32a34 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -85,8 +85,8 @@ public abstract partial class ResultOperation : System.ClientModel.ResultOper public T? Value { get { throw null; } protected set { } } public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public partial class ResultPage : System.ClientModel.ResultCollection { diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index 884001cdc0ba..b47c69ed60b3 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -85,8 +85,8 @@ public abstract partial class ResultOperation : System.ClientModel.ResultOper public T? Value { get { throw null; } protected set { } } public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.Task> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public partial class ResultPage : System.ClientModel.ResultCollection { diff --git a/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs index 9048ed65afff..99d9e3817d40 100644 --- a/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs +++ b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs @@ -16,11 +16,11 @@ protected ResultOperation(string id, PipelineResponse response) : base(id, respo public T? Value { get; protected set; } - public abstract Task> WaitForCompletionAsync(CancellationToken cancellationToken = default); + public abstract ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default); public abstract ClientResult WaitForCompletion(CancellationToken cancellationToken = default); - public abstract Task> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default); + public abstract ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default); public abstract ClientResult WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default); } From 85008f9cd40e3a89fa874707fecf9cef32f15285 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Fri, 24 May 2024 14:29:47 -0700 Subject: [PATCH 08/10] Initial draft of subtype of ResultOperation to add status functionality --- .../api/System.ClientModel.net6.0.cs | 7 ++++++ .../api/System.ClientModel.netstandard2.0.cs | 7 ++++++ .../src/Convenience/StatusBasedOperation.cs | 24 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index 7b2b23d32a34..c6a7126c5185 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -100,6 +100,13 @@ public enum ReturnWhen Started = 0, Completed = 1, } + public abstract partial class StatusBasedOperation : System.ClientModel.ResultOperation + { + protected StatusBasedOperation(string id, TStatus status, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } + public TStatus Status { get { throw null; } protected set { } } + public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + } } namespace System.ClientModel.Primitives { diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index b47c69ed60b3..f557cf4d0f84 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -100,6 +100,13 @@ public enum ReturnWhen Started = 0, Completed = 1, } + public abstract partial class StatusBasedOperation : System.ClientModel.ResultOperation + { + protected StatusBasedOperation(string id, TStatus status, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } + public TStatus Status { get { throw null; } protected set { } } + public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + } } namespace System.ClientModel.Primitives { diff --git a/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs b/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs new file mode 100644 index 000000000000..a705e5ea32f7 --- /dev/null +++ b/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace System.ClientModel; + +#pragma warning disable CS1591 // public XML comments +public abstract class StatusBasedOperation : ResultOperation +{ + protected StatusBasedOperation(string id, TStatus status, PipelineResponse response) : base(id, response) + { + Status = status; + } + + public TStatus Status { get; protected set; } + + public abstract ValueTask> WaitForStatusUpdateAsync(CancellationToken cancellationToken = default); + + public abstract ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(CancellationToken cancellationToken = default); +} +#pragma warning restore CS1591 // public XML comments From 85f9627e986639a1e7f150fbbddccd0847ca7b76 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Fri, 24 May 2024 16:38:24 -0700 Subject: [PATCH 09/10] default the pollingInterval parameter, per APIView suggestion --- .../api/System.ClientModel.net6.0.cs | 10 ++++------ .../api/System.ClientModel.netstandard2.0.cs | 10 ++++------ .../src/Convenience/ResultOperationOfT.cs | 8 ++------ .../src/Convenience/StatusBasedOperation.cs | 4 ++-- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index c6a7126c5185..69306658c9a4 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -83,10 +83,8 @@ public abstract partial class ResultOperation : System.ClientModel.ResultOper { protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public partial class ResultPage : System.ClientModel.ResultCollection { @@ -104,8 +102,8 @@ public abstract partial class StatusBasedOperation : System.Cli { protected StatusBasedOperation(string id, TStatus status, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public TStatus Status { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(TStatus status, System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(TStatus status, System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } } namespace System.ClientModel.Primitives diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index f557cf4d0f84..468fdbb101f9 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -83,10 +83,8 @@ public abstract partial class ResultOperation : System.ClientModel.ResultOper { protected ResultOperation(string id, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public T? Value { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult WaitForCompletion(System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public partial class ResultPage : System.ClientModel.ResultCollection { @@ -104,8 +102,8 @@ public abstract partial class StatusBasedOperation : System.Cli { protected StatusBasedOperation(string id, TStatus status, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public TStatus Status { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(TStatus status, System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(TStatus status, System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } } namespace System.ClientModel.Primitives diff --git a/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs index 99d9e3817d40..44f9de9c91bf 100644 --- a/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs +++ b/sdk/core/System.ClientModel/src/Convenience/ResultOperationOfT.cs @@ -16,12 +16,8 @@ protected ResultOperation(string id, PipelineResponse response) : base(id, respo public T? Value { get; protected set; } - public abstract ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default); + public abstract ValueTask> WaitForCompletionAsync(TimeSpan? pollingInterval =default, CancellationToken cancellationToken = default); - public abstract ClientResult WaitForCompletion(CancellationToken cancellationToken = default); - - public abstract ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default); - - public abstract ClientResult WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default); + public abstract ClientResult WaitForCompletion(TimeSpan? pollingInterval = default, CancellationToken cancellationToken = default); } #pragma warning restore CS1591 // public XML comments diff --git a/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs b/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs index a705e5ea32f7..01c71a7a9d94 100644 --- a/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs +++ b/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs @@ -17,8 +17,8 @@ protected StatusBasedOperation(string id, TStatus status, PipelineResponse respo public TStatus Status { get; protected set; } - public abstract ValueTask> WaitForStatusUpdateAsync(CancellationToken cancellationToken = default); + public abstract ValueTask> WaitForStatusUpdateAsync(TimeSpan? pollingInterval = default, CancellationToken cancellationToken = default); - public abstract ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(CancellationToken cancellationToken = default); + public abstract ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(TimeSpan? pollingInterval = default, CancellationToken cancellationToken = default); } #pragma warning restore CS1591 // public XML comments From dd2b59546fd83d9cf6de60873b668ba10ce00330 Mon Sep 17 00:00:00 2001 From: Anne Thompson Date: Fri, 24 May 2024 17:17:53 -0700 Subject: [PATCH 10/10] Add APIs to Pause and Resume polling --- .../System.ClientModel/api/System.ClientModel.net6.0.cs | 6 ++++-- .../api/System.ClientModel.netstandard2.0.cs | 6 ++++-- .../src/Convenience/StatusBasedOperation.cs | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs index 69306658c9a4..8577ad5115d3 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.net6.0.cs @@ -102,8 +102,10 @@ public abstract partial class StatusBasedOperation : System.Cli { protected StatusBasedOperation(string id, TStatus status, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public TStatus Status { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(TStatus status, System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(TStatus status, System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract void Pause(); + public abstract void Resume(); + public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } } namespace System.ClientModel.Primitives diff --git a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs index 468fdbb101f9..a8060dab2f09 100644 --- a/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs +++ b/sdk/core/System.ClientModel/api/System.ClientModel.netstandard2.0.cs @@ -102,8 +102,10 @@ public abstract partial class StatusBasedOperation : System.Cli { protected StatusBasedOperation(string id, TStatus status, System.ClientModel.Primitives.PipelineResponse response) : base (default(string), default(System.ClientModel.Primitives.PipelineResponse)) { } public TStatus Status { get { throw null; } protected set { } } - public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(TStatus status, System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(TStatus status, System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract void Pause(); + public abstract void Resume(); + public abstract System.ClientModel.ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask> WaitForStatusUpdateAsync(System.TimeSpan? pollingInterval = default(System.TimeSpan?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } } namespace System.ClientModel.Primitives diff --git a/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs b/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs index 01c71a7a9d94..2d047013b35f 100644 --- a/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs +++ b/sdk/core/System.ClientModel/src/Convenience/StatusBasedOperation.cs @@ -20,5 +20,10 @@ protected StatusBasedOperation(string id, TStatus status, PipelineResponse respo public abstract ValueTask> WaitForStatusUpdateAsync(TimeSpan? pollingInterval = default, CancellationToken cancellationToken = default); public abstract ClientResult<(TStatus Status, TValue? Value)> WaitForStatusUpdate(TimeSpan? pollingInterval = default, CancellationToken cancellationToken = default); + + // TODO: Optional APIs to Pause and Resume polling + public abstract void Pause(); + + public abstract void Resume(); } #pragma warning restore CS1591 // public XML comments