Skip to content

Commit e9d5947

Browse files
authored
Updated code to remove unnecessary null-forgiving operator usage (#8341)
1 parent 0d1d2b7 commit e9d5947

File tree

47 files changed

+95
-93
lines changed

Some content is hidden

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

47 files changed

+95
-93
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ dotnet_diagnostic.IDE0305.severity = silent # see https://github.com/dotnet/rosl
185185
# Use collection expression for new.
186186
dotnet_diagnostic.IDE0306.severity = warning
187187
dotnet_style_prefer_collection_expression = when_types_exactly_match
188+
# Unnecessary null-forgiving operator.
189+
dotnet_diagnostic.RCS1249.severity = warning
188190
# Remove unnecessary braces.
189191
dotnet_diagnostic.RCS1251.severity = warning
190192
# Add/remove trailing comma.

src/CookieCrumble/src/CookieCrumble/Formatters/JsonSnapshotValueFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected override IList<JsonProperty> CreateProperties(
5454
return 1000 - d.Count;
5555
}).ToList();
5656

57-
return properties!;
57+
return properties;
5858
}
5959
}
6060
}

src/GreenDonut/test/GreenDonut.Data.EntityFramework.Tests/TestContext/Brand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class Brand
1111
[Required]
1212
public string Name { get; set; } = default!;
1313

14-
public string? DisplayName { get; set; } = default!;
14+
public string? DisplayName { get; set; }
1515

1616
public string? AlwaysNull { get; set; }
1717

src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/EntitiesResolverTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public class FederatedTypeWithOptionalDetail
384384
{
385385
public string Id { get; set; } = default!;
386386

387-
public FederatedTypeDetail? Detail { get; set; } = default!;
387+
public FederatedTypeDetail? Detail { get; set; }
388388

389389
[ReferenceResolver]
390390
public static FederatedTypeWithOptionalDetail ReferenceResolver([Map("detail.id")] string detailId)

src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/ReferenceResolverAttributeTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ public async Task InClassRefResolver_WithGuid()
236236
var entity = await inClassResolverDelegate.Invoke(context);
237237

238238
if (entity is not null &&
239-
type!.Features.TryGet(out ExternalSetter? externalSetter))
239+
type.Features.TryGet(out ExternalSetter? externalSetter))
240240
{
241-
externalSetter.Invoke(type, representation!, entity);
241+
externalSetter.Invoke(type, representation, entity);
242242
}
243243

244244
return entity;

src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ClientQueryResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace HotChocolate.AspNetCore.Tests.Utilities;
44

55
public sealed class ClientQueryResult
66
{
7-
public string? ContentType { get; set; } = default!;
7+
public string? ContentType { get; set; }
88
public HttpStatusCode StatusCode { get; set; }
99
public Dictionary<string, object?>? Data { get; set; }
1010
public List<Dictionary<string, object?>>? Errors { get; set; }

src/HotChocolate/AzureFunctions/test/HotChocolate.AzureFunctions.IsolatedProcess.Tests/IsolatedProcessEndToEndTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public async Task AzFuncIsolatedProcess_EndToEndTestAsync()
4141
var resultContent = await ReadResponseAsStringAsync(response);
4242
Assert.False(string.IsNullOrWhiteSpace(resultContent));
4343

44-
dynamic json = JObject.Parse(resultContent!);
44+
dynamic json = JObject.Parse(resultContent);
4545
Assert.Null(json.errors);
4646
Assert.Equal("Luke Skywalker",json.data.person.ToString());
4747
}
@@ -90,7 +90,7 @@ public async Task AzFuncIsolatedProcess_FunctionsContextItemsTestAsync()
9090
var resultContent = await ReadResponseAsStringAsync(response);
9191
Assert.False(string.IsNullOrWhiteSpace(resultContent));
9292

93-
dynamic json = JObject.Parse(resultContent!);
93+
dynamic json = JObject.Parse(resultContent);
9494
Assert.Null(json.errors);
9595
Assert.Equal("Darth Vader", json.data.person.ToString());
9696
}
@@ -119,7 +119,7 @@ public async Task AzFuncIsolatedProcess_NitroTestAsync()
119119
var resultContent = await ReadResponseAsStringAsync(httpResponseData);
120120
Assert.NotNull(resultContent);
121121
Assert.False(string.IsNullOrWhiteSpace(resultContent));
122-
Assert.True(resultContent!.Contains("<html") && resultContent.Contains("</html>"));
122+
Assert.True(resultContent.Contains("<html") && resultContent.Contains("</html>"));
123123
}
124124

125125
private static Task<string> ReadResponseAsStringAsync(HttpResponseData responseData)

src/HotChocolate/AzureFunctions/test/HotChocolate.AzureFunctions.Tests/InProcessEndToEndTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task AzFuncInProcess_EndToEndTestAsync()
3434
var resultContent = await httpContext.ReadResponseContentAsync();
3535
Assert.False(string.IsNullOrWhiteSpace(resultContent));
3636

37-
dynamic json = JObject.Parse(resultContent!);
37+
dynamic json = JObject.Parse(resultContent);
3838
Assert.Null(json.errors);
3939
Assert.Equal("Luke Skywalker",json.data.person.ToString());
4040
}
@@ -67,6 +67,6 @@ public async Task AzFuncInProcess_NitroTestAsync()
6767
var resultContent = await httpContext.ReadResponseContentAsync();
6868
Assert.NotNull(resultContent);
6969
Assert.False(string.IsNullOrWhiteSpace(resultContent));
70-
Assert.True(resultContent!.Contains("<html") && resultContent.Contains("</html>"));
70+
Assert.True(resultContent.Contains("<html") && resultContent.Contains("</html>"));
7171
}
7272
}

src/HotChocolate/Core/src/Execution.Abstractions/Execution/OperationDocumentId.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public static bool IsValidId(string operationId)
175175
return false;
176176
}
177177

178-
start = ref Unsafe.Add(ref start, 1)!;
178+
start = ref Unsafe.Add(ref start, 1);
179179
}
180180

181181
return true;

src/HotChocolate/Core/src/Features/FeatureReferences.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void Initialize(IFeatureCollection collection, int revision)
103103
flush = true;
104104
}
105105

106-
return cached ?? UpdateCached(ref cached!, state, factory, revision, flush);
106+
return cached ?? UpdateCached(ref cached, state, factory, revision, flush);
107107
}
108108

109109
// Update and cache clearing logic, when the fast-path in Fetch isn't applicable

0 commit comments

Comments
 (0)