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>
114 lines
5.7 KiB
C#
114 lines
5.7 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
// <auto-generated/>
|
|
|
|
#nullable disable
|
|
|
|
using System.ClientModel.Primitives;
|
|
using System.Reflection;
|
|
using System;
|
|
using Azure.Core;
|
|
using Azure.Core.Pipeline;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Azure.ResourceManager
|
|
{
|
|
/// <inheritdoc/>
|
|
public abstract class ArmOperation : Operation
|
|
{
|
|
/// <summary>
|
|
/// Rehydrates an operation from a <see cref="RehydrationToken"/>.
|
|
/// </summary>
|
|
/// <param name="client">The Arm client.</param>
|
|
/// <param name="rehydrationToken">The rehydration token.</param>
|
|
/// <param name="options">The Arm client options.</param>
|
|
/// <returns>The long-running operation.</returns>
|
|
public static ArmOperation Rehydrate(ArmClient client, RehydrationToken rehydrationToken, ArmClientOptions options = null)
|
|
{
|
|
Argument.AssertNotNull(client, nameof(client));
|
|
Argument.AssertNotNull(rehydrationToken, nameof(rehydrationToken));
|
|
|
|
var nextLinkOperation = (NextLinkOperationImplementation)NextLinkOperationImplementation.Create(client.Pipeline, rehydrationToken);
|
|
var operationState = nextLinkOperation.UpdateStateAsync(async: false, default).EnsureCompleted();
|
|
return new RehydrationOperation(nextLinkOperation, operationState);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rehydrates an operation from a <see cref="RehydrationToken"/>.
|
|
/// </summary>
|
|
/// <param name="client">The Arm client.</param>
|
|
/// <param name="rehydrationToken">The rehydration token.</param>
|
|
/// <param name="options">The Arm client options.</param>
|
|
/// <returns>The long-running operation.</returns>
|
|
public static ArmOperation<T> Rehydrate<T>(ArmClient client, RehydrationToken rehydrationToken, ArmClientOptions options = null) where T : notnull
|
|
{
|
|
|
|
Argument.AssertNotNull(client, nameof(client));
|
|
Argument.AssertNotNull(rehydrationToken, nameof(rehydrationToken));
|
|
|
|
bool isResource = IsResource<T>();
|
|
IOperationSource<T> source = new GenericOperationSource<T>(client, isResource);
|
|
var nextLinkOperation = (NextLinkOperationImplementation)NextLinkOperationImplementation.Create(client.Pipeline, rehydrationToken);
|
|
var operation = NextLinkOperationImplementation.Create(source, nextLinkOperation);
|
|
var operationState = operation.UpdateStateAsync(async: false, default).EnsureCompleted();
|
|
return new RehydrationOperation<T>(nextLinkOperation, operationState, operation, options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rehydrates an operation from a <see cref="RehydrationToken"/>.
|
|
/// </summary>
|
|
/// <param name="client">The Arm client.</param>
|
|
/// <param name="rehydrationToken">The rehydration token.</param>
|
|
/// <param name="options">The Arm client options.</param>
|
|
/// <returns>The long-running operation.</returns>
|
|
public static async Task<ArmOperation> RehydrateAsync(ArmClient client, RehydrationToken rehydrationToken, ArmClientOptions options = null)
|
|
{
|
|
Argument.AssertNotNull(client, nameof(client));
|
|
Argument.AssertNotNull(rehydrationToken, nameof(rehydrationToken));
|
|
|
|
var nextLinkOperation = (NextLinkOperationImplementation)NextLinkOperationImplementation.Create(client.Pipeline, rehydrationToken);
|
|
var operationState = await nextLinkOperation.UpdateStateAsync(async: true, default).ConfigureAwait(false);
|
|
return new RehydrationOperation(nextLinkOperation, operationState);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rehydrates an operation from a <see cref="RehydrationToken"/>.
|
|
/// </summary>
|
|
/// <param name="client">The Arm client.</param>
|
|
/// <param name="rehydrationToken">The rehydration token.</param>
|
|
/// <param name="options">The Arm client options.</param>
|
|
/// <returns>The long-running operation.</returns>
|
|
public static async Task<ArmOperation<T>> RehydrateAsync<T>(ArmClient client, RehydrationToken rehydrationToken, ArmClientOptions options = null) where T : notnull
|
|
{
|
|
|
|
Argument.AssertNotNull(client, nameof(client));
|
|
Argument.AssertNotNull(rehydrationToken, nameof(rehydrationToken));
|
|
|
|
bool isResource = IsResource<T>();
|
|
IOperationSource<T> source = new GenericOperationSource<T>(client, isResource);
|
|
var nextLinkOperation = (NextLinkOperationImplementation)NextLinkOperationImplementation.Create(client.Pipeline, rehydrationToken);
|
|
var operation = NextLinkOperationImplementation.Create(source, nextLinkOperation);
|
|
var operationState = await operation.UpdateStateAsync(async: true, default).ConfigureAwait(false);
|
|
return new RehydrationOperation<T>(nextLinkOperation, operationState, operation, options);
|
|
}
|
|
|
|
private static bool IsResource<T>() where T : notnull
|
|
{
|
|
var isResource = typeof(T).GetConstructor(
|
|
BindingFlags.NonPublic | BindingFlags.Instance,
|
|
null,
|
|
CallingConventions.Any,
|
|
new Type[] { typeof(ArmClient), typeof(ResourceIdentifier) },
|
|
null) is not null;
|
|
var obj = Activator.CreateInstance(typeof(T), BindingFlags.NonPublic | BindingFlags.Instance, null, null, null);
|
|
if (!isResource && obj is not IJsonModel<object>)
|
|
{
|
|
throw new InvalidOperationException($"Type {typeof(T)} should be Resource or Model");
|
|
}
|
|
|
|
return isResource;
|
|
}
|
|
}
|
|
}
|