feat: add ConfigureAwait(false) to all await calls

pull/2500/head
Javier Campos 5 years ago
parent 21f1aa5c1c
commit 2f7af82fc1

@ -34,7 +34,7 @@ namespace Volo.Abp.FeatureManagement
public virtual async Task<FeatureListDto> GetAsync([NotNull] string providerName, [NotNull] string providerKey)
{
await CheckProviderPolicy(providerName);
await CheckProviderPolicy(providerName).ConfigureAwait(false);
var featureDefinitions = _featureDefinitionManager.GetAll();
var features = new List<FeatureDto>();
@ -48,7 +48,7 @@ namespace Volo.Abp.FeatureManagement
ValueType = featureDefinition.ValueType,
Description = featureDefinition.Description?.Localize(_stringLocalizerFactory),
ParentName = featureDefinition.Parent?.Name,
Value = await _featureManager.GetOrNullAsync(featureDefinition.Name, providerName, providerKey)
Value = await _featureManager.GetOrNullAsync(featureDefinition.Name, providerName, providerKey).ConfigureAwait(false)
});
}
@ -59,11 +59,11 @@ namespace Volo.Abp.FeatureManagement
public virtual async Task UpdateAsync([NotNull] string providerName, [NotNull] string providerKey, UpdateFeaturesDto input)
{
await CheckProviderPolicy(providerName);
await CheckProviderPolicy(providerName).ConfigureAwait(false);
foreach (var feature in input.Features)
{
await _featureManager.SetAsync(feature.Name, feature.Value, providerName, providerKey);
await _featureManager.SetAsync(feature.Name, feature.Value, providerName, providerKey).ConfigureAwait(false);
}
}
@ -88,7 +88,7 @@ namespace Volo.Abp.FeatureManagement
throw new AbpException($"No policy defined to get/set permissions for the provider '{policyName}'. Use {nameof(FeatureManagementOptions)} to map the policy.");
}
await AuthorizationService.CheckAsync(policyName);
await AuthorizationService.CheckAsync(policyName).ConfigureAwait(false);
}
}
}

@ -16,17 +16,17 @@ namespace Volo.Abp.FeatureManagement
public async Task<string> GetOrNullAsync(FeatureDefinition feature, string providerKey)
{
return await Store.GetOrNullAsync(feature.Name, Name, NormalizeProviderKey(providerKey));
return await Store.GetOrNullAsync(feature.Name, Name, NormalizeProviderKey(providerKey)).ConfigureAwait(false);
}
public virtual async Task SetAsync(FeatureDefinition feature, string value, string providerKey)
{
await Store.SetAsync(feature.Name, value, Name, NormalizeProviderKey(providerKey));
await Store.SetAsync(feature.Name, value, Name, NormalizeProviderKey(providerKey)).ConfigureAwait(false);
}
public virtual async Task ClearAsync(FeatureDefinition feature, string providerKey)
{
await Store.DeleteAsync(feature.Name, Name, NormalizeProviderKey(providerKey));
await Store.DeleteAsync(feature.Name, Name, NormalizeProviderKey(providerKey)).ConfigureAwait(false);
}
protected virtual string NormalizeProviderKey(string providerKey)

@ -23,52 +23,52 @@ namespace Volo.Abp.FeatureManagement
public async Task<string> GetOrNullAsync(string name, string providerName, string providerKey)
{
var cacheItem = await GetCacheItemAsync(name, providerName, providerKey);
var cacheItem = await GetCacheItemAsync(name, providerName, providerKey).ConfigureAwait(false);
return cacheItem.Value;
}
public async Task SetAsync(string name, string value, string providerName, string providerKey)
{
var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey);
var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey).ConfigureAwait(false);
if (featureValue == null)
{
featureValue = new FeatureValue(GuidGenerator.Create(), name, value, providerName, providerKey);
await FeatureValueRepository.InsertAsync(featureValue);
await FeatureValueRepository.InsertAsync(featureValue).ConfigureAwait(false);
}
else
{
featureValue.Value = value;
await FeatureValueRepository.UpdateAsync(featureValue);
await FeatureValueRepository.UpdateAsync(featureValue).ConfigureAwait(false);
}
}
public async Task DeleteAsync(string name, string providerName, string providerKey)
{
var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey);
var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey).ConfigureAwait(false);
if (featureValue != null)
{
await FeatureValueRepository.DeleteAsync(featureValue);
await FeatureValueRepository.DeleteAsync(featureValue).ConfigureAwait(false);
}
}
protected virtual async Task<FeatureValueCacheItem> GetCacheItemAsync(string name, string providerName, string providerKey)
{
var cacheKey = CalculateCacheKey(name, providerName, providerKey);
var cacheItem = await Cache.GetAsync(cacheKey);
var cacheItem = await Cache.GetAsync(cacheKey).ConfigureAwait(false);
if (cacheItem != null)
{
return cacheItem;
}
var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey);
var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey).ConfigureAwait(false);
cacheItem = new FeatureValueCacheItem(featureValue?.Value);
await Cache.SetAsync(
cacheKey,
cacheItem
);
).ConfigureAwait(false);
return cacheItem;
}

