Compiler Warning ASPIREWATCH001
Questi contenuti non sono ancora disponibili nella tua lingua.
Run mode configuration 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 experimental run mode configuration APIs in Aspire, including:
RunConfigurationclassDistributedApplicationExecutionContext.RunConfigurationpropertyDistributedApplicationExecutionContextOptions.RunConfigurationproperty
These APIs let integrations vary how their resources are launched based on the kind of run being performed, without changing the core hosting behavior. In publish mode, every property on RunConfiguration holds its default value.
Example
Section titled “Example”The following code generates ASPIREWATCH001:
var builder = DistributedApplication.CreateBuilder(args);
if (builder.ExecutionContext.IsRunMode){ var runConfiguration = builder.ExecutionContext.RunConfiguration;
if (runConfiguration.WatchEnabled) { // Launch resources so source changes are hot-reloaded. }}
builder.Build().Run();Understanding run mode configuration
Section titled “Understanding run mode configuration”RunConfiguration holds settings that only apply when the AppHost is running in run mode (as opposed to publish mode). Integrations use it to vary how their resources are launched without changing the core hosting behavior.
WatchEnabled
Section titled “WatchEnabled”Indicates that resources should start in watch mode if able. Integrations that support watch can launch their resources so that source changes are hot-reloaded. This is a hint: integrations that cannot watch their resources should start them in the normal fashion.
To suppress this warning
Section titled “To suppress this warning”Suppress the warning with either of the following methods:
-
Set the severity of the rule in the .editorconfig file.
.editorconfig [*.{cs,vb}]dotnet_diagnostic.ASPIREWATCH001.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);ASPIREWATCH001</NoWarn></PropertyGroup> -
Suppress in code with the
#pragma warning disable ASPIREWATCH001directive:Suppressing the warning var builder = DistributedApplication.CreateBuilder(args);#pragma warning disable ASPIREWATCH001var runConfiguration = builder.ExecutionContext.RunConfiguration;#pragma warning restore ASPIREWATCH001builder.Build().Run();