julealgonon Stack Overflow • Recommends
On “Split async method into two for code analysis?”
Am I correct, when I split this code in the following way?
No. The correct way to split them would be like this:
public Task DeleteColorSchemeAsync(ColorScheme colorScheme)
{
if (colorScheme == null)
throw new ArgumentNullException(nameof(colorScheme));
if (colorScheme.IsDefault)
throw new SettingIsDefaultException();
return DeleteColorSchemeInternalAsync(colorScheme);
}
private async Task DeleteColorSchemeInternalAsync(ColorScheme colorScheme)
{
_dbContext.ColorSchemes.Remove(colorScheme);
await _dbContext.SaveChangesAsync();
}
(note that the entry method is not async in this case).
Or like this, using the newer local functions:
public Task DeleteColorSchemeAsync(ColorS…