Compiler Warning ASPIRECOMMAND001
このコンテンツはまだ日本語訳がありません。
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
WithRequiredCommandoverload that accepts a validation callback (Func<RequiredCommandValidationContext, Task<RequiredCommandValidationResult>>) RequiredCommandAnnotationIRequiredCommandValidatorRequiredCommandValidationContextandRequiredCommandValidationResult
The simpler WithRequiredCommand(command, helpLink) overload isn’t experimental and doesn’t raise this diagnostic.
Example
Section titled “Example”The following code generates ASPIRECOMMAND001:
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.
To correct this warning
Section titled “To correct this warning”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 = noneFor more information about editor config files, see Configuration files for code analysis rules.
-
Add the following
PropertyGroupto your project file:C# project file <PropertyGroup><NoWarn>$(NoWarn);ASPIRECOMMAND001</NoWarn></PropertyGroup> -
Suppress in code with the
#pragma warning disable ASPIRECOMMAND001directive:Suppressing the warning #pragma warning disable ASPIRECOMMAND001builder.AddContainer("db", "postgres").WithRequiredCommand("psql", context => Task.FromResult(context.Success()));#pragma warning restore ASPIRECOMMAND001