コンテンツにスキップ
ドキュメントAspire を試す
ドキュメント試す

Compiler Warning ASPIRECOMMAND001

このコンテンツはまだ日本語訳がありません。

Version introduced: 13.2

Required command validation types and members are for evaluation purposes only and are subject to change or removal in future updates. Suppress this diagnostic to proceed.

This diagnostic warning is reported when using the experimental required-command validation APIs. These APIs let an AppHost run custom validation against a resource’s required command or executable before the resource starts.

The following APIs are protected by this diagnostic:

  • The WithRequiredCommand overload that accepts a validation callback (Func<RequiredCommandValidationContext, Task<RequiredCommandValidationResult>>)
  • RequiredCommandAnnotation
  • IRequiredCommandValidator
  • RequiredCommandValidationContext and RequiredCommandValidationResult

The simpler WithRequiredCommand(command, helpLink) overload isn’t experimental and doesn’t raise this diagnostic.

The following code generates ASPIRECOMMAND001:

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
builder.AddContainer("db", "postgres")
.WithRequiredCommand(
"psql",
context => Task.FromResult(context.Success()));
builder.Build().Run();

The diagnostic is triggered because the WithRequiredCommand validation-callback overload and the RequiredCommandValidationContext type are marked with the [Experimental("ASPIRECOMMAND001")] attribute.

Suppress the warning with one of the following methods:

  • Set the severity of the rule in the .editorconfig file.

    .editorconfig
    [*.{cs,vb}]
    dotnet_diagnostic.ASPIRECOMMAND001.severity = none

    For more information about editor config files, see Configuration files for code analysis rules.

  • Add the following PropertyGroup to your project file:

    C# project file
    <PropertyGroup>
    <NoWarn>$(NoWarn);ASPIRECOMMAND001</NoWarn>
    </PropertyGroup>
  • Suppress in code with the #pragma warning disable ASPIRECOMMAND001 directive:

    Suppressing the warning
    #pragma warning disable ASPIRECOMMAND001
    builder.AddContainer("db", "postgres")
    .WithRequiredCommand("psql", context => Task.FromResult(context.Success()));
    #pragma warning restore ASPIRECOMMAND001