diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index ad89a48ac6..a787383114 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "jetbrains.resharper.globaltools": { - "version": "2023.1.2", + "version": "2023.2.1", "commands": [ "jb" ] diff --git a/src/Examples/NoEntityFrameworkExample/Services/InMemoryResourceService.cs b/src/Examples/NoEntityFrameworkExample/Services/InMemoryResourceService.cs index 510d750fa7..67c7a4138c 100644 --- a/src/Examples/NoEntityFrameworkExample/Services/InMemoryResourceService.cs +++ b/src/Examples/NoEntityFrameworkExample/Services/InMemoryResourceService.cs @@ -83,15 +83,16 @@ public Task> GetAsync(CancellationToken cancellat private void LogFiltersInTopScope() { // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true - FilterExpression[] filtersInTopScope = _constraintProviders.SelectMany(provider => provider.GetConstraints()) + FilterExpression[] filtersInTopScope = _constraintProviders + .SelectMany(provider => provider.GetConstraints()) .Where(constraint => constraint.Scope == null) .Select(constraint => constraint.Expression) .OfType() .ToArray(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore FilterExpression? filter = LogicalExpression.Compose(LogicalOperator.And, filtersInTopScope); diff --git a/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj.DotSettings b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj.DotSettings new file mode 100644 index 0000000000..c4bbbae949 --- /dev/null +++ b/src/JsonApiDotNetCore.SourceGenerators/JsonApiDotNetCore.SourceGenerators.csproj.DotSettings @@ -0,0 +1,5 @@ + + WARNING + WARNING + WARNING + diff --git a/src/JsonApiDotNetCore/Queries/EvaluatedIncludeCache.cs b/src/JsonApiDotNetCore/Queries/EvaluatedIncludeCache.cs index cfbb0ab46b..9aeb4f5d0d 100644 --- a/src/JsonApiDotNetCore/Queries/EvaluatedIncludeCache.cs +++ b/src/JsonApiDotNetCore/Queries/EvaluatedIncludeCache.cs @@ -34,15 +34,16 @@ public void Set(IncludeExpression include) // then as a fallback, we feed the requested includes from query string to the response serializer. // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true - _include = _constraintProviders.SelectMany(provider => provider.GetConstraints()) + _include = _constraintProviders + .SelectMany(provider => provider.GetConstraints()) .Where(constraint => constraint.Scope == null) .Select(constraint => constraint.Expression) .OfType() .FirstOrDefault(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore _isAssigned = true; } diff --git a/src/JsonApiDotNetCore/Queries/QueryLayerComposer.cs b/src/JsonApiDotNetCore/Queries/QueryLayerComposer.cs index fb4920d1a4..60f22a0613 100644 --- a/src/JsonApiDotNetCore/Queries/QueryLayerComposer.cs +++ b/src/JsonApiDotNetCore/Queries/QueryLayerComposer.cs @@ -48,7 +48,7 @@ public QueryLayerComposer(IEnumerable constraintProvid ExpressionInScope[] constraints = _constraintProviders.SelectMany(provider => provider.GetConstraints()).ToArray(); // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true FilterExpression[] filtersInTopScope = constraints .Where(constraint => constraint.Scope == null) @@ -56,7 +56,7 @@ public QueryLayerComposer(IEnumerable constraintProvid .OfType() .ToArray(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore return GetFilter(filtersInTopScope, primaryResourceType); @@ -83,7 +83,7 @@ public QueryLayerComposer(IEnumerable constraintProvid ExpressionInScope[] constraints = _constraintProviders.SelectMany(provider => provider.GetConstraints()).ToArray(); // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true FilterExpression[] filtersInSecondaryScope = constraints .Where(constraint => constraint.Scope == null) @@ -91,7 +91,7 @@ public QueryLayerComposer(IEnumerable constraintProvid .OfType() .ToArray(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore FilterExpression? primaryFilter = GetFilter(Array.Empty(), hasManyRelationship.LeftType); @@ -146,14 +146,14 @@ private QueryLayer ComposeTopLayer(IEnumerable constraints, R using IDisposable _ = CodeTimingSessionManager.Current.Measure("Top-level query composition"); // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true QueryExpression[] expressionsInTopScope = constraints .Where(constraint => constraint.Scope == null) .Select(constraint => constraint.Expression) .ToArray(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore PaginationExpression topPagination = GetPagination(expressionsInTopScope, resourceType); @@ -174,7 +174,7 @@ private IncludeExpression ComposeChildren(QueryLayer topLayer, ICollection constraint.Scope == null) @@ -182,7 +182,7 @@ private IncludeExpression ComposeChildren(QueryLayer topLayer, ICollection() .FirstOrDefault() ?? IncludeExpression.Empty; - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore IImmutableSet includeElements = ProcessIncludeSet(include.Elements, topLayer, new List(), constraints); @@ -212,15 +212,14 @@ private IImmutableSet ProcessIncludeSet(IImmutableSet< }; // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true QueryExpression[] expressionsInCurrentScope = constraints - .Where(constraint => - constraint.Scope != null && constraint.Scope.Fields.SequenceEqual(relationshipChain)) + .Where(constraint => constraint.Scope != null && constraint.Scope.Fields.SequenceEqual(relationshipChain)) .Select(constraint => constraint.Expression) .ToArray(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore ResourceType resourceType = includeElement.Relationship.RightType; diff --git a/src/JsonApiDotNetCore/Queries/SparseFieldSetCache.cs b/src/JsonApiDotNetCore/Queries/SparseFieldSetCache.cs index 57df16c62b..70847adf6d 100644 --- a/src/JsonApiDotNetCore/Queries/SparseFieldSetCache.cs +++ b/src/JsonApiDotNetCore/Queries/SparseFieldSetCache.cs @@ -29,7 +29,7 @@ public SparseFieldSetCache(IEnumerable constraintProvi private static IDictionary> BuildSourceTable(IEnumerable constraintProviders) { // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true KeyValuePair[] sparseFieldTables = constraintProviders .SelectMany(provider => provider.GetConstraints()) @@ -40,7 +40,7 @@ private static IDictionary> .SelectMany(table => table) .ToArray(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore var mergedTable = new Dictionary.Builder>(); diff --git a/src/JsonApiDotNetCore/QueryStrings/IncludeQueryStringParameterReader.cs b/src/JsonApiDotNetCore/QueryStrings/IncludeQueryStringParameterReader.cs index b5fde463ee..de144de7c5 100644 --- a/src/JsonApiDotNetCore/QueryStrings/IncludeQueryStringParameterReader.cs +++ b/src/JsonApiDotNetCore/QueryStrings/IncludeQueryStringParameterReader.cs @@ -47,10 +47,14 @@ public virtual void Read(string parameterName, StringValues parameterValue) { try { + // Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment + // ReSharper disable once AssignNullToNotNullAttribute _includeExpression = GetInclude(parameterValue.ToString()); } catch (QueryParseException exception) { + // Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment + // ReSharper disable once AssignNullToNotNullAttribute string specificMessage = exception.GetMessageWithPosition(parameterValue.ToString()); throw new InvalidQueryStringParameterException(parameterName, "The specified include is invalid.", specificMessage, exception); } diff --git a/src/JsonApiDotNetCore/QueryStrings/PaginationQueryStringParameterReader.cs b/src/JsonApiDotNetCore/QueryStrings/PaginationQueryStringParameterReader.cs index 86feed30bf..93e180275a 100644 --- a/src/JsonApiDotNetCore/QueryStrings/PaginationQueryStringParameterReader.cs +++ b/src/JsonApiDotNetCore/QueryStrings/PaginationQueryStringParameterReader.cs @@ -58,6 +58,8 @@ public virtual void Read(string parameterName, StringValues parameterValue) try { + // Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment + // ReSharper disable once AssignNullToNotNullAttribute PaginationQueryStringValueExpression constraint = GetPageConstraint(parameterValue.ToString()); if (constraint.Elements.Any(element => element.Scope == null)) @@ -80,6 +82,8 @@ public virtual void Read(string parameterName, StringValues parameterValue) } catch (QueryParseException exception) { + // Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment + // ReSharper disable once AssignNullToNotNullAttribute string specificMessage = exception.GetMessageWithPosition(isParameterNameValid ? parameterValue.ToString() : parameterName); throw new InvalidQueryStringParameterException(parameterName, "The specified pagination is invalid.", specificMessage, exception); } diff --git a/src/JsonApiDotNetCore/QueryStrings/SortQueryStringParameterReader.cs b/src/JsonApiDotNetCore/QueryStrings/SortQueryStringParameterReader.cs index 9fb98581de..542d69b8ec 100644 --- a/src/JsonApiDotNetCore/QueryStrings/SortQueryStringParameterReader.cs +++ b/src/JsonApiDotNetCore/QueryStrings/SortQueryStringParameterReader.cs @@ -59,12 +59,16 @@ public virtual void Read(string parameterName, StringValues parameterValue) ResourceFieldChainExpression? scope = GetScope(parameterName); parameterNameIsValid = true; + // Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment + // ReSharper disable once AssignNullToNotNullAttribute SortExpression sort = GetSort(parameterValue.ToString(), scope); var expressionInScope = new ExpressionInScope(scope, sort); _constraints.Add(expressionInScope); } catch (QueryParseException exception) { + // Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment + // ReSharper disable once AssignNullToNotNullAttribute string specificMessage = exception.GetMessageWithPosition(parameterNameIsValid ? parameterValue.ToString() : parameterName); throw new InvalidQueryStringParameterException(parameterName, "The specified sort is invalid.", specificMessage, exception); } diff --git a/src/JsonApiDotNetCore/QueryStrings/SparseFieldSetQueryStringParameterReader.cs b/src/JsonApiDotNetCore/QueryStrings/SparseFieldSetQueryStringParameterReader.cs index d79e9c98ed..9757383c39 100644 --- a/src/JsonApiDotNetCore/QueryStrings/SparseFieldSetQueryStringParameterReader.cs +++ b/src/JsonApiDotNetCore/QueryStrings/SparseFieldSetQueryStringParameterReader.cs @@ -63,11 +63,15 @@ public virtual void Read(string parameterName, StringValues parameterValue) ResourceType resourceType = GetScope(parameterName); parameterNameIsValid = true; + // Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment + // ReSharper disable once AssignNullToNotNullAttribute SparseFieldSetExpression sparseFieldSet = GetSparseFieldSet(parameterValue.ToString(), resourceType); _sparseFieldTableBuilder[resourceType] = sparseFieldSet; } catch (QueryParseException exception) { + // Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment + // ReSharper disable once AssignNullToNotNullAttribute string specificMessage = exception.GetMessageWithPosition(parameterNameIsValid ? parameterValue.ToString() : parameterName); throw new InvalidQueryStringParameterException(parameterName, "The specified fieldset is invalid.", specificMessage, exception); } diff --git a/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs b/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs index ca30c222c9..4c3314ddab 100644 --- a/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs +++ b/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs @@ -119,7 +119,7 @@ protected virtual IQueryable ApplyQueryLayer(QueryLayer queryLayer) IQueryable source = GetAll(); // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true QueryableHandlerExpression[] queryableHandlers = _constraintProviders .SelectMany(provider => provider.GetConstraints()) @@ -128,7 +128,7 @@ protected virtual IQueryable ApplyQueryLayer(QueryLayer queryLayer) .OfType() .ToArray(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore foreach (QueryableHandlerExpression queryableHandler in queryableHandlers) @@ -470,14 +470,14 @@ private IEnumerable GetRightValueToStoreForAddToToMany(TResource leftResource, H object? rightValueStored = relationship.GetValue(leftResource); // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true HashSet rightResourceIdsStored = _collectionConverter .ExtractResources(rightValueStored) .Select(rightResource => _dbContext.GetTrackedOrAttach(rightResource)) .ToHashSet(IdentifiableComparer.Instance); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore if (rightResourceIdsStored.Any()) @@ -519,7 +519,7 @@ public virtual async Task RemoveFromToManyRelationshipAsync(TResource leftResour object? rightValueStored = relationship.GetValue(leftResourceTracked); // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true IIdentifiable[] rightResourceIdsStored = _collectionConverter .ExtractResources(rightValueStored) @@ -527,7 +527,7 @@ public virtual async Task RemoveFromToManyRelationshipAsync(TResource leftResour .Select(rightResource => _dbContext.GetTrackedOrAttach(rightResource)) .ToArray(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore rightValueStored = _collectionConverter.CopyToTypedCollection(rightResourceIdsStored, relationship.Property.PropertyType); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionBroadcastDefinition.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionBroadcastDefinition.cs index 4037f59b62..ddac26d61f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionBroadcastDefinition.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionBroadcastDefinition.cs @@ -71,7 +71,7 @@ private bool IsRequestingCollectionOfTelevisionBroadcasts() private bool IsIncludingCollectionOfTelevisionBroadcasts() { // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_before_first_method_call true IncludeElementExpression[] includeElements = _constraintProviders .SelectMany(provider => provider.GetConstraints()) @@ -80,7 +80,7 @@ private bool IsIncludingCollectionOfTelevisionBroadcasts() .SelectMany(include => include.Elements) .ToArray(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_before_first_method_call restore // @formatter:wrap_chained_method_calls restore foreach (IncludeElementExpression includeElement in includeElements) diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionFakers.cs index 6c3116d789..18b5536f36 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/TelevisionFakers.cs @@ -1,38 +1,31 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.Archiving; internal sealed class TelevisionFakers : FakerContainer { - private readonly Lazy> _lazyTelevisionNetworkFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(network => network.Name, faker => faker.Company.CompanyName())); + private readonly Lazy> _lazyTelevisionNetworkFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(network => network.Name, faker => faker.Company.CompanyName())); - private readonly Lazy> _lazyTelevisionStationFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(station => station.Name, faker => faker.Company.CompanyName())); + private readonly Lazy> _lazyTelevisionStationFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(station => station.Name, faker => faker.Company.CompanyName())); - private readonly Lazy> _lazyTelevisionBroadcastFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(broadcast => broadcast.Title, faker => faker.Lorem.Sentence()) - .RuleFor(broadcast => broadcast.AiredAt, faker => faker.Date.PastOffset() - .TruncateToWholeMilliseconds()) - .RuleFor(broadcast => broadcast.ArchivedAt, faker => faker.Date.RecentOffset() - .TruncateToWholeMilliseconds())); + private readonly Lazy> _lazyTelevisionBroadcastFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(broadcast => broadcast.Title, faker => faker.Lorem.Sentence()) + .RuleFor(broadcast => broadcast.AiredAt, faker => faker.Date.PastOffset().TruncateToWholeMilliseconds()) + .RuleFor(broadcast => broadcast.ArchivedAt, faker => faker.Date.RecentOffset().TruncateToWholeMilliseconds())); - private readonly Lazy> _lazyBroadcastCommentFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(comment => comment.Text, faker => faker.Lorem.Paragraph()) - .RuleFor(comment => comment.CreatedAt, faker => faker.Date.PastOffset() - .TruncateToWholeMilliseconds())); + private readonly Lazy> _lazyBroadcastCommentFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(comment => comment.Text, faker => faker.Lorem.Paragraph()) + .RuleFor(comment => comment.CreatedAt, faker => faker.Date.PastOffset().TruncateToWholeMilliseconds())); public Faker TelevisionNetwork => _lazyTelevisionNetworkFaker.Value; public Faker TelevisionStation => _lazyTelevisionStationFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs index 5aff75498d..3331b1f1cc 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs @@ -931,7 +931,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_after_property_in_chained_method_calls true MusicTrack trackInDatabase = await dbContext.MusicTracks .Include(musicTrack => musicTrack.Lyric) @@ -939,7 +939,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => .Include(musicTrack => musicTrack.Performers) .FirstWithIdAsync(newTrackId); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore trackInDatabase.Title.Should().Be(newTitle); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs index 0112dc9ed4..5d138404ba 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs @@ -241,14 +241,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_after_property_in_chained_method_calls true List tracksInDatabase = await dbContext.MusicTracks .Include(musicTrack => musicTrack.OwnedBy) .Where(musicTrack => newTrackIds.Contains(musicTrack.Id)) .ToListAsync(); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore tracksInDatabase.ShouldHaveCount(elementCount); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs index 39768280bd..df5bc5f90b 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs @@ -639,14 +639,14 @@ public async Task Can_update_resource_with_relationships_using_local_ID() await _testContext.RunOnDatabaseAsync(async dbContext => { // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_after_property_in_chained_method_calls true MusicTrack trackInDatabase = await dbContext.MusicTracks .Include(musicTrack => musicTrack.OwnedBy) .Include(musicTrack => musicTrack.Performers) .FirstWithIdAsync(newTrackId); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore trackInDatabase.Title.Should().Be(newTrackTitle); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/OperationsFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/OperationsFakers.cs index 8cf3c07e41..6666a4ffb9 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/OperationsFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/OperationsFakers.cs @@ -2,57 +2,48 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.AtomicOperations; internal sealed class OperationsFakers : FakerContainer { - private static readonly Lazy> LazyLanguageIsoCodes = - new(() => CultureInfo - .GetCultures(CultureTypes.NeutralCultures) - .Where(culture => !string.IsNullOrEmpty(culture.Name)) - .Select(culture => culture.Name) - .ToArray()); - - private readonly Lazy> _lazyPlaylistFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(playlist => playlist.Name, faker => faker.Lorem.Sentence())); - - private readonly Lazy> _lazyMusicTrackFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(musicTrack => musicTrack.Title, faker => faker.Lorem.Word()) - .RuleFor(musicTrack => musicTrack.LengthInSeconds, faker => faker.Random.Decimal(3 * 60, 5 * 60)) - .RuleFor(musicTrack => musicTrack.Genre, faker => faker.Lorem.Word()) - .RuleFor(musicTrack => musicTrack.ReleasedAt, faker => faker.Date.PastOffset() - .TruncateToWholeMilliseconds())); - - private readonly Lazy> _lazyLyricFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(lyric => lyric.Text, faker => faker.Lorem.Text()) - .RuleFor(lyric => lyric.Format, "LRC")); - - private readonly Lazy> _lazyTextLanguageFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(textLanguage => textLanguage.IsoCode, faker => faker.PickRandom(LazyLanguageIsoCodes.Value))); - - private readonly Lazy> _lazyPerformerFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(performer => performer.ArtistName, faker => faker.Name.FullName()) - .RuleFor(performer => performer.BornAt, faker => faker.Date.PastOffset() - .TruncateToWholeMilliseconds())); - - private readonly Lazy> _lazyRecordCompanyFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(recordCompany => recordCompany.Name, faker => faker.Company.CompanyName()) - .RuleFor(recordCompany => recordCompany.CountryOfResidence, faker => faker.Address.Country())); + private static readonly Lazy> LazyLanguageIsoCodes = new(() => CultureInfo + .GetCultures(CultureTypes.NeutralCultures) + .Where(culture => !string.IsNullOrEmpty(culture.Name)) + .Select(culture => culture.Name) + .ToArray()); + + private readonly Lazy> _lazyPlaylistFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(playlist => playlist.Name, faker => faker.Lorem.Sentence())); + + private readonly Lazy> _lazyMusicTrackFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(musicTrack => musicTrack.Title, faker => faker.Lorem.Word()) + .RuleFor(musicTrack => musicTrack.LengthInSeconds, faker => faker.Random.Decimal(3 * 60, 5 * 60)) + .RuleFor(musicTrack => musicTrack.Genre, faker => faker.Lorem.Word()) + .RuleFor(musicTrack => musicTrack.ReleasedAt, faker => faker.Date.PastOffset().TruncateToWholeMilliseconds())); + + private readonly Lazy> _lazyLyricFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(lyric => lyric.Text, faker => faker.Lorem.Text()) + .RuleFor(lyric => lyric.Format, "LRC")); + + private readonly Lazy> _lazyTextLanguageFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(textLanguage => textLanguage.IsoCode, faker => faker.PickRandom(LazyLanguageIsoCodes.Value))); + + private readonly Lazy> _lazyPerformerFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(performer => performer.ArtistName, faker => faker.Name.FullName()) + .RuleFor(performer => performer.BornAt, faker => faker.Date.PastOffset().TruncateToWholeMilliseconds())); + + private readonly Lazy> _lazyRecordCompanyFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(recordCompany => recordCompany.Name, faker => faker.Company.CompanyName()) + .RuleFor(recordCompany => recordCompany.CountryOfResidence, faker => faker.Address.Country())); public Faker Playlist => _lazyPlaylistFaker.Value; public Faker MusicTrack => _lazyMusicTrackFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs index 4b0a10fd82..895d1a0df5 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs @@ -1742,7 +1742,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_after_property_in_chained_method_calls true MusicTrack trackInDatabase = await dbContext.MusicTracks .Include(musicTrack => musicTrack.Lyric) @@ -1750,7 +1750,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => .Include(musicTrack => musicTrack.Performers) .FirstWithIdAsync(existingTrack.Id); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore trackInDatabase.Title.Should().Be(existingTrack.Title); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/BlobFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/BlobFakers.cs index 924b67dfa3..22f5a20d36 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/BlobFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/BlobFakers.cs @@ -1,19 +1,18 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.Blobs; internal sealed class BlobFakers : FakerContainer { - private readonly Lazy> _lazyImageContainerFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(imageContainer => imageContainer.FileName, faker => faker.System.FileName()) - .RuleFor(imageContainer => imageContainer.Data, faker => faker.Random.Bytes(128)) - .RuleFor(imageContainer => imageContainer.Thumbnail, faker => faker.Random.Bytes(64))); + private readonly Lazy> _lazyImageContainerFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(imageContainer => imageContainer.FileName, faker => faker.System.FileName()) + .RuleFor(imageContainer => imageContainer.Data, faker => faker.Random.Bytes(128)) + .RuleFor(imageContainer => imageContainer.Thumbnail, faker => faker.Random.Bytes(64))); public Faker ImageContainer => _lazyImageContainerFaker.Value; } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/CompositeKeys/CompositeKeyFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/CompositeKeys/CompositeKeyFakers.cs index ce3a4455d1..e64e7bf8b2 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/CompositeKeys/CompositeKeyFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/CompositeKeys/CompositeKeyFakers.cs @@ -1,28 +1,25 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.CompositeKeys; internal sealed class CompositeKeyFakers : FakerContainer { - private readonly Lazy> _lazyCarFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(car => car.LicensePlate, faker => faker.Random.Replace("??-??-##")) - .RuleFor(car => car.RegionId, faker => faker.Random.Long(100, 999))); + private readonly Lazy> _lazyCarFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(car => car.LicensePlate, faker => faker.Random.Replace("??-??-##")) + .RuleFor(car => car.RegionId, faker => faker.Random.Long(100, 999))); - private readonly Lazy> _lazyEngineFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(engine => engine.SerialCode, faker => faker.Random.Replace("????-????"))); + private readonly Lazy> _lazyEngineFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(engine => engine.SerialCode, faker => faker.Random.Replace("????-????"))); - private readonly Lazy> _lazyDealershipFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(dealership => dealership.Address, faker => faker.Address.FullAddress())); + private readonly Lazy> _lazyDealershipFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(dealership => dealership.Address, faker => faker.Address.FullAddress())); public Faker Car => _lazyCarFaker.Value; public Faker Engine => _lazyEngineFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/CustomRouteFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/CustomRouteFakers.cs index d9416d99ab..5a0452010c 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/CustomRouteFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/CustomRouteFakers.cs @@ -1,24 +1,22 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.CustomRoutes; internal sealed class CustomRouteFakers : FakerContainer { - private readonly Lazy> _lazyTownFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(town => town.Name, faker => faker.Address.City()) - .RuleFor(town => town.Latitude, faker => faker.Address.Latitude()) - .RuleFor(town => town.Longitude, faker => faker.Address.Longitude())); + private readonly Lazy> _lazyTownFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(town => town.Name, faker => faker.Address.City()) + .RuleFor(town => town.Latitude, faker => faker.Address.Latitude()) + .RuleFor(town => town.Longitude, faker => faker.Address.Longitude())); - private readonly Lazy> _lazyCivilianFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(civilian => civilian.Name, faker => faker.Person.FullName)); + private readonly Lazy> _lazyCivilianFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(civilian => civilian.Name, faker => faker.Person.FullName)); public Faker Town => _lazyTownFaker.Value; public Faker Civilian => _lazyCivilianFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingFakers.cs index 0ac7eb6804..77e25a8192 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingFakers.cs @@ -1,43 +1,37 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.EagerLoading; internal sealed class EagerLoadingFakers : FakerContainer { - private readonly Lazy> _lazyStateFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(state => state.Name, faker => faker.Address.City())); - - private readonly Lazy> _lazyCityFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(city => city.Name, faker => faker.Address.City())); - - private readonly Lazy> _lazyStreetFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(street => street.Name, faker => faker.Address.StreetName())); - - private readonly Lazy> _lazyBuildingFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(building => building.Number, faker => faker.Address.BuildingNumber())); - - private readonly Lazy> _lazyWindowFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(window => window.HeightInCentimeters, faker => faker.Random.Number(30, 199)) - .RuleFor(window => window.WidthInCentimeters, faker => faker.Random.Number(30, 199))); - - private readonly Lazy> _lazyDoorFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(door => door.Color, faker => faker.Commerce.Color())); + private readonly Lazy> _lazyStateFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(state => state.Name, faker => faker.Address.City())); + + private readonly Lazy> _lazyCityFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(city => city.Name, faker => faker.Address.City())); + + private readonly Lazy> _lazyStreetFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(street => street.Name, faker => faker.Address.StreetName())); + + private readonly Lazy> _lazyBuildingFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(building => building.Number, faker => faker.Address.BuildingNumber())); + + private readonly Lazy> _lazyWindowFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(window => window.HeightInCentimeters, faker => faker.Random.Number(30, 199)) + .RuleFor(window => window.WidthInCentimeters, faker => faker.Random.Number(30, 199))); + + private readonly Lazy> _lazyDoorFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(door => door.Color, faker => faker.Commerce.Color())); public Faker State => _lazyStateFaker.Value; public Faker City => _lazyCityFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs index b65d9765f7..5d2ddf0ece 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs @@ -245,7 +245,7 @@ public async Task Can_create_resource() await _testContext.RunOnDatabaseAsync(async dbContext => { // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_after_property_in_chained_method_calls true Building? buildingInDatabase = await dbContext.Buildings .Include(building => building.PrimaryDoor) @@ -253,7 +253,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => .Include(building => building.Windows) .FirstWithIdOrDefaultAsync(newBuildingId); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore buildingInDatabase.ShouldNotBeNull(); @@ -310,7 +310,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { // @formatter:wrap_chained_method_calls chop_always - // @formatter:keep_existing_linebreaks true + // @formatter:wrap_after_property_in_chained_method_calls true Building? buildingInDatabase = await dbContext.Buildings .Include(building => building.PrimaryDoor) @@ -318,7 +318,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => .Include(building => building.Windows) .FirstWithIdOrDefaultAsync(existingBuilding.Id); - // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore buildingInDatabase.ShouldNotBeNull(); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/HostingInIIS/HostingFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/HostingInIIS/HostingFakers.cs index 93734a6f08..33bd79ba9d 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/HostingInIIS/HostingFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/HostingInIIS/HostingFakers.cs @@ -1,22 +1,20 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.HostingInIIS; internal sealed class HostingFakers : FakerContainer { - private readonly Lazy> _lazyArtGalleryFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(artGallery => artGallery.Theme, faker => faker.Lorem.Word())); + private readonly Lazy> _lazyArtGalleryFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(artGallery => artGallery.Theme, faker => faker.Lorem.Word())); - private readonly Lazy> _lazyPaintingFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(painting => painting.Title, faker => faker.Lorem.Sentence())); + private readonly Lazy> _lazyPaintingFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(painting => painting.Title, faker => faker.Lorem.Sentence())); public Faker ArtGallery => _lazyArtGalleryFaker.Value; public Faker Painting => _lazyPaintingFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationFakers.cs index 201089d15b..2755d1ebcb 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationFakers.cs @@ -1,23 +1,21 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; internal sealed class ObfuscationFakers : FakerContainer { - private readonly Lazy> _lazyBankAccountFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(bankAccount => bankAccount.Iban, faker => faker.Finance.Iban())); + private readonly Lazy> _lazyBankAccountFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(bankAccount => bankAccount.Iban, faker => faker.Finance.Iban())); - private readonly Lazy> _lazyDebitCardFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(debitCard => debitCard.OwnerName, faker => faker.Name.FullName()) - .RuleFor(debitCard => debitCard.PinCode, faker => (short)faker.Random.Number(1000, 9999))); + private readonly Lazy> _lazyDebitCardFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(debitCard => debitCard.OwnerName, faker => faker.Name.FullName()) + .RuleFor(debitCard => debitCard.PinCode, faker => (short)faker.Random.Number(1000, 9999))); public Faker BankAccount => _lazyBankAccountFaker.Value; public Faker DebitCard => _lazyDebitCardFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateFakers.cs index a16e9a97b7..1939a168dc 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateFakers.cs @@ -2,8 +2,8 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.InputValidation.ModelState; @@ -15,25 +15,22 @@ internal sealed class ModelStateFakers : FakerContainer private static readonly TimeOnly MinCreatedAt = TimeOnly.Parse("09:00:00", CultureInfo.InvariantCulture); private static readonly TimeOnly MaxCreatedAt = TimeOnly.Parse("17:30:00", CultureInfo.InvariantCulture); - private readonly Lazy> _lazySystemVolumeFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(systemVolume => systemVolume.Name, faker => faker.Lorem.Word())); - - private readonly Lazy> _lazySystemFileFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(systemFile => systemFile.FileName, faker => faker.System.FileName()) - .RuleFor(systemFile => systemFile.Attributes, faker => faker.Random.Enum(FileAttributes.Normal, FileAttributes.Hidden, FileAttributes.ReadOnly)) - .RuleFor(systemFile => systemFile.SizeInBytes, faker => faker.Random.Long(0, 1_000_000)) - .RuleFor(systemFile => systemFile.CreatedOn, faker => faker.Date.BetweenDateOnly(MinCreatedOn, MaxCreatedOn)) - .RuleFor(systemFile => systemFile.CreatedAt, faker => faker.Date.BetweenTimeOnly(MinCreatedAt, MaxCreatedAt))); - - private readonly Lazy> _lazySystemDirectoryFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(systemDirectory => systemDirectory.Name, faker => Path.GetFileNameWithoutExtension(faker.System.FileName())) - .RuleFor(systemDirectory => systemDirectory.IsCaseSensitive, faker => faker.Random.Bool())); + private readonly Lazy> _lazySystemVolumeFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(systemVolume => systemVolume.Name, faker => faker.Lorem.Word())); + + private readonly Lazy> _lazySystemFileFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(systemFile => systemFile.FileName, faker => faker.System.FileName()) + .RuleFor(systemFile => systemFile.Attributes, faker => faker.Random.Enum(FileAttributes.Normal, FileAttributes.Hidden, FileAttributes.ReadOnly)) + .RuleFor(systemFile => systemFile.SizeInBytes, faker => faker.Random.Long(0, 1_000_000)) + .RuleFor(systemFile => systemFile.CreatedOn, faker => faker.Date.BetweenDateOnly(MinCreatedOn, MaxCreatedOn)) + .RuleFor(systemFile => systemFile.CreatedAt, faker => faker.Date.BetweenTimeOnly(MinCreatedAt, MaxCreatedAt))); + + private readonly Lazy> _lazySystemDirectoryFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(systemDirectory => systemDirectory.Name, faker => Path.GetFileNameWithoutExtension(faker.System.FileName())) + .RuleFor(systemDirectory => systemDirectory.IsCaseSensitive, faker => faker.Random.Bool())); public Faker SystemVolume => _lazySystemVolumeFaker.Value; public Faker SystemFile => _lazySystemFileFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinksFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinksFakers.cs index bd34d85cf5..a1acafeb7d 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinksFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinksFakers.cs @@ -1,29 +1,26 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.Links; internal sealed class LinksFakers : FakerContainer { - private readonly Lazy> _lazyPhotoAlbumFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(photoAlbum => photoAlbum.Name, faker => faker.Lorem.Sentence())); + private readonly Lazy> _lazyPhotoAlbumFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(photoAlbum => photoAlbum.Name, faker => faker.Lorem.Sentence())); - private readonly Lazy> _lazyPhotoFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(photo => photo.Url, faker => faker.Image.PlaceImgUrl())); + private readonly Lazy> _lazyPhotoFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(photo => photo.Url, faker => faker.Image.PlaceImgUrl())); - private readonly Lazy> _lazyPhotoLocationFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(photoLocation => photoLocation.PlaceName, faker => faker.Address.FullAddress()) - .RuleFor(photoLocation => photoLocation.Latitude, faker => faker.Address.Latitude()) - .RuleFor(photoLocation => photoLocation.Longitude, faker => faker.Address.Longitude())); + private readonly Lazy> _lazyPhotoLocationFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(photoLocation => photoLocation.PlaceName, faker => faker.Address.FullAddress()) + .RuleFor(photoLocation => photoLocation.Latitude, faker => faker.Address.Latitude()) + .RuleFor(photoLocation => photoLocation.Longitude, faker => faker.Address.Longitude())); public Faker PhotoAlbum => _lazyPhotoAlbumFaker.Value; public Faker Photo => _lazyPhotoFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Logging/LoggingFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Logging/LoggingFakers.cs index 1c467dc782..5d2b25a74c 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Logging/LoggingFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Logging/LoggingFakers.cs @@ -1,19 +1,17 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.Logging; internal sealed class LoggingFakers : FakerContainer { - private readonly Lazy> _lazyAuditEntryFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(auditEntry => auditEntry.UserName, faker => faker.Internet.UserName()) - .RuleFor(auditEntry => auditEntry.CreatedAt, faker => faker.Date.PastOffset() - .TruncateToWholeMilliseconds())); + private readonly Lazy> _lazyAuditEntryFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(auditEntry => auditEntry.UserName, faker => faker.Internet.UserName()) + .RuleFor(auditEntry => auditEntry.CreatedAt, faker => faker.Date.PastOffset().TruncateToWholeMilliseconds())); public Faker AuditEntry => _lazyAuditEntryFaker.Value; } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Meta/MetaFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Meta/MetaFakers.cs index 726dd82923..c6cd2b5859 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Meta/MetaFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Meta/MetaFakers.cs @@ -1,22 +1,20 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.Meta; internal sealed class MetaFakers : FakerContainer { - private readonly Lazy> _lazyProductFamilyFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(productFamily => productFamily.Name, faker => faker.Commerce.ProductName())); + private readonly Lazy> _lazyProductFamilyFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(productFamily => productFamily.Name, faker => faker.Commerce.ProductName())); - private readonly Lazy> _lazySupportTicketFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(supportTicket => supportTicket.Description, faker => faker.Lorem.Paragraph())); + private readonly Lazy> _lazySupportTicketFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(supportTicket => supportTicket.Description, faker => faker.Lorem.Paragraph())); public Faker ProductFamily => _lazyProductFamilyFaker.Value; public Faker SupportTicket => _lazySupportTicketFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/DomainFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/DomainFakers.cs index 8109dadf31..54d3812b97 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/DomainFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/DomainFakers.cs @@ -1,23 +1,21 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.Microservices; internal sealed class DomainFakers : FakerContainer { - private readonly Lazy> _lazyDomainUserFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(domainUser => domainUser.LoginName, faker => faker.Person.UserName) - .RuleFor(domainUser => domainUser.DisplayName, faker => faker.Person.FullName)); + private readonly Lazy> _lazyDomainUserFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(domainUser => domainUser.LoginName, faker => faker.Person.UserName) + .RuleFor(domainUser => domainUser.DisplayName, faker => faker.Person.FullName)); - private readonly Lazy> _lazyDomainGroupFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(domainGroup => domainGroup.Name, faker => faker.Commerce.Department())); + private readonly Lazy> _lazyDomainGroupFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(domainGroup => domainGroup.Name, faker => faker.Commerce.Department())); public Faker DomainUser => _lazyDomainUserFaker.Value; public Faker DomainGroup => _lazyDomainGroupFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/MultiTenancy/MultiTenancyFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/MultiTenancy/MultiTenancyFakers.cs index 564985f107..e92f23808f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/MultiTenancy/MultiTenancyFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/MultiTenancy/MultiTenancyFakers.cs @@ -1,23 +1,21 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.MultiTenancy; internal sealed class MultiTenancyFakers : FakerContainer { - private readonly Lazy> _lazyWebShopFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(webShop => webShop.Url, faker => faker.Internet.Url())); + private readonly Lazy> _lazyWebShopFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(webShop => webShop.Url, faker => faker.Internet.Url())); - private readonly Lazy> _lazyWebProductFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(webProduct => webProduct.Name, faker => faker.Commerce.ProductName()) - .RuleFor(webProduct => webProduct.Price, faker => faker.Finance.Amount())); + private readonly Lazy> _lazyWebProductFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(webProduct => webProduct.Name, faker => faker.Commerce.ProductName()) + .RuleFor(webProduct => webProduct.Price, faker => faker.Finance.Amount())); public Faker WebShop => _lazyWebShopFaker.Value; public Faker WebProduct => _lazyWebProductFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/NamingFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/NamingFakers.cs index e60dbdf525..dee6e4b19f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/NamingFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/NamingFakers.cs @@ -1,27 +1,24 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.NamingConventions; internal sealed class NamingFakers : FakerContainer { - private readonly Lazy> _lazySwimmingPoolFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(swimmingPool => swimmingPool.IsIndoor, faker => faker.Random.Bool())); + private readonly Lazy> _lazySwimmingPoolFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(swimmingPool => swimmingPool.IsIndoor, faker => faker.Random.Bool())); - private readonly Lazy> _lazyWaterSlideFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(waterSlide => waterSlide.LengthInMeters, faker => faker.Random.Decimal(3, 100))); + private readonly Lazy> _lazyWaterSlideFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(waterSlide => waterSlide.LengthInMeters, faker => faker.Random.Decimal(3, 100))); - private readonly Lazy> _lazyDivingBoardFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(divingBoard => divingBoard.HeightInMeters, faker => faker.Random.Decimal(1, 15))); + private readonly Lazy> _lazyDivingBoardFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(divingBoard => divingBoard.HeightInMeters, faker => faker.Random.Decimal(1, 15))); public Faker SwimmingPool => _lazySwimmingPoolFaker.Value; public Faker WaterSlide => _lazyWaterSlideFaker.Value; diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/QueryStringFakers.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/QueryStringFakers.cs index 4afd53e405..849e53b720 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/QueryStringFakers.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/QueryStringFakers.cs @@ -1,95 +1,79 @@ using Bogus; using TestBuildingBlocks; -// @formatter:wrap_chained_method_calls chop_always -// @formatter:keep_existing_linebreaks true +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true namespace JsonApiDotNetCoreTests.IntegrationTests.QueryStrings; internal sealed class QueryStringFakers : FakerContainer { - private readonly Lazy> _lazyBlogFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(blog => blog.Title, faker => faker.Lorem.Word()) - .RuleFor(blog => blog.PlatformName, faker => faker.Company.CompanyName())); + private readonly Lazy> _lazyBlogFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(blog => blog.Title, faker => faker.Lorem.Word()) + .RuleFor(blog => blog.PlatformName, faker => faker.Company.CompanyName())); - private readonly Lazy> _lazyBlogPostFaker = new(() => - new Faker() - .UseSeed(GetFakerSeed()) - .RuleFor(blogPost => blogPost.Caption, faker => faker.Lorem.Sentence()) - .RuleFor(blogPost => blogPost.Url, faker => faker.Internet.Url())); + private readonly Lazy> _lazyBlogPostFaker = new(() => new Faker() + .UseSeed(GetFakerSeed()) + .RuleFor(blogPost => blogPost.Caption, faker => faker.Lorem.Sentence()) + .RuleFor(blogPost => blogPost.Url, faker => faker.Internet.Url())); - private readonly Lazy> _lazyLabelFaker = new(() => - new Faker