Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed broken build after reformat
  • Loading branch information
Bart Koelman committed Mar 3, 2021
commit 1a642871b1aff1c79a56f8b4bbf39438fd89059d
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void DiscoverImplementedHooks(Type containerType)

foreach (ResourceHook hook in _allHooks)
{
MethodInfo? method = containerType.GetMethod(hook.ToString("G"));
MethodInfo method = containerType.GetMethod(hook.ToString("G"));

if (method == null || method.DeclaringType == _boundResourceDefinitionType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private void AddToImplicitlyAffected(IEnumerable includedLefts, RelationshipAttr

private static void AddToList(IList list, IEnumerable itemsToAdd)
{
foreach (object? item in itemsToAdd)
foreach (object item in itemsToAdd)
{
list.Add(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ private void ValidateHookResponse<T>(IEnumerable<T> returnedList, ResourcePipeli
/// </summary>
private IEnumerable CallHook(IResourceHookContainer container, ResourceHook hook, object[] arguments)
{
MethodInfo? method = container.GetType().GetMethod(hook.ToString("G"));
MethodInfo method = container.GetType().GetMethod(hook.ToString("G"));
// note that some of the hooks return "void". When these hooks, the
// are called reflectively with Invoke like here, the return value
// is just null, so we don't have to worry about casting issues here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public object GetValue(IIdentifiable resource)
return null;
}

foreach (object? throughResource in throughResources)
foreach (object throughResource in throughResources)
{
var rightResource = (IIdentifiable)hasManyThrough.RightProperty.GetValue(throughResource);

Expand Down Expand Up @@ -110,7 +110,7 @@ public void SetValue(IIdentifiable resource, object value)
var filteredList = new List<object>();
IList rightResources = TypeHelper.CopyToList((IEnumerable)value, RightType);

foreach (object? throughResource in throughResources ?? Array.Empty<object>())
foreach (object throughResource in throughResources ?? Array.Empty<object>())
{
if (rightResources.Contains(hasManyThrough.RightProperty.GetValue(throughResource)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private Dictionary<RightType, List<KeyValuePair<RelationshipProxy, List<IIdentif
ExtractLeftResources(leftResources, relationships, rightResourcesGrouped, leftResourcesGrouped);
}

MethodInfo? processResourcesMethod = GetType().GetMethod(nameof(ProcessResources), BindingFlags.NonPublic | BindingFlags.Instance);
MethodInfo processResourcesMethod = GetType().GetMethod(nameof(ProcessResources), BindingFlags.NonPublic | BindingFlags.Instance);

foreach (KeyValuePair<RelationshipProxy, List<IIdentifiable>> kvp in rightResourcesGrouped)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private Type ExtractResourceTypeFromController(Type type)

while (!currentType.IsGenericType || currentType.GetGenericTypeDefinition() != baseControllerType)
{
Type? nextBaseType = currentType.BaseType;
Type nextBaseType = currentType.BaseType;

if ((nextBaseType == aspNetControllerType || nextBaseType == coreControllerType) && currentType.IsGenericType)
{
Expand Down
4 changes: 2 additions & 2 deletions src/JsonApiDotNetCore/Middleware/TraceLogWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static void WriteProperty(StringBuilder builder, PropertyInfo property,
builder.Append(property.Name);
builder.Append(": ");

object? value = property.GetValue(instance);
object value = property.GetValue(instance);

if (value == null)
{
Expand Down Expand Up @@ -111,7 +111,7 @@ private static bool HasToStringOverload(Type type)
{
if (type != null)
{
MethodInfo? toStringMethod = type.GetMethod("ToString", Array.Empty<Type>());
MethodInfo toStringMethod = type.GetMethod("ToString", Array.Empty<Type>());

if (toStringMethod != null && toStringMethod.DeclaringType != typeof(object))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public override object GetValue(object resource)
{
ArgumentGuard.NotNull(resource, nameof(resource));

object? throughEntity = ThroughProperty.GetValue(resource);
object throughEntity = ThroughProperty.GetValue(resource);

if (throughEntity == null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/Serialization/JsonApiReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private bool HasMissingId(object model)
/// </summary>
private bool HasMissingId(IEnumerable models)
{
foreach (object? model in models)
foreach (object model in models)
{
if (TryGetId(model, out string id) && id == null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/JsonApiDotNetCore/TypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public static bool TypeCanContainHashSet(Type collectionType)
/// </summary>
public static Type GetIdType(Type resourceType)
{
PropertyInfo? property = resourceType.GetProperty(nameof(Identifiable.Id));
PropertyInfo property = resourceType.GetProperty(nameof(Identifiable.Id));

if (property == null)
{
Expand Down Expand Up @@ -375,7 +375,7 @@ public static IEnumerable CopyToTypedCollection(IEnumerable source, Type collect
Type concreteCollectionType = ToConcreteCollectionType(collectionType);
dynamic concreteCollectionInstance = CreateInstance(concreteCollectionType);

foreach (object? item in source)
foreach (object item in source)
{
concreteCollectionInstance.Add((dynamic)item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task Can_filter_equality_on_type(string propertyName, object value)
{
// Arrange
var resource = new FilterableResource();
PropertyInfo? property = typeof(FilterableResource).GetProperty(propertyName);
PropertyInfo property = typeof(FilterableResource).GetProperty(propertyName);
property?.SetValue(resource, value);

await _testContext.RunOnDatabaseAsync(async dbContext =>
Expand Down Expand Up @@ -256,7 +256,7 @@ public async Task Can_filter_is_null_on_type(string propertyName)
{
// Arrange
var resource = new FilterableResource();
PropertyInfo? property = typeof(FilterableResource).GetProperty(propertyName);
PropertyInfo property = typeof(FilterableResource).GetProperty(propertyName);
property?.SetValue(resource, null);

var otherResource = new FilterableResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
workItemInDatabase.DueAt.Should().Be(newWorkItem.DueAt);
});

PropertyInfo? property = typeof(WorkItem).GetProperty(nameof(Identifiable.Id));
PropertyInfo property = typeof(WorkItem).GetProperty(nameof(Identifiable.Id));
property.Should().NotBeNull().And.Subject.PropertyType.Should().Be(typeof(int));
}

Expand Down Expand Up @@ -157,7 +157,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
userAccountInDatabase.LastName.Should().Be(newUserAccount.LastName);
});

PropertyInfo? property = typeof(UserAccount).GetProperty(nameof(Identifiable.Id));
PropertyInfo property = typeof(UserAccount).GetProperty(nameof(Identifiable.Id));
property.Should().NotBeNull().And.Subject.PropertyType.Should().Be(typeof(long));
}

Expand Down Expand Up @@ -201,7 +201,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
groupInDatabase.Name.Should().Be(newGroup.Name);
});

PropertyInfo? property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id));
PropertyInfo property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id));
property.Should().NotBeNull().And.Subject.PropertyType.Should().Be(typeof(Guid));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
groupInDatabase.Name.Should().Be(newGroup.Name);
});

PropertyInfo? property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id));
PropertyInfo property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id));
property.Should().NotBeNull().And.Subject.PropertyType.Should().Be(typeof(Guid));
}

Expand Down Expand Up @@ -115,7 +115,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
groupInDatabase.Name.Should().Be(newGroup.Name);
});

PropertyInfo? property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id));
PropertyInfo property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id));
property.Should().NotBeNull().And.Subject.PropertyType.Should().Be(typeof(Guid));
}

Expand Down Expand Up @@ -155,7 +155,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
colorInDatabase.DisplayName.Should().Be(newColor.DisplayName);
});

PropertyInfo? property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id));
PropertyInfo property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id));
property.Should().NotBeNull().And.Subject.PropertyType.Should().Be(typeof(string));
}