@ -82,7 +82,7 @@ namespace Volo.Abp.FeatureManagement
var providerValue = await provider.GetOrNullAsync(
feature,
provider.Name == providerName ? providerKey : null
);
).ConfigureAwait(false);
if (providerValue != null)
{
@ -123,7 +123,7 @@ namespace Volo.Abp.FeatureManagement
if (providers.Count > 1 && !forceToSet && value != null)
{
var fallbackValue = await GetOrNullInternalAsync(name, providers[1].Name, null);
var fallbackValue = await GetOrNullInternalAsync(name, providers[1].Name, null).ConfigureAwait(false);
if (fallbackValue == value)
{
//Clear the value if it's same as it's fallback value
@ -139,14 +139,14 @@ namespace Volo.Abp.FeatureManagement
{
foreach (var provider in providers)
{
await provider.ClearAsync(feature, providerKey);
await provider.ClearAsync(feature, providerKey).ConfigureAwait(false);
}
}
else
{
foreach (var provider in providers)
{
await provider.SetAsync(feature, value, providerKey);
await provider.SetAsync(feature, value, providerKey).ConfigureAwait(false);
}
}
}
@ -172,7 +172,7 @@ namespace Volo.Abp.FeatureManagement
value = await provider.GetOrNullAsync(
feature,
provider.Name == providerName ? providerKey : null
);
).ConfigureAwait(false);
if (value != null)
{

@ -25,7 +25,7 @@ namespace Volo.Abp.FeatureManagement
eventData.Entity.ProviderKey
);
await Cache.RemoveAsync(cacheKey);
await Cache.RemoveAsync(cacheKey).ConfigureAwait(false);
}
protected virtual string CalculateCacheKey(string name, string providerName, string providerKey)

@ -20,7 +20,7 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore
return await DbSet
.FirstOrDefaultAsync(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey
);
).ConfigureAwait(false);
}
public async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey)
@ -28,7 +28,7 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore
return await DbSet
.Where(
s => s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync();
).ToListAsync().ConfigureAwait(false);
}
}
}

@ -19,14 +19,14 @@ namespace Volo.Abp.FeatureManagement.MongoDB
public async Task<FeatureValue> FindAsync(string name, string providerName, string providerKey)
{
return await GetMongoQueryable()
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey);
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey).ConfigureAwait(false);
}
public async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey)
{
return await GetMongoQueryable()
.Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync();
.ToListAsync().ConfigureAwait(false);
}
}
}

@ -36,7 +36,7 @@ namespace Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement
public async Task OnGetAsync()
{
FeatureListDto = await _featureAppService.GetAsync(ProviderName, ProviderKey);
FeatureListDto = await _featureAppService.GetAsync(ProviderName, ProviderKey).ConfigureAwait(false);
}
public async Task<IActionResult> OnPostAsync()
@ -50,7 +50,7 @@ namespace Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement
}).ToList()
};
await _featureAppService.UpdateAsync(ProviderName, ProviderKey, features);
await _featureAppService.UpdateAsync(ProviderName, ProviderKey, features).ConfigureAwait(false);
return NoContent();
}

@ -39,7 +39,7 @@ namespace Volo.Abp.FeatureManagement
Login(_testData.User1Id);
var featureList = await _featureAppService.GetAsync(EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString());
TestEditionIds.Regular.ToString()).ConfigureAwait(false);
featureList.ShouldNotBeNull();
featureList.Features.ShouldContain(feature => feature.Name == TestFeatureDefinitionProvider.SocialLogins);
@ -61,10 +61,10 @@ namespace Volo.Abp.FeatureManagement
Value = false.ToString().ToLowerInvariant()
}
}
});
}).ConfigureAwait(false);
(await _featureAppService.GetAsync(EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString())).Features.Any(x =>
TestEditionIds.Regular.ToString()).ConfigureAwait(false)).Features.Any(x =>
x.Name == TestFeatureDefinitionProvider.SocialLogins &&
x.Value == false.ToString().ToLowerInvariant())
.ShouldBeTrue();

