mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
042a9d2b2c
* Reorganize plugins per agreed structure (#271) Split the dotnet plugin into domain-specific plugins per discussion in #271: - dotnet: narrowed to common everyday C#/.NET coding tasks - dotnet-diag: perf investigations, debugging, incident analysis - dotnet-data: data access and Entity Framework - dotnet-aspnet, dotnet-wpf, dotnet-winforms, dotnet-maui: scaffolded empty to convey intent for future framework-specific skills Moved skills, tests, and CODEOWNERS entries accordingly. No file content was changed; all skill/test moves are pure renames. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Improve dotnet-diag and dotnet-winforms descriptions - dotnet-diag: add '.NET' qualifier to clarify scope - dotnet-winforms: use official 'Windows Forms (WinForms)' name Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add .NET qualifier to dotnet-data description Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove empty plugins; list them in CONTRIBUTING.md as future options Remove the four empty placeholder plugins (dotnet-aspnet, dotnet-wpf, dotnet-winforms, dotnet-maui) that had only plugin.json and no skills. Add a 'Plugin organization' section to CONTRIBUTING.md that describes the domain-specific plugin groupings introduced in this PR and lists the four removed plugin names as reserved candidates for future contributions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Create dotnet-upgrade plugin with migration/upgrade skills Move migrate-nullable-references, thread-abort-migration, and dotnet-aot-compat from dotnet to the new dotnet-upgrade plugin. Update CODEOWNERS paths (same owners), CONTRIBUTING.md plugin table, and fix the thread-abort-migration SKILL.md link in CONTRIBUTING.md. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
79 lines
3.3 KiB
C#
79 lines
3.3 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#nullable enable
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Azure.Core.Pipeline;
|
|
|
|
namespace Azure.Core
|
|
{
|
|
internal class ProtocolOperation<T> : Operation<T>, IOperation<T> where T : notnull
|
|
{
|
|
private readonly Func<Response, T> _resultSelector;
|
|
private readonly OperationInternal<T> _operation;
|
|
private readonly IOperation _nextLinkOperation;
|
|
|
|
internal ProtocolOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, string scopeName, Func<Response, T> resultSelector)
|
|
{
|
|
_resultSelector = resultSelector;
|
|
_nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia);
|
|
_operation = new OperationInternal<T>(this, clientDiagnostics, response, scopeName);
|
|
}
|
|
|
|
#pragma warning disable CA1822
|
|
// This scenario is currently unsupported.
|
|
// See: https://github.com/Azure/autorest.csharp/issues/2158.
|
|
/// <inheritdoc />
|
|
public override string Id => throw new NotSupportedException();
|
|
#pragma warning restore CA1822
|
|
|
|
/// <inheritdoc />
|
|
public override RehydrationToken? GetRehydrationToken() => ((IOperation<T>)this).GetRehydrationToken();
|
|
|
|
RehydrationToken IOperation<T>.GetRehydrationToken() => _nextLinkOperation.GetRehydrationToken();
|
|
|
|
/// <inheritdoc />
|
|
public override T Value => _operation.Value;
|
|
|
|
/// <inheritdoc />
|
|
public override bool HasCompleted => _operation.HasCompleted;
|
|
|
|
/// <inheritdoc />
|
|
public override bool HasValue => _operation.HasValue;
|
|
|
|
/// <inheritdoc />
|
|
public override Response GetRawResponse() => _operation.RawResponse;
|
|
|
|
/// <inheritdoc />
|
|
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
|
|
|
|
/// <inheritdoc />
|
|
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
|
|
|
|
/// <inheritdoc />
|
|
public override ValueTask<Response<T>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
|
|
|
|
/// <inheritdoc />
|
|
public override ValueTask<Response<T>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
|
|
|
|
async ValueTask<OperationState<T>> IOperation<T>.UpdateStateAsync(bool async, CancellationToken cancellationToken)
|
|
{
|
|
var state = await _nextLinkOperation.UpdateStateAsync(async, cancellationToken).ConfigureAwait(false);
|
|
if (state.HasSucceeded)
|
|
{
|
|
return OperationState<T>.Success(state.RawResponse, _resultSelector(state.RawResponse));
|
|
}
|
|
|
|
if (state.HasCompleted)
|
|
{
|
|
return OperationState<T>.Failure(state.RawResponse, state.OperationFailedException);
|
|
}
|
|
|
|
return OperationState<T>.Pending(state.RawResponse);
|
|
}
|
|
}
|
|
}
|