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

#302 Update ReflectionUtils.cs #304

Merged
merged 1 commit into from
Sep 13, 2024
Merged
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
Update ReflectionUtils.cs
remove unused method

Signed-off-by: krivchenko_kv <kvkrivchenko@activebc.ru>
  • Loading branch information
dundich authored and krivchenko_kv committed Sep 13, 2024
commit d413a1eedf8c9b279415e4aeda4800c4271bcf2e
13 changes: 1 addition & 12 deletions src/SlimMessageBus.Host/Helpers/ReflectionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@

public static class ReflectionUtils
{
public static Func<object, object> GenerateGetterExpr(PropertyInfo property)
{
var objInstanceExpr = Expression.Parameter(typeof(object), "instance");
var typedInstanceExpr = Expression.TypeAs(objInstanceExpr, property.DeclaringType);

var propertyExpr = Expression.Property(typedInstanceExpr, property);
var propertyObjExpr = Expression.Convert(propertyExpr, typeof(object));

return Expression.Lambda<Func<object, object>>(propertyObjExpr, objInstanceExpr).Compile();
}

public static Func<object, object> GenerateGetterFunc(PropertyInfo property)
{
var objInstanceExpr = Expression.Parameter(typeof(object), "instance");

Check warning on line 10 in src/SlimMessageBus.Host/Helpers/ReflectionUtils.cs

View workflow job for this annotation

GitHub Actions / build

Define a constant instead of using this literal 'instance' 4 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)

Check warning on line 10 in src/SlimMessageBus.Host/Helpers/ReflectionUtils.cs

View workflow job for this annotation

GitHub Actions / build

Define a constant instead of using this literal 'instance' 4 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)

Check warning on line 10 in src/SlimMessageBus.Host/Helpers/ReflectionUtils.cs

View workflow job for this annotation

GitHub Actions / build

Define a constant instead of using this literal 'instance' 4 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
var typedInstanceExpr = Expression.TypeAs(objInstanceExpr, property.DeclaringType);

var propertyExpr = Expression.Property(typedInstanceExpr, property);
Expand Down Expand Up @@ -195,4 +184,4 @@

return Expression.Lambda<Func<Task, object>>(Expression.Convert(Expression.Property(Expression.Convert(taskParam, taskOfType), taskOfTypeResultProperty), typeof(object)), taskParam).Compile();
}
}
}
Loading