Skip to content

Commit 4acc5e8

Browse files
committed
CS1998 This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
1 parent d21b774 commit 4acc5e8

File tree

5 files changed

+19
-26
lines changed

5 files changed

+19
-26
lines changed

src/MigrationTools.Host/Commands/CommandBase.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ public sealed override async Task<int> ExecuteAsync(CommandContext context, TSet
111111
}
112112
}
113113

114-
internal virtual async Task<int> ExecuteInternalAsync(CommandContext context, TSettings settings)
114+
internal virtual Task<int> ExecuteInternalAsync(CommandContext context, TSettings settings)
115115
{
116-
// no-op
117-
return 0;
116+
return Task.FromResult( 0);
118117
}
119118

120119
public void RunStartupLogic(TSettings settings)

src/MigrationTools.Host/Commands/ConfigurationBuilderCommand.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public ConfigurationBuilderCommand(
3939
Layout layout = new Layout("Root");
4040

4141

42-
public override async Task<int> ExecuteAsync(CommandContext context, ConfigurationBuilderCommandSettings settings)
42+
public override Task<int> ExecuteAsync(CommandContext context, ConfigurationBuilderCommandSettings settings)
4343
{
4444
int _exitCode;
4545

@@ -58,10 +58,6 @@ public override async Task<int> ExecuteAsync(CommandContext context, Configurati
5858
optionsUpgrader.UpgradeConfiguration(optionsBuilder, configFile);
5959
_logger.LogInformation("Configuration loaded & Upgraded to latest...");
6060

61-
62-
63-
64-
6561
var configurationEditorOptions = new[]
6662
{
6763
"Apply Templates",
@@ -116,7 +112,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, Configurati
116112
// Stop the application once the work is done
117113
_appLifetime.StopApplication();
118114
}
119-
return _exitCode;
115+
return Task.FromResult(_exitCode);
120116
}
121117

122118
private void DisplayCurrentOptions(OptionsConfigurationBuilder optionsBuilder)
@@ -171,7 +167,7 @@ private void SaveOptions(OptionsConfigurationBuilder optionsBuilder, string conf
171167

172168
private void SelectTemplateToApply(OptionsConfigurationBuilder optionsBuilder, string configFile)
173169
{
174-
170+
175171
bool shouldExit = false;
176172
while (!shouldExit)
177173
{

src/MigrationTools.Host/Commands/ExecuteMigrationCommand.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ public ExecuteMigrationCommand(
4545
_appLifetime = appLifetime;
4646
}
4747

48-
internal override async Task<int> ExecuteInternalAsync(CommandContext context, ExecuteMigrationCommandSettings settings)
48+
internal override Task<int> ExecuteInternalAsync(CommandContext context, ExecuteMigrationCommandSettings settings)
4949
{
5050
int _exitCode;
5151
try
5252
{
53-
// KILL if the config is not valid
54-
if (!VersionOptions.ConfigureOptions.IsConfigValid(Configuration))
55-
{
56-
CommandActivity.AddEvent(new ActivityEvent("ConfigIsNotValid"));
57-
BoilerplateCli.ConfigIsNotValidMessage(Configuration, Log.Logger);
58-
return -1;
59-
}
53+
// KILL if the config is not valid
54+
if (!VersionOptions.ConfigureOptions.IsConfigValid(Configuration))
55+
{
56+
CommandActivity.AddEvent(new ActivityEvent("ConfigIsNotValid"));
57+
BoilerplateCli.ConfigIsNotValidMessage(Configuration, Log.Logger);
58+
return Task.FromResult(-1);
59+
}
6060
var migrationEngine = _services.GetRequiredService<IMigrationEngine>();
6161
migrationEngine.Run();
6262
_exitCode = 0;
@@ -71,7 +71,7 @@ internal override async Task<int> ExecuteInternalAsync(CommandContext context, E
7171
foreach (var failure in ex.Failures)
7272
{
7373
_logger.LogCritical(failure);
74-
}
74+
}
7575
_logger.LogCritical("------------");
7676
_exitCode = 1;
7777
}
@@ -88,7 +88,7 @@ internal override async Task<int> ExecuteInternalAsync(CommandContext context, E
8888
// Stop the application once the work is done
8989
_appLifetime.StopApplication();
9090
}
91-
return _exitCode;
91+
return Task.FromResult(_exitCode);
9292
}
9393
}
9494
}

src/MigrationTools.Host/Commands/InitMigrationCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public InitMigrationCommand(IHostApplicationLifetime appLifetime, IServiceProvid
3232
_logger = logger;
3333
}
3434

35-
internal override async Task<int> ExecuteInternalAsync(CommandContext context, InitMigrationCommandSettings settings)
35+
internal override Task<int> ExecuteInternalAsync(CommandContext context, InitMigrationCommandSettings settings)
3636
{
3737
int _exitCode;
3838
try
@@ -81,7 +81,7 @@ internal override async Task<int> ExecuteInternalAsync(CommandContext context, I
8181
// Stop the application once the work is done
8282
Lifetime.StopApplication();
8383
}
84-
return _exitCode;
84+
return Task.FromResult(_exitCode);
8585
}
8686
}
8787
}

src/MigrationTools.Host/Commands/UpgradeConfigCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ internal class UpgradeConfigCommand : CommandBase<UpgradeConfigCommandSettings>
3737

3838
private readonly ILogger _logger;
3939

40-
41-
4240
public UpgradeConfigCommand(IHostApplicationLifetime appLifetime, IServiceProvider services, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService, ILogger<CommandBase<UpgradeConfigCommandSettings>> logger, ITelemetryLogger telemetryLogger, IMigrationToolVersion migrationToolVersion, IConfiguration configuration, ActivitySource activitySource) : base(appLifetime, services, detectOnlineService, detectVersionService, logger, telemetryLogger, migrationToolVersion, configuration, activitySource)
4341
{
4442
_logger = logger;
4543
}
4644

47-
internal override async Task<int> ExecuteInternalAsync(CommandContext context, UpgradeConfigCommandSettings settings)
45+
internal override Task<int> ExecuteInternalAsync(CommandContext context, UpgradeConfigCommandSettings settings)
4846
{
4947
CommandActivity.SetTagsFromObject(settings);
5048
int _exitCode = 0;
@@ -63,7 +61,7 @@ internal override async Task<int> ExecuteInternalAsync(CommandContext context, U
6361
File.WriteAllText(configFile, json);
6462
_logger.LogInformation("New {configFile} file has been created", configFile);
6563
Console.WriteLine(json);
66-
return _exitCode;
64+
return Task.FromResult(_exitCode);
6765
}
6866

6967

0 commit comments

Comments
 (0)