Expand Down Expand Up @@ -195,7 +195,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
colorInDatabase.DisplayName.Should().Be(newColor.DisplayName);
});

PropertyInfo? property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id));
PropertyInfo property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id));
property.Should().NotBeNull().And.Subject.PropertyType.Should().Be(typeof(string));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
groupInDatabase.IsPublic.Should().Be(existingGroup.IsPublic);
});

PropertyInfo? property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id));
PropertyInfo property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id));
property.Should().NotBeNull().And.Subject.PropertyType.Should().Be(typeof(Guid));
}

Expand Down Expand Up @@ -256,7 +256,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
colorInDatabase.DisplayName.Should().Be(newDisplayName);
});

PropertyInfo? property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id));
PropertyInfo property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id));
property.Should().NotBeNull().And.Subject.PropertyType.Should().Be(typeof(string));
}

Expand Down
2 changes: 1 addition & 1 deletion test/TestBuildingBlocks/FakerContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private static MethodBase GetTestMethod()
{
var stackTrace = new StackTrace();

MethodBase? testMethod = stackTrace.GetFrames().Select(stackFrame => stackFrame?.GetMethod()).FirstOrDefault(IsTestMethod);
MethodBase testMethod = stackTrace.GetFrames().Select(stackFrame => stackFrame?.GetMethod()).FirstOrDefault(IsTestMethod);

if (testMethod == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void DeserializeAttributes_VariousDataTypes_CanDeserialize(string member,

// Assert
PropertyInfo pi = ResourceGraph.GetResourceContext("testResource").Attributes.Single(attr => attr.PublicName == member).Property;
object? deserializedValue = pi.GetValue(resource);
object deserializedValue = pi.GetValue(resource);

if (member == "intField")
{
Expand Down