Skip to content

Update to Resharper v2023.2.1 #1302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2023.1.2",
"version": "2023.2.1",
"commands": [
"jb"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ public Task<IReadOnlyCollection<TResource>> 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<FilterExpression>()
.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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LambdaExpressionCanBeMadeStatic/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LambdaExpressionMustBeStatic/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LocalFunctionCanBeMadeStatic/@EntryIndexedValue">WARNING</s:String>
</wpf:ResourceDictionary>
7 changes: 4 additions & 3 deletions src/JsonApiDotNetCore/Queries/EvaluatedIncludeCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IncludeExpression>()
.FirstOrDefault();

// @formatter:keep_existing_linebreaks restore
// @formatter:wrap_before_first_method_call restore
// @formatter:wrap_chained_method_calls restore
_isAssigned = true;
}
Expand Down
23 changes: 11 additions & 12 deletions src/JsonApiDotNetCore/Queries/QueryLayerComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public QueryLayerComposer(IEnumerable<IQueryConstraintProvider> 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)
.Select(constraint => constraint.Expression)
.OfType<FilterExpression>()
.ToArray();

// @formatter:keep_existing_linebreaks restore
// @formatter:wrap_before_first_method_call restore
// @formatter:wrap_chained_method_calls restore

return GetFilter(filtersInTopScope, primaryResourceType);
Expand All @@ -83,15 +83,15 @@ public QueryLayerComposer(IEnumerable<IQueryConstraintProvider> 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)
.Select(constraint => constraint.Expression)
.OfType<FilterExpression>()
.ToArray();

// @formatter:keep_existing_linebreaks restore
// @formatter:wrap_before_first_method_call restore
// @formatter:wrap_chained_method_calls restore

FilterExpression? primaryFilter = GetFilter(Array.Empty<QueryExpression>(), hasManyRelationship.LeftType);
Expand Down Expand Up @@ -146,14 +146,14 @@ private QueryLayer ComposeTopLayer(IEnumerable<ExpressionInScope> 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);
Expand All @@ -174,15 +174,15 @@ private IncludeExpression ComposeChildren(QueryLayer topLayer, ICollection<Expre
using IDisposable _ = CodeTimingSessionManager.Current.Measure("Nested query composition");

// @formatter:wrap_chained_method_calls chop_always
// @formatter:keep_existing_linebreaks true
// @formatter:wrap_before_first_method_call true

IncludeExpression include = constraints
.Where(constraint => constraint.Scope == null)
.Select(constraint => constraint.Expression)
.OfType<IncludeExpression>()
.FirstOrDefault() ?? IncludeExpression.Empty;

// @formatter:keep_existing_linebreaks restore
// @formatter:wrap_before_first_method_call restore
// @formatter:wrap_chained_method_calls restore

IImmutableSet<IncludeElementExpression> includeElements = ProcessIncludeSet(include.Elements, topLayer, new List<RelationshipAttribute>(), constraints);
Expand Down Expand Up @@ -212,15 +212,14 @@ private IImmutableSet<IncludeElementExpression> 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;
Expand Down
4 changes: 2 additions & 2 deletions src/JsonApiDotNetCore/Queries/SparseFieldSetCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public SparseFieldSetCache(IEnumerable<IQueryConstraintProvider> constraintProvi
private static IDictionary<ResourceType, IImmutableSet<ResourceFieldAttribute>> BuildSourceTable(IEnumerable<IQueryConstraintProvider> constraintProviders)
{
// @formatter:wrap_chained_method_calls chop_always
// @formatter:keep_existing_linebreaks true
// @formatter:wrap_before_first_method_call true

KeyValuePair<ResourceType, SparseFieldSetExpression>[] sparseFieldTables = constraintProviders
.SelectMany(provider => provider.GetConstraints())
Expand All @@ -40,7 +40,7 @@ private static IDictionary<ResourceType, IImmutableSet<ResourceFieldAttribute>>
.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<ResourceType, ImmutableHashSet<ResourceFieldAttribute>.Builder>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected virtual IQueryable<TResource> ApplyQueryLayer(QueryLayer queryLayer)
IQueryable<TResource> 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())
Expand All @@ -128,7 +128,7 @@ protected virtual IQueryable<TResource> ApplyQueryLayer(QueryLayer queryLayer)
.OfType<QueryableHandlerExpression>()
.ToArray();

// @formatter:keep_existing_linebreaks restore
// @formatter:wrap_before_first_method_call restore
// @formatter:wrap_chained_method_calls restore

foreach (QueryableHandlerExpression queryableHandler in queryableHandlers)
Expand Down Expand Up @@ -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<IIdentifiable> 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())
Expand Down Expand Up @@ -519,15 +519,15 @@ 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)
.Concat(extraResourceIdsToRemove)
.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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Faker<TelevisionNetwork>> _lazyTelevisionNetworkFaker = new(() =>
new Faker<TelevisionNetwork>()
.UseSeed(GetFakerSeed())
.RuleFor(network => network.Name, faker => faker.Company.CompanyName()));
private readonly Lazy<Faker<TelevisionNetwork>> _lazyTelevisionNetworkFaker = new(() => new Faker<TelevisionNetwork>()
.UseSeed(GetFakerSeed())
.RuleFor(network => network.Name, faker => faker.Company.CompanyName()));

private readonly Lazy<Faker<TelevisionStation>> _lazyTelevisionStationFaker = new(() =>
new Faker<TelevisionStation>()
.UseSeed(GetFakerSeed())
.RuleFor(station => station.Name, faker => faker.Company.CompanyName()));
private readonly Lazy<Faker<TelevisionStation>> _lazyTelevisionStationFaker = new(() => new Faker<TelevisionStation>()
.UseSeed(GetFakerSeed())
.RuleFor(station => station.Name, faker => faker.Company.CompanyName()));

private readonly Lazy<Faker<TelevisionBroadcast>> _lazyTelevisionBroadcastFaker = new(() =>
new Faker<TelevisionBroadcast>()
.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<Faker<TelevisionBroadcast>> _lazyTelevisionBroadcastFaker = new(() => new Faker<TelevisionBroadcast>()
.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<Faker<BroadcastComment>> _lazyBroadcastCommentFaker = new(() =>
new Faker<BroadcastComment>()
.UseSeed(GetFakerSeed())
.RuleFor(comment => comment.Text, faker => faker.Lorem.Paragraph())
.RuleFor(comment => comment.CreatedAt, faker => faker.Date.PastOffset()
.TruncateToWholeMilliseconds()));
private readonly Lazy<Faker<BroadcastComment>> _lazyBroadcastCommentFaker = new(() => new Faker<BroadcastComment>()
.UseSeed(GetFakerSeed())
.RuleFor(comment => comment.Text, faker => faker.Lorem.Paragraph())
.RuleFor(comment => comment.CreatedAt, faker => faker.Date.PastOffset().TruncateToWholeMilliseconds()));

public Faker<TelevisionNetwork> TelevisionNetwork => _lazyTelevisionNetworkFaker.Value;
public Faker<TelevisionStation> TelevisionStation => _lazyTelevisionStationFaker.Value;
Expand Down
Loading