Files
Dan Moseley 042a9d2b2c Reorganize plugins into domain-specific groupings (#274)
* 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>
2026-03-06 21:01:52 -08:00

111 lines
4.4 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#nullable enable
using System.Threading;
using System.Threading.Tasks;
using Azure.Core.Pipeline;
namespace Azure.Core
{
internal static class HttpPipelineExtensions
{
public static async ValueTask<Response> ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext? requestContext, CancellationToken cancellationToken = default)
{
var (userCt, statusOption) = ApplyRequestContext(requestContext);
if (!userCt.CanBeCanceled || !cancellationToken.CanBeCanceled)
{
await pipeline.SendAsync(message, cancellationToken.CanBeCanceled ? cancellationToken : userCt).ConfigureAwait(false);
}
else
{
using var cts = CancellationTokenSource.CreateLinkedTokenSource(userCt, cancellationToken);
await pipeline.SendAsync(message, cts.Token).ConfigureAwait(false);
}
if (!message.Response.IsError || statusOption == ErrorOptions.NoThrow)
{
return message.Response;
}
throw new RequestFailedException(message.Response);
}
public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext? requestContext, CancellationToken cancellationToken = default)
{
var (userCt, statusOption) = ApplyRequestContext(requestContext);
if (!userCt.CanBeCanceled || !cancellationToken.CanBeCanceled)
{
pipeline.Send(message, cancellationToken.CanBeCanceled ? cancellationToken : userCt);
}
else
{
using var cts = CancellationTokenSource.CreateLinkedTokenSource(userCt, cancellationToken);
pipeline.Send(message, cts.Token);
}
if (!message.Response.IsError || statusOption == ErrorOptions.NoThrow)
{
return message.Response;
}
throw new RequestFailedException(message.Response);
}
public static async ValueTask<Response<bool>> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, ClientDiagnostics clientDiagnostics, RequestContext? requestContext)
{
var response = await pipeline.ProcessMessageAsync(message, requestContext).ConfigureAwait(false);
switch (response.Status)
{
case >= 200 and < 300:
return Response.FromValue(true, response);
case >= 400 and < 500:
return Response.FromValue(false, response);
default:
return new ErrorResponse<bool>(response, new RequestFailedException(response));
}
}
public static Response<bool> ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, ClientDiagnostics clientDiagnostics, RequestContext? requestContext)
{
var response = pipeline.ProcessMessage(message, requestContext);
switch (response.Status)
{
case >= 200 and < 300:
return Response.FromValue(true, response);
case >= 400 and < 500:
return Response.FromValue(false, response);
default:
return new ErrorResponse<bool>(response, new RequestFailedException(response));
}
}
private static (CancellationToken CancellationToken, ErrorOptions ErrorOptions) ApplyRequestContext(RequestContext? requestContext)
{
if (requestContext == null)
{
return (CancellationToken.None, ErrorOptions.Default);
}
return (requestContext.CancellationToken, requestContext.ErrorOptions);
}
internal class ErrorResponse<T> : Response<T>
{
private readonly Response _response;
private readonly RequestFailedException _exception;
public ErrorResponse(Response response, RequestFailedException exception)
{
_response = response;
_exception = exception;
}
public override T Value { get => throw _exception; }
public override Response GetRawResponse() => _response;
}
}
}