Skip to content

Commit 3f6f926

Browse files
committed
Revert "Resharper: Replace async method with Task return"
This reverts commit b958174.
1 parent 961ecef commit 3f6f926

File tree

38 files changed

+150
-158
lines changed

38 files changed

+150
-158
lines changed

src/JsonApiDotNetCore.MongoDb/AtomicOperations/MongoTransaction.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,20 @@ public Task AfterProcessOperationAsync(CancellationToken cancellationToken)
3535
}
3636

3737
/// <inheritdoc />
38-
public Task CommitAsync(CancellationToken cancellationToken)
38+
public async Task CommitAsync(CancellationToken cancellationToken)
3939
{
4040
if (_ownsTransaction && _mongoDataAccess.ActiveSession != null)
4141
{
42-
return _mongoDataAccess.ActiveSession.CommitTransactionAsync(cancellationToken);
42+
await _mongoDataAccess.ActiveSession.CommitTransactionAsync(cancellationToken);
4343
}
44-
45-
return Task.CompletedTask;
4644
}
4745

4846
/// <inheritdoc />
49-
public ValueTask DisposeAsync()
47+
public async ValueTask DisposeAsync()
5048
{
5149
if (_ownsTransaction)
5250
{
53-
return _mongoDataAccess.DisposeAsync();
51+
await _mongoDataAccess.DisposeAsync();
5452
}
55-
56-
return ValueTask.CompletedTask;
5753
}
5854
}

src/JsonApiDotNetCore.MongoDb/Repositories/MongoRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ public virtual async Task CreateAsync(TResource resourceFromRequest, TResource r
174174
await _resourceDefinitionAccessor.OnWritingAsync(resourceForDatabase, WriteOperationKind.CreateResource, cancellationToken);
175175

176176
await SaveChangesAsync(
177-
() => _mongoDataAccess.ActiveSession != null
177+
async () => await (_mongoDataAccess.ActiveSession != null
178178
? Collection.InsertOneAsync(_mongoDataAccess.ActiveSession, resourceForDatabase, cancellationToken: cancellationToken)
179-
: Collection.InsertOneAsync(resourceForDatabase, cancellationToken: cancellationToken), cancellationToken);
179+
: Collection.InsertOneAsync(resourceForDatabase, cancellationToken: cancellationToken)), cancellationToken);
180180

181181
await _resourceDefinitionAccessor.OnWriteSucceededAsync(resourceForDatabase, WriteOperationKind.CreateResource, cancellationToken);
182182
}

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/AtomicOperationsFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public Task InitializeAsync()
3232
return Task.CompletedTask;
3333
}
3434

35-
public Task DisposeAsync()
35+
public async Task DisposeAsync()
3636
{
37-
return TestContext.DisposeAsync();
37+
await TestContext.DisposeAsync();
3838
}
3939
}

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ public async Task Cannot_create_resource_for_existing_client_generated_ID()
132132

133133
string newIsoCode = _fakers.TextLanguage.Generate().IsoCode!;
134134

