Skip to content

Commit fd5f63f

Browse files
authored
Updated code to use pattern matching not operator (#8344)
1 parent 53a0cb5 commit fd5f63f

File tree

9 files changed

+12
-10
lines changed

9 files changed

+12
-10
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ dotnet_diagnostic.IDE0028.severity = warning
172172
dotnet_diagnostic.IDE0036.severity = warning
173173
# Use range operator.
174174
dotnet_diagnostic.IDE0057.severity = warning
175+
# Use pattern matching (not operator).
176+
dotnet_diagnostic.IDE0083.severity = warning
175177
# Use collection expression for array.
176178
dotnet_diagnostic.IDE0300.severity = warning
177179
# Use collection expression for empty.

src/HotChocolate/Data/src/Data/Projections/Expressions/Handlers/QueryableProjectionListHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public override bool TryHandleLeave(
7272

7373
var scope = context.PopScope();
7474

75-
if (!(scope is QueryableProjectionScope queryableScope) ||
75+
if (scope is not QueryableProjectionScope queryableScope ||
7676
!context.TryGetQueryableScope(out var parentScope))
7777
{
7878
action = null;

src/HotChocolate/Data/src/Data/Sorting/Expressions/Handlers/QueryableDefaultSortFieldHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override bool TryHandleEnter(
3737
return false;
3838
}
3939

40-
if (!(context.GetInstance() is QueryableFieldSelector lastFieldSelector))
40+
if (context.GetInstance() is not QueryableFieldSelector lastFieldSelector)
4141
{
4242
throw ThrowHelper.Sorting_InvalidState_ParentIsNoFieldSelector(field);
4343
}

src/HotChocolate/MongoDb/src/Data/Filters/Handlers/MongoDbDefaultFieldHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public override bool CanHandle(
2424
ITypeCompletionContext context,
2525
IFilterInputTypeConfiguration typeConfiguration,
2626
IFilterFieldConfiguration fieldConfiguration) =>
27-
!(fieldConfiguration is FilterOperationFieldConfiguration);
27+
fieldConfiguration is not FilterOperationFieldConfiguration;
2828

2929
/// <inheritdoc />
3030
public override bool TryHandleEnter(

src/HotChocolate/Spatial/src/Types/Serialization/GeoJsonCoordinatesSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public override bool TryDeserialize(IType type, object? serialized, out object?
179179
return true;
180180
}
181181

182-
if (!(serialized is IList list))
182+
if (serialized is not IList list)
183183
{
184184
value = null;
185185
return false;

src/HotChocolate/Spatial/src/Types/Serialization/GeoJsonGeometrySerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public IValueNode ParseValue(IType type, object? runtimeValue)
120120
return ParseResult(type, runtimeValue);
121121
}
122122

123-
if (!(runtimeValue is Geometry geometry))
123+
if (runtimeValue is not Geometry geometry)
124124
{
125125
throw Geometry_Parse_InvalidGeometryType(type, runtimeValue.GetType());
126126
}

src/HotChocolate/Spatial/src/Types/Serialization/GeoJsonPositionSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public override bool TryDeserialize(IType type, object? serialized, out object?
189189
return true;
190190
}
191191

192-
if (!(serialized is IList list))
192+
if (serialized is not IList list)
193193
{
194194
value = null;
195195
return false;
@@ -259,7 +259,7 @@ public override bool TrySerialize(IType type, object? value, out object? seriali
259259
return true;
260260
}
261261

262-
if (!(value is Coordinate coordinate))
262+
if (value is not Coordinate coordinate)
263263
{
264264
serialized = null;
265265
return false;

src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/DependencyInjectionGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ private static ICode GenerateInternalMethodBody(
524524

525525
foreach (var operation in descriptor.Operations)
526526
{
527-
if (!(operation.ResultTypeReference is InterfaceTypeDescriptor typeDescriptor))
527+
if (operation.ResultTypeReference is not InterfaceTypeDescriptor typeDescriptor)
528528
{
529529
continue;
530530
}

src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/SerializerNameUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private static string CreateName(IType type, string prefix)
2323
{
2424
if (current is HotChocolate.Types.ListType)
2525
{
26-
if (types.Count == 0 || !(types.Peek() is NonNullType))
26+
if (types.Count == 0 || types.Peek() is not NonNullType)
2727
{
2828
sb.Append("Nullable");
2929
}
@@ -33,7 +33,7 @@ private static string CreateName(IType type, string prefix)
3333
current = current.InnerType();
3434
}
3535

36-
if (types.Count == 0 || !(types.Peek() is NonNullType))
36+
if (types.Count == 0 || types.Peek() is not NonNullType)
3737
{
3838
sb.Append("Nullable");
3939
}

0 commit comments

Comments
 (0)