Skip to content

Commit 0cdb348

Browse files
authored
Fix JetBrains warnings and update ReSharper version to 2024.3.4 (#679)
### Summary & Motivation After upgrading Rider and ReSharper to JetBrains 2024.3.4, new warnings started appearing in the editor, specifically recommending the use of `CancellationToken.None` instead of `new CancellationToken()`. Warnings have been fixed, and the `jetbrains.resharper.globaltools` version in the `global.json` .NET tooling file has been updated to 2024.3.4, ensuring consistency between the build server and local development environments. ### Downstream Projects Please run the `code-inspections` CLI command to detect any warnings and fix these before continuing. ### Checklist - [x] I have added tests, or done manual regression tests - [x] I have updated the documentation, if necessary
2 parents 21810c8 + 4628b11 commit 0cdb348

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

application/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"commands": ["dotnet-dotcover"]
1212
},
1313
"jetbrains.resharper.globaltools": {
14-
"version": "2024.3.0",
14+
"version": "2024.3.4",
1515
"commands": ["jb"]
1616
}
1717
}

application/shared-kernel/Tests/Behaviors/PublishDomainEventsPipelineBehaviorTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public async Task Handle_WhenCalled_ShouldPublishDomainEvents()
2121
publisher
2222
);
2323
var request = new TestCommand();
24-
var cancellationToken = new CancellationToken();
2524
var next = Substitute.For<RequestHandlerDelegate<Result<TestAggregate>>>();
2625
next.Invoke().Returns(TestAggregate.Create("Test"));
2726

@@ -32,10 +31,10 @@ public async Task Handle_WhenCalled_ShouldPublishDomainEvents()
3231
);
3332

3433
// Act
35-
await behavior.Handle(request, next, cancellationToken);
34+
await behavior.Handle(request, next, CancellationToken.None);
3635

3736
// Assert
38-
await publisher.Received(1).Publish(domainEvent, cancellationToken);
37+
await publisher.Received(1).Publish(domainEvent, CancellationToken.None);
3938
testAggregate.DomainEvents.Should().BeEmpty();
4039
}
4140
}

application/shared-kernel/Tests/Behaviors/UnitOfWorkPipelineBehaviorTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,19 @@ public async Task Handle_WhenSuccessfulCommand_ShouldCallNextAndCommitChanges()
2929
{
3030
// Arrange
3131
var command = new TestCommand();
32-
var cancellationToken = new CancellationToken();
3332
var next = Substitute.For<RequestHandlerDelegate<Result<TestAggregate>>>();
3433
var successfulCommandResult = Result<TestAggregate>.Success(TestAggregate.Create("Foo"));
3534
next.Invoke().Returns(Task.FromResult(successfulCommandResult));
3635

3736
// Act
38-
_ = await _behavior.Handle(command, next, cancellationToken);
37+
_ = await _behavior.Handle(command, next, CancellationToken.None);
3938

4039
// Assert
41-
await _unitOfWork.Received().CommitAsync(cancellationToken);
40+
await _unitOfWork.Received().CommitAsync(CancellationToken.None);
4241
Received.InOrder(() =>
4342
{
4443
next.Invoke();
45-
_unitOfWork.CommitAsync(cancellationToken);
44+
_unitOfWork.CommitAsync(CancellationToken.None);
4645
}
4746
);
4847
}
@@ -52,16 +51,15 @@ public async Task Handle_WhenNonSuccessfulCommand_ShouldCallNextButNotCommitChan
5251
{
5352
// Arrange
5453
var command = new TestCommand();
55-
var cancellationToken = new CancellationToken();
5654
var next = Substitute.For<RequestHandlerDelegate<Result<TestAggregate>>>();
5755
var successfulCommandResult = Result<TestAggregate>.BadRequest("Fail");
5856
next.Invoke().Returns(Task.FromResult(successfulCommandResult));
5957

6058
// Act
61-
_ = await _behavior.Handle(command, next, cancellationToken);
59+
_ = await _behavior.Handle(command, next, CancellationToken.None);
6260

6361
// Assert
64-
await _unitOfWork.DidNotReceive().CommitAsync(cancellationToken);
62+
await _unitOfWork.DidNotReceive().CommitAsync(CancellationToken.None);
6563
await next.Received().Invoke();
6664
}
6765
}

application/shared-kernel/Tests/Persistence/RepositoryTests.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ public async Task Add_WhenNewAggregate_ShouldAddToDatabase()
3131
{
3232
// Arrange
3333
var testAggregate = TestAggregate.Create("TestAggregate");
34-
var cancellationToken = new CancellationToken();
3534

3635
// Act
37-
await _testAggregateRepository.AddAsync(testAggregate, cancellationToken);
38-
await _testDbContext.SaveChangesAsync(cancellationToken);
36+
await _testAggregateRepository.AddAsync(testAggregate, CancellationToken.None);
37+
await _testDbContext.SaveChangesAsync(CancellationToken.None);
3938

4039
// Assert
41-
var retrievedAggregate = await _testAggregateRepository.GetByIdAsync(testAggregate.Id, cancellationToken);
40+
var retrievedAggregate = await _testAggregateRepository.GetByIdAsync(testAggregate.Id, CancellationToken.None);
4241
retrievedAggregate.Should().NotBeNull();
4342
retrievedAggregate!.Id.Should().Be(testAggregate.Id);
4443
}
@@ -136,26 +135,25 @@ public async Task Update_WhenEntityIsModifiedByAnotherUser_ShouldThrowConcurrenc
136135
// Arrange
137136
var primaryRepository = new TestAggregateRepository(_testDbContext);
138137
var originalTestAggregate = TestAggregate.Create("TestAggregate");
139-
var cancellationToken = new CancellationToken();
140-
await primaryRepository.AddAsync(originalTestAggregate, cancellationToken);
141-
await _testDbContext.SaveChangesAsync(cancellationToken);
138+
await primaryRepository.AddAsync(originalTestAggregate, CancellationToken.None);
139+
await _testDbContext.SaveChangesAsync(CancellationToken.None);
142140

143141
// Simulate another user by creating a new DbContext and repository instance
144142
var secondaryDbContext = _sqliteInMemoryDbContextFactory.CreateContext();
145143
var secondaryRepository = new TestAggregateRepository(secondaryDbContext);
146144

147145
// Act
148146
var concurrentTestAggregate =
149-
(await secondaryRepository.GetByIdAsync(originalTestAggregate.Id, cancellationToken))!;
147+
(await secondaryRepository.GetByIdAsync(originalTestAggregate.Id, CancellationToken.None))!;
150148
concurrentTestAggregate.Name = "UpdatedTestAggregateByAnotherUser";
151149
secondaryRepository.Update(concurrentTestAggregate);
152-
await secondaryDbContext.SaveChangesAsync(cancellationToken);
150+
await secondaryDbContext.SaveChangesAsync(CancellationToken.None);
153151

154152
originalTestAggregate.Name = "UpdatedTestAggregate";
155153
primaryRepository.Update(originalTestAggregate);
156154

157155
// Assert
158-
await Assert.ThrowsAsync<DbUpdateConcurrencyException>(() => _testDbContext.SaveChangesAsync(cancellationToken));
156+
await Assert.ThrowsAsync<DbUpdateConcurrencyException>(() => _testDbContext.SaveChangesAsync(CancellationToken.None));
159157
}
160158

161159
[Fact]

0 commit comments

Comments
 (0)