Skip to content

Commit 4107baa

Browse files
committed
refactor: Use is (not) null
1 parent 81165c0 commit 4107baa

File tree

14 files changed

+24
-24
lines changed

14 files changed

+24
-24
lines changed

src/LinkDotNet.Blog.Infrastructure/Persistence/InMemory/Repository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ public ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProjection>(
3939
{
4040
ArgumentNullException.ThrowIfNull(selector);
4141
var result = entities.AsEnumerable();
42-
if (filter != null)
42+
if (filter is not null)
4343
{
4444
result = result.Where(filter.Compile());
4545
}
4646

47-
if (orderBy != null)
47+
if (orderBy is not null)
4848
{
4949
result = descending
5050
? result.OrderByDescending(orderBy.Compile())
@@ -64,7 +64,7 @@ public ValueTask StoreAsync(TEntity entity)
6464
}
6565

6666
var entry = entities.SingleOrDefault(b => b.Id == entity.Id);
67-
if (entry != null)
67+
if (entry is not null)
6868
{
6969
entities.Remove(entry);
7070
}
@@ -76,7 +76,7 @@ public ValueTask StoreAsync(TEntity entity)
7676
public ValueTask DeleteAsync(string id)
7777
{
7878
var blogPostToDelete = entities.SingleOrDefault(b => b.Id == id);
79-
if (blogPostToDelete != null)
79+
if (blogPostToDelete is not null)
8080
{
8181
entities.Remove(blogPostToDelete);
8282
}

src/LinkDotNet.Blog.Infrastructure/Persistence/MongoDB/Repository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProject
6262
{
6363
var query = Collection.AsQueryable();
6464

65-
if (filter != null)
65+
if (filter is not null)
6666
{
6767
query = query.Where(filter);
6868
}
6969

70-
if (orderBy != null)
70+
if (orderBy is not null)
7171
{
7272
query = descending ? query.OrderByDescending(orderBy) : query.OrderBy(orderBy);
7373
}

src/LinkDotNet.Blog.Infrastructure/Persistence/RavenDb/Repository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProject
5959
using var session = documentStore.OpenAsyncSession();
6060

6161
var query = session.Query<TEntity>();
62-
if (filter != null)
62+
if (filter is not null)
6363
{
6464
query = query.Where(filter);
6565
}
6666

67-
if (orderBy != null)
67+
if (orderBy is not null)
6868
{
6969
query = descending
7070
? query.OrderByDescending(orderBy)

src/LinkDotNet.Blog.Infrastructure/Persistence/Sql/Repository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProject
6262
var blogDbContext = await dbContextFactory.CreateDbContextAsync();
6363
var entity = blogDbContext.Set<TEntity>().AsNoTracking().AsQueryable();
6464

65-
if (filter != null)
65+
if (filter is not null)
6666
{
6767
entity = entity.Where(filter);
6868
}
6969

70-
if (orderBy != null)
70+
if (orderBy is not null)
7171
{
7272
entity = descending
7373
? entity.OrderByDescending(orderBy)
@@ -97,7 +97,7 @@ public async ValueTask StoreAsync(TEntity entity)
9797
public async ValueTask DeleteAsync(string id)
9898
{
9999
var entityToDelete = await GetByIdAsync(id);
100-
if (entityToDelete != null)
100+
if (entityToDelete is not null)
101101
{
102102
var blogDbContext = await dbContextFactory.CreateDbContextAsync();
103103
blogDbContext.Remove(entityToDelete);

src/LinkDotNet.Blog.Web/Features/AboutMe/Components/Profile.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ OnYesPressed="DeleteItem"></ConfirmDialog>
9898

9999
private async Task HandleDrop(ProfileInformationEntry dropTarget)
100100
{
101-
if (currentDragItem == null || dropTarget == currentDragItem)
101+
if (currentDragItem is null || dropTarget == currentDragItem)
102102
{
103103
return;
104104
}

src/LinkDotNet.Blog.Web/Features/AboutMe/Components/Skill/SkillTable.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484
private async Task HandleDrop(ProficiencyLevel proficiencyLevel)
8585
{
86-
if (currentDragItem == null || currentDragItem.ProficiencyLevel == proficiencyLevel)
86+
if (currentDragItem is null || currentDragItem.ProficiencyLevel == proficiencyLevel)
8787
{
8888
return;
8989
}

src/LinkDotNet.Blog.Web/Features/Admin/BlogPostEditor/Components/CreateNewBlogPost.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<label for="tags">Tags</label>
6666
<InputText class="form-control" id="tags" @bind-Value="model.Tags"/>
6767
</div>
68-
@if (BlogPost != null && !IsScheduled)
68+
@if (BlogPost is not null && !IsScheduled)
6969
{
7070
<div class="form-check">
7171
<InputCheckbox class="form-check-input" id="updatedate" @bind-Value="model.ShouldUpdateDate" />
@@ -117,7 +117,7 @@
117117

118118
protected override void OnParametersSet()
119119
{
120-
if (BlogPost == null)
120+
if (BlogPost is null)
121121
{
122122
return;
123123
}

src/LinkDotNet.Blog.Web/Features/Admin/BlogPostEditor/UpdateBlogPostPage.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@inject IRepository<BlogPost> BlogPostRepository
77
@inject IToastService ToastService
88

9-
@if (blogPostFromDb != null)
9+
@if (blogPostFromDb is not null)
1010
{
1111
<CreateNewBlogPost
1212
Title="Update BlogPost"
@@ -38,4 +38,4 @@ else
3838
await BlogPostRepository.StoreAsync(blogPostFromDb);
3939
ToastService.ShowInfo($"Updated BlogPost {blogPost.Title}");
4040
}
41-
}
41+
}

src/LinkDotNet.Blog.Web/Features/Admin/Dashboard/Components/VisitCountPerPage.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<div class="card-body">
1717
<div class="row">
1818
<DateRangeSelector FilterChanged="RefreshVisitCount"></DateRangeSelector>
19-
@if (visitData != null)
19+
@if (visitData is not null)
2020
{
2121
<p id="total-clicks">@visitData.Sum(c => c.ClickCount) clicks in total</p>
2222
}
@@ -31,7 +31,7 @@
3131
<th>Clicks</th>
3232
<th>Likes</th>
3333
</tr>
34-
@if (visitData != null)
34+
@if (visitData is not null)
3535
{
3636
@foreach (var date in visitData)
3737
{

src/LinkDotNet.Blog.Web/Features/Admin/Sitemap/SitemapPage.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{
1515
<Loading></Loading>
1616
}
17-
@if (sitemapUrlSet != null)
17+
@if (sitemapUrlSet is not null)
1818
{
1919
<table class="table table-striped table-hover h-50">
2020
<thead>

0 commit comments

Comments
 (0)