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>
74 lines
3.9 KiB
C#
74 lines
3.9 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
|
|
#nullable enable
|
|
|
|
namespace Azure.Core.Pipeline
|
|
{
|
|
internal class ClientDiagnostics : DiagnosticScopeFactory
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ClientDiagnostics"/> class.
|
|
/// </summary>
|
|
/// <param name="options">The customer provided client options object.</param>
|
|
/// <param name="suppressNestedClientActivities">Flag controlling if <see cref="System.Diagnostics.Activity"/>
|
|
/// created by this <see cref="ClientDiagnostics"/> for client method calls should be suppressed when called
|
|
/// by other Azure SDK client methods. It's recommended to set it to true for new clients; use default (null)
|
|
/// for backward compatibility reasons, or set it to false to explicitly disable suppression for specific cases.
|
|
/// The default value could change in the future, the flag should be only set to false if suppression for the client
|
|
/// should never be enabled.</param>
|
|
public ClientDiagnostics(ClientOptions options, bool? suppressNestedClientActivities = null)
|
|
: this(options.GetType().Namespace!,
|
|
GetResourceProviderNamespace(options.GetType().Assembly),
|
|
options.Diagnostics,
|
|
suppressNestedClientActivities)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ClientDiagnostics"/> class.
|
|
/// </summary>
|
|
/// <param name="optionsNamespace">Namespace of the client class, such as Azure.Storage or Azure.AppConfiguration.</param>
|
|
/// <param name="providerNamespace">Azure Resource Provider namespace of the Azure service SDK is primarily used for.</param>
|
|
/// <param name="diagnosticsOptions">The customer provided client diagnostics options.</param>
|
|
/// <param name="suppressNestedClientActivities">Flag controlling if <see cref="System.Diagnostics.Activity"/>
|
|
/// created by this <see cref="ClientDiagnostics"/> for client method calls should be suppressed when called
|
|
/// by other Azure SDK client methods. It's recommended to set it to true for new clients, use default (null) for old clients
|
|
/// for backward compatibility reasons, or set it to false to explicitly disable suppression for specific cases.
|
|
/// The default value could change in the future, the flag should be only set to false if suppression for the client
|
|
/// should never be enabled.</param>
|
|
public ClientDiagnostics(string optionsNamespace, string? providerNamespace, DiagnosticsOptions diagnosticsOptions, bool? suppressNestedClientActivities = null)
|
|
: base(optionsNamespace, providerNamespace, diagnosticsOptions.IsDistributedTracingEnabled, suppressNestedClientActivities.GetValueOrDefault(true), true)
|
|
{
|
|
}
|
|
|
|
internal static HttpMessageSanitizer CreateMessageSanitizer(DiagnosticsOptions diagnostics)
|
|
{
|
|
return new HttpMessageSanitizer(
|
|
diagnostics.LoggedQueryParameters.ToArray(),
|
|
diagnostics.LoggedHeaderNames.ToArray());
|
|
}
|
|
|
|
internal static string? GetResourceProviderNamespace(Assembly assembly)
|
|
{
|
|
foreach (var customAttribute in assembly.GetCustomAttributesData())
|
|
{
|
|
// Weak bind internal shared type
|
|
Type attributeType = customAttribute.AttributeType!;
|
|
if (attributeType.FullName == ("Azure.Core.AzureResourceProviderNamespaceAttribute"))
|
|
{
|
|
IList<CustomAttributeTypedArgument> namedArguments = customAttribute.ConstructorArguments;
|
|
return namedArguments.Single().Value as string;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|