Skip to content

Commit 6ea3421

Browse files
committed
Use new formatting directives
1 parent 00b51e4 commit 6ea3421

File tree

53 files changed

+623
-734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+623
-734
lines changed

src/Examples/NoEntityFrameworkExample/Services/InMemoryResourceService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,16 @@ public Task<IReadOnlyCollection<TResource>> GetAsync(CancellationToken cancellat
8383
private void LogFiltersInTopScope()
8484
{
8585
// @formatter:wrap_chained_method_calls chop_always
86-
// @formatter:keep_existing_linebreaks true
86+
// @formatter:wrap_before_first_method_call true
8787

88-
FilterExpression[] filtersInTopScope = _constraintProviders.SelectMany(provider => provider.GetConstraints())
88+
FilterExpression[] filtersInTopScope = _constraintProviders
89+
.SelectMany(provider => provider.GetConstraints())
8990
.Where(constraint => constraint.Scope == null)
9091
.Select(constraint => constraint.Expression)
9192
.OfType<FilterExpression>()
9293
.ToArray();
9394

94-
// @formatter:keep_existing_linebreaks restore
95+
// @formatter:wrap_before_first_method_call restore
9596
// @formatter:wrap_chained_method_calls restore
9697

9798
FilterExpression? filter = LogicalExpression.Compose(LogicalOperator.And, filtersInTopScope);

src/JsonApiDotNetCore/Queries/EvaluatedIncludeCache.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ public void Set(IncludeExpression include)
3434
// then as a fallback, we feed the requested includes from query string to the response serializer.
3535

3636
// @formatter:wrap_chained_method_calls chop_always
37-
// @formatter:keep_existing_linebreaks true
37+
// @formatter:wrap_before_first_method_call true
3838

39-
_include = _constraintProviders.SelectMany(provider => provider.GetConstraints())
39+
_include = _constraintProviders
40+
.SelectMany(provider => provider.GetConstraints())
4041
.Where(constraint => constraint.Scope == null)
4142
.Select(constraint => constraint.Expression)
4243
.OfType<IncludeExpression>()
4344
.FirstOrDefault();
4445

45-
// @formatter:keep_existing_linebreaks restore
46+
// @formatter:wrap_before_first_method_call restore
4647
// @formatter:wrap_chained_method_calls restore
4748
_isAssigned = true;
4849
}

src/JsonApiDotNetCore/Queries/QueryLayerComposer.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ public QueryLayerComposer(IEnumerable<IQueryConstraintProvider> constraintProvid
4848
ExpressionInScope[] constraints = _constraintProviders.SelectMany(provider => provider.GetConstraints()).ToArray();
4949

5050
// @formatter:wrap_chained_method_calls chop_always
51-
// @formatter:keep_existing_linebreaks true
51+
// @formatter:wrap_before_first_method_call true
5252

5353
FilterExpression[] filtersInTopScope = constraints
5454
.Where(constraint => constraint.Scope == null)
5555
.Select(constraint => constraint.Expression)
5656
.OfType<FilterExpression>()
5757
.ToArray();
5858

59-
// @formatter:keep_existing_linebreaks restore
59+
// @formatter:wrap_before_first_method_call restore
6060
// @formatter:wrap_chained_method_calls restore
6161

6262
return GetFilter(filtersInTopScope, primaryResourceType);
@@ -83,15 +83,15 @@ public QueryLayerComposer(IEnumerable<IQueryConstraintProvider> constraintProvid
8383
ExpressionInScope[] constraints = _constraintProviders.SelectMany(provider => provider.GetConstraints()).ToArray();
8484

8585
// @formatter:wrap_chained_method_calls chop_always
86-
// @formatter:keep_existing_linebreaks true
86+
// @formatter:wrap_before_first_method_call true
8787

8888
FilterExpression[] filtersInSecondaryScope = constraints
8989
.Where(constraint => constraint.Scope == null)
9090
.Select(constraint => constraint.Expression)
9191
.OfType<FilterExpression>()
9292
.ToArray();
9393

94-
// @formatter:keep_existing_linebreaks restore
94+
// @formatter:wrap_before_first_method_call restore
9595
// @formatter:wrap_chained_method_calls restore
9696

9797
FilterExpression? primaryFilter = GetFilter(Array.Empty<QueryExpression>(), hasManyRelationship.LeftType);
@@ -146,14 +146,14 @@ private QueryLayer ComposeTopLayer(IEnumerable<ExpressionInScope> constraints, R
146146
using IDisposable _ = CodeTimingSessionManager.Current.Measure("Top-level query composition");
147147

148148
// @formatter:wrap_chained_method_calls chop_always
149-
// @formatter:keep_existing_linebreaks true
149+
// @formatter:wrap_before_first_method_call true
150150

151151
QueryExpression[] expressionsInTopScope = constraints
152152
.Where(constraint => constraint.Scope == null)
153153
.Select(constraint => constraint.Expression)
154154
.ToArray();
155155

156-
// @formatter:keep_existing_linebreaks restore
156+
// @formatter:wrap_before_first_method_call restore
157157
// @formatter:wrap_chained_method_calls restore
158158

159159
PaginationExpression topPagination = GetPagination(expressionsInTopScope, resourceType);
@@ -174,15 +174,15 @@ private IncludeExpression ComposeChildren(QueryLayer topLayer, ICollection<Expre
174174
using IDisposable _ = CodeTimingSessionManager.Current.Measure("Nested query composition");
175175

176176
// @formatter:wrap_chained_method_calls chop_always
177-
// @formatter:keep_existing_linebreaks true
177+
// @formatter:wrap_before_first_method_call true
178178

179179
IncludeExpression include = constraints
180180
.Where(constraint => constraint.Scope == null)
181181
.Select(constraint => constraint.Expression)
182182
.OfType<IncludeExpression>()
183183
.FirstOrDefault() ?? IncludeExpression.Empty;
184184

185-
// @formatter:keep_existing_linebreaks restore
185+
// @formatter:wrap_before_first_method_call restore
186186
// @formatter:wrap_chained_method_calls restore
187187

188188
IImmutableSet<IncludeElementExpression> includeElements = ProcessIncludeSet(include.Elements, topLayer, new List<RelationshipAttribute>(), constraints);
@@ -212,15 +212,14 @@ private IImmutableSet<IncludeElementExpression> ProcessIncludeSet(IImmutableSet<
212212
};
213213

214214
// @formatter:wrap_chained_method_calls chop_always
215-
// @formatter:keep_existing_linebreaks true
215+
// @formatter:wrap_before_first_method_call true
216216

217217
QueryExpression[] expressionsInCurrentScope = constraints
218-
.Where(constraint =>
219-
constraint.Scope != null && constraint.Scope.Fields.SequenceEqual(relationshipChain))
218+
.Where(constraint => constraint.Scope != null && constraint.Scope.Fields.SequenceEqual(relationshipChain))
220219
.Select(constraint => constraint.Expression)
221220
.ToArray();
222221

223-
// @formatter:keep_existing_linebreaks restore
222+
// @formatter:wrap_before_first_method_call restore
224223
// @formatter:wrap_chained_method_calls restore
225224

226225
ResourceType resourceType = includeElement.Relationship.RightType;

src/JsonApiDotNetCore/Queries/SparseFieldSetCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public SparseFieldSetCache(IEnumerable<IQueryConstraintProvider> constraintProvi
2929
private static IDictionary<ResourceType, IImmutableSet<ResourceFieldAttribute>> BuildSourceTable(IEnumerable<IQueryConstraintProvider> constraintProviders)
3030
{
3131
// @formatter:wrap_chained_method_calls chop_always
32-
// @formatter:keep_existing_linebreaks true
32+
// @formatter:wrap_before_first_method_call true
3333

3434
KeyValuePair<ResourceType, SparseFieldSetExpression>[] sparseFieldTables = constraintProviders
3535
.SelectMany(provider => provider.GetConstraints())
@@ -40,7 +40,7 @@ private static IDictionary<ResourceType, IImmutableSet<ResourceFieldAttribute>>
4040
.SelectMany(table => table)
4141
.ToArray();
4242

43-
// @formatter:keep_existing_linebreaks restore
43+
// @formatter:wrap_before_first_method_call restore
4444
// @formatter:wrap_chained_method_calls restore
4545

4646
var mergedTable = new Dictionary<ResourceType, ImmutableHashSet<ResourceFieldAttribute>.Builder>();

src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected virtual IQueryable<TResource> ApplyQueryLayer(QueryLayer queryLayer)
119119
IQueryable<TResource> source = GetAll();
120120

121121
// @formatter:wrap_chained_method_calls chop_always
122-
// @formatter:keep_existing_linebreaks true
122+
// @formatter:wrap_before_first_method_call true
123123

124124
QueryableHandlerExpression[] queryableHandlers = _constraintProviders
125125
.SelectMany(provider => provider.GetConstraints())
@@ -128,7 +128,7 @@ protected virtual IQueryable<TResource> ApplyQueryLayer(QueryLayer queryLayer)
128128
.OfType<QueryableHandlerExpression>()
129129
.ToArray();
130130

131-
// @formatter:keep_existing_linebreaks restore
131+
// @formatter:wrap_before_first_method_call restore
132132
// @formatter:wrap_chained_method_calls restore
133133

134134
foreach (QueryableHandlerExpression queryableHandler in queryableHandlers)
@@ -470,14 +470,14 @@ private IEnumerable GetRightValueToStoreForAddToToMany(TResource leftResource, H
470470
object? rightValueStored = relationship.GetValue(leftResource);
471471

472472
// @formatter:wrap_chained_method_calls chop_always
473-
// @formatter:keep_existing_linebreaks true
473+
// @formatter:wrap_before_first_method_call true
474474

475475
HashSet<IIdentifiable> rightResourceIdsStored = _collectionConverter
476476
.ExtractResources(rightValueStored)
477477
.Select(rightResource => _dbContext.GetTrackedOrAttach(rightResource))
478478
.ToHashSet(IdentifiableComparer.Instance);
479479

480-
// @formatter:keep_existing_linebreaks restore
480+
// @formatter:wrap_before_first_method_call restore
481481
// @formatter:wrap_chained_method_calls restore
482482

483483
if (rightResourceIdsStored.Any())
@@ -519,15 +519,15 @@ public virtual async Task RemoveFromToManyRelationshipAsync(TResource leftResour
519519
object? rightValueStored = relationship.GetValue(leftResourceTracked);
520520

521521
// @formatter:wrap_chained_method_calls chop_always
522-
// @formatter:keep_existing_linebreaks true
522+
// @formatter:wrap_before_first_method_call true
523523

524524
IIdentifiable[] rightResourceIdsStored = _collectionConverter
525525
.ExtractResources(rightValueStored)
526526
.Concat(extraResourceIdsToRemove)
527527
.Select(rightResource => _dbContext.GetTrackedOrAttach(rightResource))
528528
.ToArray();
529529

530-
// @formatter:keep_existing_linebreaks restore
530+
// @formatter:wrap_before_first_method_call restore
531531
// @formatter:wrap_chained_method_calls restore
532532

533533
rightValueStored = _collectionConverter.CopyToTypedCollection(rightResourceIdsStored, relationship.Property.PropertyType);

test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionBroadcastDefinition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private bool IsRequestingCollectionOfTelevisionBroadcasts()
7171
private bool IsIncludingCollectionOfTelevisionBroadcasts()
7272
{
7373
// @formatter:wrap_chained_method_calls chop_always
74-
// @formatter:keep_existing_linebreaks true
74+
// @formatter:wrap_before_first_method_call true
7575

7676
IncludeElementExpression[] includeElements = _constraintProviders
7777
.SelectMany(provider => provider.GetConstraints())
@@ -80,7 +80,7 @@ private bool IsIncludingCollectionOfTelevisionBroadcasts()
8080
.SelectMany(include => include.Elements)
8181
.ToArray();
8282

83-
// @formatter:keep_existing_linebreaks restore
83+
// @formatter:wrap_before_first_method_call restore
8484
// @formatter:wrap_chained_method_calls restore
8585

8686
foreach (IncludeElementExpression includeElement in includeElements)

test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionFakers.cs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
11
using Bogus;
22
using TestBuildingBlocks;
33

4-
// @formatter:wrap_chained_method_calls chop_always
5-
// @formatter:keep_existing_linebreaks true
4+
// @formatter:wrap_chained_method_calls chop_if_long
5+
// @formatter:wrap_before_first_method_call true
66

77
namespace JsonApiDotNetCoreTests.IntegrationTests.Archiving;
88

99
internal sealed class TelevisionFakers : FakerContainer
1010
{
11-
private readonly Lazy<Faker<TelevisionNetwork>> _lazyTelevisionNetworkFaker = new(() =>
12-
new Faker<TelevisionNetwork>()
13-
.UseSeed(GetFakerSeed())
14-
.RuleFor(network => network.Name, faker => faker.Company.CompanyName()));
11+
private readonly Lazy<Faker<TelevisionNetwork>> _lazyTelevisionNetworkFaker = new(() => new Faker<TelevisionNetwork>()
12+
.UseSeed(GetFakerSeed())
13+
.RuleFor(network => network.Name, faker => faker.Company.CompanyName()));
1514

16-
private readonly Lazy<Faker<TelevisionStation>> _lazyTelevisionStationFaker = new(() =>
17-
new Faker<TelevisionStation>()
18-
.UseSeed(GetFakerSeed())
19-
.RuleFor(station => station.Name, faker => faker.Company.CompanyName()));
15+
private readonly Lazy<Faker<TelevisionStation>> _lazyTelevisionStationFaker = new(() => new Faker<TelevisionStation>()
16+
.UseSeed(GetFakerSeed())
17+
.RuleFor(station => station.Name, faker => faker.Company.CompanyName()));
2018

21-
private readonly Lazy<Faker<TelevisionBroadcast>> _lazyTelevisionBroadcastFaker = new(() =>
22-
new Faker<TelevisionBroadcast>()
23-
.UseSeed(GetFakerSeed())
24-
.RuleFor(broadcast => broadcast.Title, faker => faker.Lorem.Sentence())
25-
.RuleFor(broadcast => broadcast.AiredAt, faker => faker.Date.PastOffset()
26-
.TruncateToWholeMilliseconds())
27-
.RuleFor(broadcast => broadcast.ArchivedAt, faker => faker.Date.RecentOffset()
28-
.TruncateToWholeMilliseconds()));
19+
private readonly Lazy<Faker<TelevisionBroadcast>> _lazyTelevisionBroadcastFaker = new(() => new Faker<TelevisionBroadcast>()
20+
.UseSeed(GetFakerSeed())
21+
.RuleFor(broadcast => broadcast.Title, faker => faker.Lorem.Sentence())
22+
.RuleFor(broadcast => broadcast.AiredAt, faker => faker.Date.PastOffset().TruncateToWholeMilliseconds())
23+
.RuleFor(broadcast => broadcast.ArchivedAt, faker => faker.Date.RecentOffset().TruncateToWholeMilliseconds()));
2924

30-
private readonly Lazy<Faker<BroadcastComment>> _lazyBroadcastCommentFaker = new(() =>
31-
new Faker<BroadcastComment>()
32-
.UseSeed(GetFakerSeed())
33-
.RuleFor(comment => comment.Text, faker => faker.Lorem.Paragraph())
34-
.RuleFor(comment => comment.CreatedAt, faker => faker.Date.PastOffset()
35-
.TruncateToWholeMilliseconds()));
25+
private readonly Lazy<Faker<BroadcastComment>> _lazyBroadcastCommentFaker = new(() => new Faker<BroadcastComment>()
26+
.UseSeed(GetFakerSeed())
27+
.RuleFor(comment => comment.Text, faker => faker.Lorem.Paragraph())
28+
.RuleFor(comment => comment.CreatedAt, faker => faker.Date.PastOffset().TruncateToWholeMilliseconds()));
3629

3730
public Faker<TelevisionNetwork> TelevisionNetwork => _lazyTelevisionNetworkFaker.Value;
3831
public Faker<TelevisionStation> TelevisionStation => _lazyTelevisionStationFaker.Value;

test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,15 +931,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
931931
await _testContext.RunOnDatabaseAsync(async dbContext =>
932932
{
933933
// @formatter:wrap_chained_method_calls chop_always
934-
// @formatter:keep_existing_linebreaks true
934+
// @formatter:wrap_after_property_in_chained_method_calls true
935935

936936
MusicTrack trackInDatabase = await dbContext.MusicTracks
937937
.Include(musicTrack => musicTrack.Lyric)
938938
.Include(musicTrack => musicTrack.OwnedBy)
939939
.Include(musicTrack => musicTrack.Performers)
940940
.FirstWithIdAsync(newTrackId);
941941

942-
// @formatter:keep_existing_linebreaks restore
942+
// @formatter:wrap_after_property_in_chained_method_calls restore
943943
// @formatter:wrap_chained_method_calls restore
944944

945945
trackInDatabase.Title.Should().Be(newTitle);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
241241
await _testContext.RunOnDatabaseAsync(async dbContext =>
242242
{
243243
// @formatter:wrap_chained_method_calls chop_always
244-
// @formatter:keep_existing_linebreaks true
244+
// @formatter:wrap_after_property_in_chained_method_calls true
245245

246246
List<MusicTrack> tracksInDatabase = await dbContext.MusicTracks
247247
.Include(musicTrack => musicTrack.OwnedBy)
248248
.Where(musicTrack => newTrackIds.Contains(musicTrack.Id))
249249
.ToListAsync();
250250

251-
// @formatter:keep_existing_linebreaks restore
251+
// @formatter:wrap_after_property_in_chained_method_calls restore
252252
// @formatter:wrap_chained_method_calls restore
253253

254254
tracksInDatabase.ShouldHaveCount(elementCount);

test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,14 @@ public async Task Can_update_resource_with_relationships_using_local_ID()
639639
await _testContext.RunOnDatabaseAsync(async dbContext =>
640640
{
641641
// @formatter:wrap_chained_method_calls chop_always
642-
// @formatter:keep_existing_linebreaks true
642+
// @formatter:wrap_after_property_in_chained_method_calls true
643643

644644
MusicTrack trackInDatabase = await dbContext.MusicTracks
645645
.Include(musicTrack => musicTrack.OwnedBy)
646646
.Include(musicTrack => musicTrack.Performers)
647647
.FirstWithIdAsync(newTrackId);
648648

649-
// @formatter:keep_existing_linebreaks restore
649+
// @formatter:wrap_after_property_in_chained_method_calls restore
650650
// @formatter:wrap_chained_method_calls restore
651651

652652
trackInDatabase.Title.Should().Be(newTrackTitle);

0 commit comments

Comments
 (0)