Skip to content

Commit

Permalink
fix: Analyzer rules for net9
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Apr 14, 2024
1 parent ca50915 commit c66fab9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ dotnet_naming_rule.parameters_rule.severity = warning

# Microsoft - Code Analysis
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/
dotnet_diagnostic.CA1515.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1515.md
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
dotnet_diagnostic.CA2007.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md

Expand All @@ -416,8 +417,11 @@ dotnet_diagnostic.S3875.severity = none # Remove this overload of 'operato

# Visual Studio
dotnet_diagnostic.IDE0005.severity = none # IDE0005: Using directive is unnecessary
dotnet_diagnostic.IDE0021.severity = suggestion # IDE0021: Use expression body for constructor
dotnet_diagnostic.IDE0022.severity = suggestion # IDE0022: Use expression body for method
dotnet_diagnostic.IDE0058.severity = none # IDE0058: Expression value is never used
dotnet_diagnostic.IDE0079.severity = warning # IDE0079: Remove unnecessary suppression
dotnet_diagnostic.IDE0290.severity = none # IDE0290: Use primary constructor

# AsyncFixer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ public CachedRepository(IRepository<T> repository, IMemoryCache memoryCache)

public ValueTask<HealthCheckResult> PerformHealthCheckAsync() => repository.PerformHealthCheckAsync();

public async ValueTask<T> GetByIdAsync(string id)
{
return await memoryCache.GetOrCreateAsync(id, async entry =>
public async ValueTask<T> GetByIdAsync(string id) =>
await memoryCache.GetOrCreateAsync(id, async entry =>
{
entry.SlidingExpiration = TimeSpan.FromDays(7);
return await repository.GetByIdAsync(id);
});
}

public async ValueTask<IPagedList<T>> GetAllAsync(
Expression<Func<T, bool>> filter = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static CreateNewModel FromBlogPost(BlogPost blogPost)
public BlogPost ToBlogPost()
{
var tagList = string.IsNullOrWhiteSpace(Tags)
? Array.Empty<string>()
? []
: Tags.Split(",", StringSplitOptions.RemoveEmptyEntries);
DateTime? updatedDate = ShouldUpdateDate || originalUpdatedDate == default
? null
Expand Down
17 changes: 4 additions & 13 deletions src/LinkDotNet.Blog.Web/Features/Services/LocalStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,9 @@ public LocalStorageService(ProtectedLocalStorage localStorage)
this.localStorage = localStorage;
}

public async ValueTask<bool> ContainKeyAsync(string key)
{
return (await localStorage.GetAsync<object>(key)).Success;
}
public async ValueTask<bool> ContainKeyAsync(string key) => (await localStorage.GetAsync<object>(key)).Success;

public async ValueTask<T> GetItemAsync<T>(string key)
{
return (await localStorage.GetAsync<T>(key)).Value;
}
public async ValueTask<T> GetItemAsync<T>(string key) => (await localStorage.GetAsync<T>(key)).Value;

public async ValueTask SetItemAsync<T>(string key, T value)
{
await localStorage.SetAsync(key, value);
}
}
public async ValueTask SetItemAsync<T>(string key, T value) => await localStorage.SetAsync(key, value);
}

0 comments on commit c66fab9

Please sign in to comment.