Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPropertyMetadata nullable get value fix #734

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ private object GetAttributeValue(TestFilterRuntimeModel operation, TestAttribute
{
var attributeName = attributeType?.Name;

if (ReferenceEquals(attributeName, null))
{
return null;
}

TestAttributeValue value;
return operation.Attributes.TryGetValue(attributeName, out value) ? value.Value : null;
}
Expand Down
28 changes: 12 additions & 16 deletions src/Orc.FilterBuilder/Models/Interfaces/IPropertyMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
namespace Orc.FilterBuilder
{
using System;
namespace Orc.FilterBuilder;

using System;

public interface IPropertyMetadata
{
/// <summary>
/// Display name of the property
/// </summary>
string DisplayName { get; set; }
public interface IPropertyMetadata
{
string DisplayName { get; set; }

string Name { get; }
string Name { get; }

Type OwnerType { get; }
Type OwnerType { get; }

Type Type { get; }
Type Type { get; }

object? GetValue(object instance);
object? GetValue(object instance);

TValue GetValue<TValue>(object instance);
TValue? GetValue<TValue>(object instance);

void SetValue(object instance, object? value);
}
void SetValue(object instance, object? value);
}
13 changes: 3 additions & 10 deletions src/Orc.FilterBuilder/Models/PropertyMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,8 @@ public override bool Equals(object? obj)
return true;
}

if (obj.GetType() != GetType())
{
return false;
}

return Equals((PropertyMetadata)obj);
return obj.GetType() == GetType()
&& Equals((PropertyMetadata)obj);
}

public override int GetHashCode()
Expand Down Expand Up @@ -132,10 +128,7 @@ public void SetValue(object instance, object? value)
{
ArgumentNullException.ThrowIfNull(instance);

if (_propertyInfo is not null)
{
_propertyInfo.SetValue(instance, value, null);
}
_propertyInfo?.SetValue(instance, value, null);

if (_propertyData is null)
{
Expand Down