135-
await _testContext.RunOnDatabaseAsync(dbContext =>
135+
await _testContext.RunOnDatabaseAsync(async dbContext =>
136136
{
137137
dbContext.TextLanguages.Add(existingLanguage);
138-
return dbContext.SaveChangesAsync();
138+
await dbContext.SaveChangesAsync();
139139
});
140140

141141
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public async Task Cannot_create_ToMany_relationship()
2020

2121
string newTitle = _fakers.MusicTrack.Generate().Title;
2222

23-
await _testContext.RunOnDatabaseAsync(dbContext =>
23+
await _testContext.RunOnDatabaseAsync(async dbContext =>
2424
{
2525
dbContext.Performers.Add(existingPerformer);
26-
return dbContext.SaveChangesAsync();
26+
await dbContext.SaveChangesAsync();
2727
});
2828

2929
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public async Task Cannot_create_ToOne_relationship()
2020

2121
string newLyricText = _fakers.Lyric.Generate().Text;
2222

23-
await _testContext.RunOnDatabaseAsync(dbContext =>
23+
await _testContext.RunOnDatabaseAsync(async dbContext =>
2424
{
2525
dbContext.MusicTracks.Add(existingTrack);
26-
return dbContext.SaveChangesAsync();
26+
await dbContext.SaveChangesAsync();
2727
});
2828

2929
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public async Task Can_delete_existing_resource()
1818
// Arrange
1919
Performer existingPerformer = _fakers.Performer.Generate();
2020

21-
await _testContext.RunOnDatabaseAsync(dbContext =>
21+
await _testContext.RunOnDatabaseAsync(async dbContext =>
2222
{
2323
dbContext.Performers.Add(existingPerformer);
24-
return dbContext.SaveChangesAsync();
24+
await dbContext.SaveChangesAsync();
2525
});
2626

2727
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ public async Task Returns_resource_meta_in_update_resource_with_side_effects()
112112

113113
TextLanguage existingLanguage = _fakers.TextLanguage.Generate();
114114

115-
await _testContext.RunOnDatabaseAsync(dbContext =>
115+
await _testContext.RunOnDatabaseAsync(async dbContext =>
116116
{
117117
dbContext.TextLanguages.Add(existingLanguage);
118-
return dbContext.SaveChangesAsync();
118+
await dbContext.SaveChangesAsync();
119119
});
120120

121121
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Transactions/AtomicRollbackTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public async Task Can_rollback_created_resource_on_error()
2626
string newArtistName = _fakers.Performer.Generate().ArtistName!;
2727
DateTimeOffset newBornAt = _fakers.Performer.Generate().BornAt;
2828

29-
await _testContext.RunOnDatabaseAsync(dbContext => dbContext.ClearTableAsync<Performer>());
29+
await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.ClearTableAsync<Performer>());
3030

3131
string unknownPerformerId = Unknown.StringId.For<Performer, string?>();
3232

@@ -91,10 +91,10 @@ public async Task Can_rollback_updated_resource_on_error()
9191

9292
string newArtistName = _fakers.Performer.Generate().ArtistName!;
9393

94-
await _testContext.RunOnDatabaseAsync(dbContext =>
94+
await _testContext.RunOnDatabaseAsync(async dbContext =>
9595
{
9696
dbContext.Performers.Add(existingPerformer);
97-
return dbContext.SaveChangesAsync();
97+
await dbContext.SaveChangesAsync();
9898
});
9999

100100
string unknownPerformerId = Unknown.StringId.For<Performer, string?>();

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Transactions/LyricRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public LyricRepository(IMongoDataAccess mongoDataAccess, ITargetedFields targete
2626
_transaction = factory.BeginTransactionAsync(CancellationToken.None).Result;
2727
}
2828

29-
public ValueTask DisposeAsync()
29+
public async ValueTask DisposeAsync()
3030
{
31-
return _transaction.DisposeAsync();
31+
await _transaction.DisposeAsync();
3232
}
3333
}

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public async Task Cannot_add_to_OneToMany_relationship()
1919
MusicTrack existingTrack = _fakers.MusicTrack.Generate();
2020
Performer existingPerformer = _fakers.Performer.Generate();
2121

22-
await _testContext.RunOnDatabaseAsync(dbContext =>
22+
await _testContext.RunOnDatabaseAsync(async dbContext =>
2323
{
2424
dbContext.Performers.Add(existingPerformer);
2525
dbContext.MusicTracks.Add(existingTrack);
26-
return dbContext.SaveChangesAsync();
26+
await dbContext.SaveChangesAsync();
2727
});
2828

2929
var requestBody = new
@@ -76,11 +76,11 @@ public async Task Cannot_add_to_ManyToMany_relationship()
7676
Playlist existingPlaylist = _fakers.Playlist.Generate();
7777
MusicTrack existingTrack = _fakers.MusicTrack.Generate();
7878

79-
await _testContext.RunOnDatabaseAsync(dbContext =>
79+
await _testContext.RunOnDatabaseAsync(async dbContext =>
8080
{
8181
dbContext.MusicTracks.Add(existingTrack);
8282
dbContext.Playlists.Add(existingPlaylist);
83-
return dbContext.SaveChangesAsync();
83+
await dbContext.SaveChangesAsync();
8484
});
8585

8686
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public async Task Cannot_remove_from_OneToMany_relationship()
1919
MusicTrack existingTrack = _fakers.MusicTrack.Generate();
2020
existingTrack.Performers = _fakers.Performer.Generate(1);
2121

22-
await _testContext.RunOnDatabaseAsync(dbContext =>
22+
await _testContext.RunOnDatabaseAsync(async dbContext =>
2323
{
2424
dbContext.Performers.Add(existingTrack.Performers[0]);
2525
dbContext.MusicTracks.Add(existingTrack);
26-
return dbContext.SaveChangesAsync();
26+
await dbContext.SaveChangesAsync();
2727
});
2828

2929
var requestBody = new
@@ -76,11 +76,11 @@ public async Task Cannot_remove_from_ManyToMany_relationship()
7676
Playlist existingPlaylist = _fakers.Playlist.Generate();
7777
existingPlaylist.Tracks = _fakers.MusicTrack.Generate(1);
7878

79-
await _testContext.RunOnDatabaseAsync(dbContext =>
79+
await _testContext.RunOnDatabaseAsync(async dbContext =>
8080
{
8181
dbContext.MusicTracks.Add(existingPlaylist.Tracks[0]);
8282
dbContext.Playlists.Add(existingPlaylist);
83-
return dbContext.SaveChangesAsync();
83+
await dbContext.SaveChangesAsync();
8484
});
8585

8686
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public async Task Cannot_replace_OneToMany_relationship()
1919
MusicTrack existingTrack = _fakers.MusicTrack.Generate();
2020
Performer existingPerformer = _fakers.Performer.Generate();
2121

22-
await _testContext.RunOnDatabaseAsync(dbContext =>
22+
await _testContext.RunOnDatabaseAsync(async dbContext =>
2323
{
2424
dbContext.Performers.Add(existingPerformer);
2525
dbContext.MusicTracks.Add(existingTrack);
26-
return dbContext.SaveChangesAsync();
26+
await dbContext.SaveChangesAsync();
2727
});
2828

2929
var requestBody = new
@@ -76,11 +76,11 @@ public async Task Cannot_replace_ManyToMany_relationship()
7676
Playlist existingPlaylist = _fakers.Playlist.Generate();
7777
MusicTrack existingTrack = _fakers.MusicTrack.Generate();
7878

79-
await _testContext.RunOnDatabaseAsync(dbContext =>
79+
await _testContext.RunOnDatabaseAsync(async dbContext =>
8080
{
8181
dbContext.MusicTracks.Add(existingTrack);
8282
dbContext.Playlists.Add(existingPlaylist);
83-
return dbContext.SaveChangesAsync();
83+
await dbContext.SaveChangesAsync();
8484
});
8585

8686
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public async Task Cannot_create_ManyToOne_relationship()
1919
MusicTrack existingTrack = _fakers.MusicTrack.Generate();
2020
RecordCompany existingCompany = _fakers.RecordCompany.Generate();
2121

22-
await _testContext.RunOnDatabaseAsync(dbContext =>
22+
await _testContext.RunOnDatabaseAsync(async dbContext =>
2323
{
2424
dbContext.RecordCompanies.Add(existingCompany);
2525
dbContext.MusicTracks.Add(existingTrack);
26-
return dbContext.SaveChangesAsync();
26+
await dbContext.SaveChangesAsync();
2727
});
2828

2929
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public async Task Cannot_replace_ToMany_relationship()
1919
MusicTrack existingTrack = _fakers.MusicTrack.Generate();
2020
Performer existingPerformer = _fakers.Performer.Generate();
2121

22-
await _testContext.RunOnDatabaseAsync(dbContext =>
22+
await _testContext.RunOnDatabaseAsync(async dbContext =>
2323
{
2424
dbContext.Performers.Add(existingPerformer);
2525
dbContext.MusicTracks.Add(existingTrack);
26-
return dbContext.SaveChangesAsync();
26+
await dbContext.SaveChangesAsync();
2727
});
2828

2929
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ public async Task Can_update_resource_without_attributes_or_relationships()
8484
// Arrange
8585
MusicTrack existingTrack = _fakers.MusicTrack.Generate();
8686

87-
await _testContext.RunOnDatabaseAsync(dbContext =>
87+
await _testContext.RunOnDatabaseAsync(async dbContext =>
8888
{
8989
dbContext.MusicTracks.Add(existingTrack);
90-
return dbContext.SaveChangesAsync();
90+
await dbContext.SaveChangesAsync();
9191
});
9292

9393
var requestBody = new
@@ -139,10 +139,10 @@ public async Task Can_partially_update_resource_without_side_effects()
139139

140140
string newGenre = _fakers.MusicTrack.Generate().Genre!;
141141

142-
await _testContext.RunOnDatabaseAsync(dbContext =>
142+
await _testContext.RunOnDatabaseAsync(async dbContext =>
143143
{
144144
dbContext.MusicTracks.Add(existingTrack);
145-
return dbContext.SaveChangesAsync();
145+
await dbContext.SaveChangesAsync();
146146
});
147147

148148
var requestBody = new
@@ -197,10 +197,10 @@ public async Task Can_completely_update_resource_without_side_effects()
197197
string newGenre = _fakers.MusicTrack.Generate().Genre!;
198198
DateTimeOffset newReleasedAt = _fakers.MusicTrack.Generate().ReleasedAt;
199199

200-
await _testContext.RunOnDatabaseAsync(dbContext =>
200+
await _testContext.RunOnDatabaseAsync(async dbContext =>
201201
{
202202
dbContext.MusicTracks.Add(existingTrack);
203-
return dbContext.SaveChangesAsync();
203+
await dbContext.SaveChangesAsync();
204204
});
205205

206206
var requestBody = new
@@ -254,10 +254,10 @@ public async Task Can_update_resource_with_side_effects()
254254
TextLanguage existingLanguage = _fakers.TextLanguage.Generate();
255255
string newIsoCode = _fakers.TextLanguage.Generate().IsoCode!;
256256

257-
await _testContext.RunOnDatabaseAsync(dbContext =>
257+
await _testContext.RunOnDatabaseAsync(async dbContext =>
258258
{
259259
dbContext.TextLanguages.Add(existingLanguage);
260-
return dbContext.SaveChangesAsync();
260+
await dbContext.SaveChangesAsync();
261261
});
262262

263263
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public async Task Cannot_create_ToOne_relationship()
1919
Lyric existingLyric = _fakers.Lyric.Generate();
2020
MusicTrack existingTrack = _fakers.MusicTrack.Generate();
2121

22-
await _testContext.RunOnDatabaseAsync(dbContext =>
22+
await _testContext.RunOnDatabaseAsync(async dbContext =>
2323
{
2424
dbContext.MusicTracks.Add(existingTrack);
2525
dbContext.Lyrics.Add(existingLyric);
26-
return dbContext.SaveChangesAsync();
26+
await dbContext.SaveChangesAsync();
2727
});
2828

2929
var requestBody = new

test/JsonApiDotNetCoreMongoDbTests/IntegrationTests/Meta/TopLevelCountTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
5959
public async Task Renders_resource_count_for_empty_collection()
6060
{
6161
// Arrange
62-
await _testContext.RunOnDatabaseAsync(dbContext => dbContext.ClearTableAsync<SupportTicket>());
62+
await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.ClearTableAsync<SupportTicket>());
6363

6464
const string route = "/supportTickets";
6565

@@ -111,10 +111,10 @@ public async Task Hides_resource_count_in_update_resource_response()
111111

112112
string newDescription = _fakers.SupportTicket.Generate().Description;
113113

114-
await _testContext.RunOnDatabaseAsync(dbContext =>
114+
await _testContext.RunOnDatabaseAsync(async dbContext =>
115115
{
116116
dbContext.SupportTickets.Add(existingTicket);
117-
return dbContext.SaveChangesAsync();
117+
await dbContext.SaveChangesAsync();
118118
});
119119

120120
var requestBody = new

0 commit comments

Comments
 (0)