@ -21,63 +21,63 @@ namespace Volo.Abp.FeatureManagement
(await _featureManager.GetOrNullDefaultAsync(
TestFeatureDefinitionProvider.SocialLogins
)).ShouldBeNull();
).ConfigureAwait(false)).ShouldBeNull();
(await _featureManager.GetOrNullDefaultAsync(
TestFeatureDefinitionProvider.DailyAnalysis
)).ShouldBe(false.ToString().ToLowerInvariant());
).ConfigureAwait(false)).ShouldBe(false.ToString().ToLowerInvariant());
(await _featureManager.GetOrNullDefaultAsync(
TestFeatureDefinitionProvider.ProjectCount
)).ShouldBe("1");
).ConfigureAwait(false)).ShouldBe("1");
(await _featureManager.GetOrNullDefaultAsync(
TestFeatureDefinitionProvider.BackupCount
)).ShouldBe("0");
).ConfigureAwait(false)).ShouldBe("0");
//"Enterprise" edition values
(await _featureManager.GetOrNullForEditionAsync(
TestFeatureDefinitionProvider.SocialLogins,
TestEditionIds.Enterprise
)).ShouldBe(true.ToString().ToLowerInvariant());
).ConfigureAwait(false)).ShouldBe(true.ToString().ToLowerInvariant());
(await _featureManager.GetOrNullForEditionAsync(
TestFeatureDefinitionProvider.DailyAnalysis,
TestEditionIds.Enterprise
)).ShouldBe(false.ToString().ToLowerInvariant());
).ConfigureAwait(false)).ShouldBe(false.ToString().ToLowerInvariant());
(await _featureManager.GetOrNullForEditionAsync(
TestFeatureDefinitionProvider.ProjectCount,
TestEditionIds.Enterprise
)).ShouldBe("3");
).ConfigureAwait(false)).ShouldBe("3");
(await _featureManager.GetOrNullForEditionAsync(
TestFeatureDefinitionProvider.BackupCount,
TestEditionIds.Enterprise
)).ShouldBe("5");
).ConfigureAwait(false)).ShouldBe("5");
//"Ultimate" edition values
(await _featureManager.GetOrNullForEditionAsync(
TestFeatureDefinitionProvider.SocialLogins,
TestEditionIds.Ultimate
)).ShouldBe(true.ToString().ToLowerInvariant());
).ConfigureAwait(false)).ShouldBe(true.ToString().ToLowerInvariant());
(await _featureManager.GetOrNullForEditionAsync(
TestFeatureDefinitionProvider.DailyAnalysis,
TestEditionIds.Ultimate
)).ShouldBe(true.ToString().ToLowerInvariant());
).ConfigureAwait(false)).ShouldBe(true.ToString().ToLowerInvariant());
(await _featureManager.GetOrNullForEditionAsync(
TestFeatureDefinitionProvider.ProjectCount,
TestEditionIds.Ultimate
)).ShouldBe("10");
).ConfigureAwait(false)).ShouldBe("10");
(await _featureManager.GetOrNullForEditionAsync(
TestFeatureDefinitionProvider.BackupCount,
TestEditionIds.Ultimate
)).ShouldBe("10");
).ConfigureAwait(false)).ShouldBe("10");
}
}
}

@ -28,19 +28,19 @@ namespace Volo.Abp.FeatureManagement
// Arrange cache feature.
await _featureManagementStore.GetOrNullAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString());
TestEditionIds.Regular.ToString()).ConfigureAwait(false);
var feature = await _featureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString());
TestEditionIds.Regular.ToString()).ConfigureAwait(false);
// Act
await _featureValueRepository.DeleteAsync(feature);
await _featureValueRepository.DeleteAsync(feature).ConfigureAwait(false);
// Assert
(await _cache.GetAsync(FeatureValueCacheItem.CalculateCacheKey(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString()))).ShouldBeNull();
TestEditionIds.Regular.ToString())).ConfigureAwait(false)).ShouldBeNull();
}
}

