Skip to content

Commit 3d1c590

Browse files
author
Bart Koelman
committed
Adapt to changes in nullability annotations
1 parent d2e0d7b commit 3d1c590

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected virtual void ValidateModelState(IList<OperationContainer> operations)
133133
using IDisposable _ = new RevertRequestStateOnDispose(_request, _targetedFields);
134134

135135
int operationIndex = 0;
136-
var requestModelState = new List<(string key, ModelStateEntry entry)>();
136+
var requestModelState = new List<(string key, ModelStateEntry? entry)>();
137137
int maxErrorsRemaining = ModelState.MaxAllowedErrors;
138138

139139
foreach (OperationContainer operation in operations)
@@ -150,15 +150,15 @@ protected virtual void ValidateModelState(IList<OperationContainer> operations)
150150

151151
if (requestModelState.Any())
152152
{
153-
Dictionary<string, ModelStateEntry> modelStateDictionary = requestModelState.ToDictionary(tuple => tuple.key, tuple => tuple.entry);
153+
Dictionary<string, ModelStateEntry?> modelStateDictionary = requestModelState.ToDictionary(tuple => tuple.key, tuple => tuple.entry);
154154

155155
throw new InvalidModelStateException(modelStateDictionary, typeof(IList<OperationContainer>), _options.IncludeExceptionStackTraceInErrors,
156156
_resourceGraph,
157157
(collectionType, index) => collectionType == typeof(IList<OperationContainer>) ? operations[index].Resource.GetType() : null);
158158
}
159159
}
160160

161-
private int ValidateOperation(OperationContainer operation, int operationIndex, List<(string key, ModelStateEntry entry)> requestModelState,
161+
private int ValidateOperation(OperationContainer operation, int operationIndex, List<(string key, ModelStateEntry? entry)> requestModelState,
162162
int maxErrorsRemaining)
163163
{
164164
if (operation.Request.WriteOperation is WriteOperationKind.CreateResource or WriteOperationKind.UpdateResource)
@@ -182,7 +182,7 @@ private int ValidateOperation(OperationContainer operation, int operationIndex,
182182

183183
foreach (string key in validationContext.ModelState.Keys)
184184
{
185-
ModelStateEntry entry = validationContext.ModelState[key];
185+
ModelStateEntry entry = validationContext.ModelState[key]!;
186186

187187
if (entry.ValidationState == ModelValidationState.Invalid)
188188
{

src/JsonApiDotNetCore/Errors/InvalidModelStateException.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ namespace JsonApiDotNetCore.Errors
2020
[PublicAPI]
2121
public sealed class InvalidModelStateException : JsonApiException
2222
{
23-
public InvalidModelStateException(IReadOnlyDictionary<string, ModelStateEntry> modelState, Type modelType, bool includeExceptionStackTraceInErrors,
23+
public InvalidModelStateException(IReadOnlyDictionary<string, ModelStateEntry?> modelState, Type modelType, bool includeExceptionStackTraceInErrors,
2424
IResourceGraph resourceGraph, Func<Type, int, Type?>? getCollectionElementTypeCallback = null)
2525
: base(FromModelStateDictionary(modelState, modelType, resourceGraph, includeExceptionStackTraceInErrors, getCollectionElementTypeCallback))
2626
{
2727
}
2828

29-
private static IEnumerable<ErrorObject> FromModelStateDictionary(IReadOnlyDictionary<string, ModelStateEntry> modelState, Type modelType,
29+
private static IEnumerable<ErrorObject> FromModelStateDictionary(IReadOnlyDictionary<string, ModelStateEntry?> modelState, Type modelType,
3030
IResourceGraph resourceGraph, bool includeExceptionStackTraceInErrors, Func<Type, int, Type?>? getCollectionElementTypeCallback)
3131
{
3232
ArgumentGuard.NotNull(modelState, nameof(modelState));
@@ -45,15 +45,15 @@ private static IEnumerable<ErrorObject> FromModelStateDictionary(IReadOnlyDictio
4545
}
4646

4747
private static IEnumerable<(ModelStateEntry entry, string? sourcePointer)> ResolveSourcePointers(
48-
IReadOnlyDictionary<string, ModelStateEntry> modelState, Type modelType, IResourceGraph resourceGraph,
48+
IReadOnlyDictionary<string, ModelStateEntry?> modelState, Type modelType, IResourceGraph resourceGraph,
4949
Func<Type, int, Type?>? getCollectionElementTypeCallback)
5050
{
5151
foreach (string key in modelState.Keys)
5252
{
5353
var rootSegment = ModelStateKeySegment.Create(modelType, key, getCollectionElementTypeCallback);
5454
string? sourcePointer = ResolveSourcePointer(rootSegment, resourceGraph);
5555

56-
yield return (modelState[key], sourcePointer);
56+
yield return (modelState[key]!, sourcePointer);
5757
}
5858
}
5959

src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private void IncludeAllProperties(Type elementType, Dictionary<PropertyInfo, Pro
112112

113113
foreach (IProperty entityProperty in entityProperties)
114114
{
115-
var propertySelector = new PropertySelector(entityProperty.PropertyInfo);
115+
var propertySelector = new PropertySelector(entityProperty.PropertyInfo!);
116116
IncludeWritableProperty(propertySelector, propertySelectors);
117117
}
118118
}

0 commit comments

Comments
 (0)