Skip to content

Commit 42cff78

Browse files
authored
Update to Resharper v2023.2.1 (#1302)
* Update to Resharper v2023.2.1 * Add workaround for Resharper bug at https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment * Use new formatting directives * Fail the build when capturing closures in lambdas within source generators project (they cause expensive allocations)
1 parent 952518a commit 42cff78

File tree

59 files changed

+645
-735
lines changed

Some content is hidden

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

59 files changed

+645
-735
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"jetbrains.resharper.globaltools": {
6-
"version": "2023.1.2",
6+
"version": "2023.2.1",
77
"commands": [
88
"jb"
99
]

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);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<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">
2+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LambdaExpressionCanBeMadeStatic/@EntryIndexedValue">WARNING</s:String>
3+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LambdaExpressionMustBeStatic/@EntryIndexedValue">WARNING</s:String>
4+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LocalFunctionCanBeMadeStatic/@EntryIndexedValue">WARNING</s:String>
5+
</wpf:ResourceDictionary>

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/QueryStrings/IncludeQueryStringParameterReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ public virtual void Read(string parameterName, StringValues parameterValue)
4747
{
4848
try
4949
{
50+
// Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment
51+
// ReSharper disable once AssignNullToNotNullAttribute
5052
_includeExpression = GetInclude(parameterValue.ToString());
5153
}
5254
catch (QueryParseException exception)
5355
{
56+
// Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment
57+
// ReSharper disable once AssignNullToNotNullAttribute
5458
string specificMessage = exception.GetMessageWithPosition(parameterValue.ToString());
5559
throw new InvalidQueryStringParameterException(parameterName, "The specified include is invalid.", specificMessage, exception);
5660
}

src/JsonApiDotNetCore/QueryStrings/PaginationQueryStringParameterReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public virtual void Read(string parameterName, StringValues parameterValue)
5858

5959
try
6060
{
61+
// Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment
62+
// ReSharper disable once AssignNullToNotNullAttribute
6163
PaginationQueryStringValueExpression constraint = GetPageConstraint(parameterValue.ToString());
6264

6365
if (constraint.Elements.Any(element => element.Scope == null))
@@ -80,6 +82,8 @@ public virtual void Read(string parameterName, StringValues parameterValue)
8082
}
8183
catch (QueryParseException exception)
8284
{
85+
// Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment
86+
// ReSharper disable once AssignNullToNotNullAttribute
8387
string specificMessage = exception.GetMessageWithPosition(isParameterNameValid ? parameterValue.ToString() : parameterName);
8488
throw new InvalidQueryStringParameterException(parameterName, "The specified pagination is invalid.", specificMessage, exception);
8589
}

src/JsonApiDotNetCore/QueryStrings/SortQueryStringParameterReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,16 @@ public virtual void Read(string parameterName, StringValues parameterValue)
5959
ResourceFieldChainExpression? scope = GetScope(parameterName);
6060
parameterNameIsValid = true;
6161

62+
// Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment
63+
// ReSharper disable once AssignNullToNotNullAttribute
6264
SortExpression sort = GetSort(parameterValue.ToString(), scope);
6365
var expressionInScope = new ExpressionInScope(scope, sort);
6466
_constraints.Add(expressionInScope);
6567
}
6668
catch (QueryParseException exception)
6769
{
70+
// Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment
71+
// ReSharper disable once AssignNullToNotNullAttribute
6872
string specificMessage = exception.GetMessageWithPosition(parameterNameIsValid ? parameterValue.ToString() : parameterName);
6973
throw new InvalidQueryStringParameterException(parameterName, "The specified sort is invalid.", specificMessage, exception);
7074
}

src/JsonApiDotNetCore/QueryStrings/SparseFieldSetQueryStringParameterReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ public virtual void Read(string parameterName, StringValues parameterValue)
6363
ResourceType resourceType = GetScope(parameterName);
6464
parameterNameIsValid = true;
6565

66+
// Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment
67+
// ReSharper disable once AssignNullToNotNullAttribute
6668
SparseFieldSetExpression sparseFieldSet = GetSparseFieldSet(parameterValue.ToString(), resourceType);
6769
_sparseFieldTableBuilder[resourceType] = sparseFieldSet;
6870
}
6971
catch (QueryParseException exception)
7072
{
73+
// Workaround for https://youtrack.jetbrains.com/issue/RSRP-493256/Incorrect-possible-null-assignment
74+
// ReSharper disable once AssignNullToNotNullAttribute
7175
string specificMessage = exception.GetMessageWithPosition(parameterNameIsValid ? parameterValue.ToString() : parameterName);
7276
throw new InvalidQueryStringParameterException(parameterName, "The specified fieldset is invalid.", specificMessage, exception);
7377
}

0 commit comments

Comments
 (0)