@ -27,11 +27,11 @@ namespace Volo.Abp.FeatureManagement
// Act
(await FeatureManagementStore.GetOrNullAsync(Guid.NewGuid().ToString(),
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString())).ShouldBeNull();
TestEditionIds.Regular.ToString()).ConfigureAwait(false)).ShouldBeNull();
(await FeatureManagementStore.GetOrNullAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString())).ShouldNotBeNull();
TestEditionIds.Regular.ToString()).ConfigureAwait(false)).ShouldNotBeNull();
}
[Fact]
@ -40,17 +40,17 @@ namespace Volo.Abp.FeatureManagement
// Arrange
(await FeatureManagementStore.GetOrNullAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString())).ShouldNotBeNull();
TestEditionIds.Regular.ToString()).ConfigureAwait(false)).ShouldNotBeNull();
// Act
await FeatureManagementStore.DeleteAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString());
TestEditionIds.Regular.ToString()).ConfigureAwait(false);
// Assert
(await FeatureManagementStore.GetOrNullAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString())).ShouldBeNull();
TestEditionIds.Regular.ToString()).ConfigureAwait(false)).ShouldBeNull();
}
[Fact]
@ -59,18 +59,18 @@ namespace Volo.Abp.FeatureManagement
// Arrange
(await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString())).Value.ShouldBe(true.ToString().ToLowerInvariant());
TestEditionIds.Regular.ToString()).ConfigureAwait(false)).Value.ShouldBe(true.ToString().ToLowerInvariant());
// Act
await FeatureManagementStore.SetAsync(TestFeatureDefinitionProvider.SocialLogins,
false.ToString().ToUpperInvariant(),
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString());
TestEditionIds.Regular.ToString()).ConfigureAwait(false);
// Assert
(await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString())).Value.ShouldBe(false.ToString().ToUpperInvariant());
TestEditionIds.Regular.ToString()).ConfigureAwait(false)).Value.ShouldBe(false.ToString().ToUpperInvariant());
}
[Fact]
@ -79,18 +79,18 @@ namespace Volo.Abp.FeatureManagement
// Arrange
(await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString())).ShouldNotBeNull();
TestEditionIds.Regular.ToString()).ConfigureAwait(false)).ShouldNotBeNull();
// Act
await FeatureManagementStore.DeleteAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString());
TestEditionIds.Regular.ToString()).ConfigureAwait(false);
// Assert
(await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString())).ShouldBeNull();
TestEditionIds.Regular.ToString()).ConfigureAwait(false)).ShouldBeNull();
}

@ -34,7 +34,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString()
)
);
).ConfigureAwait(false);
//UserCount
await _featureValueRepository.InsertAsync(
@ -45,7 +45,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString()
)
);
).ConfigureAwait(false);
//ProjectCount
await _featureValueRepository.InsertAsync(
@ -56,7 +56,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Regular.ToString()
)
);
).ConfigureAwait(false);
#endregion
@ -71,7 +71,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Enterprise.ToString()
)
);
).ConfigureAwait(false);
//EmailSupport
await _featureValueRepository.InsertAsync(
@ -82,7 +82,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Enterprise.ToString()
)
);
).ConfigureAwait(false);
//UserCount
await _featureValueRepository.InsertAsync(
@ -93,7 +93,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Enterprise.ToString()
)
);
).ConfigureAwait(false);
//ProjectCount
await _featureValueRepository.InsertAsync(
@ -104,7 +104,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Enterprise.ToString()
)
);
).ConfigureAwait(false);
//BackupCount
await _featureValueRepository.InsertAsync(
@ -115,7 +115,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Enterprise.ToString()
)
);
).ConfigureAwait(false);
#endregion
@ -130,7 +130,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Ultimate.ToString()
)
);
).ConfigureAwait(false);
//EmailSupport
await _featureValueRepository.InsertAsync(
@ -141,7 +141,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Ultimate.ToString()
)
);
).ConfigureAwait(false);
//EmailSupport
await _featureValueRepository.InsertAsync(
@ -152,7 +152,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Ultimate.ToString()
)
);
).ConfigureAwait(false);
//UserCount
await _featureValueRepository.InsertAsync(
@ -163,7 +163,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Ultimate.ToString()
)
);
).ConfigureAwait(false);
//ProjectCount
await _featureValueRepository.InsertAsync(
@ -174,7 +174,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Ultimate.ToString()
)
);
).ConfigureAwait(false);
//BackupCount
await _featureValueRepository.InsertAsync(
@ -185,7 +185,7 @@ namespace Volo.Abp.FeatureManagement
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Ultimate.ToString()
)
);
).ConfigureAwait(false);
#endregion
}

@ -25,7 +25,7 @@ namespace Volo.Abp.FeatureManagement
TestFeatureDefinitionProvider.ProjectCount,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Enterprise.ToString()
);
).ConfigureAwait(false);
featureValue.ShouldNotBeNull();
featureValue.Value.ShouldBe("3");
@ -35,7 +35,7 @@ namespace Volo.Abp.FeatureManagement
TestFeatureDefinitionProvider.ProjectCount,
EditionFeatureValueProvider.ProviderName,
"undefined-edition-id"
);
).ConfigureAwait(false);
featureValue.ShouldBeNull();
}
@ -46,7 +46,7 @@ namespace Volo.Abp.FeatureManagement
var featureValues = await Repository.GetListAsync(
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Enterprise.ToString()
);
).ConfigureAwait(false);
featureValues.Count.ShouldBeGreaterThan(0);

Loading…
Cancel
Save