Skip to content

Commit

Permalink
Merge pull request #290 from CodeDevAM/allow_internal_properties_in_e…
Browse files Browse the repository at this point in the history
…xpressions

Allow internal properties in expressions
  • Loading branch information
maxkatz6 authored Aug 13, 2024
2 parents fb96820 + 061d64b commit 2b5532c
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ public static TypedBinding<TIn, TOut> TwoWay<TOut>(Expression<Func<TIn, TOut>> e
$"Cannot create a two-way binding for '{expression}' because the expression does not target a property.",
nameof(expression));

if (property.GetGetMethod() is null)
MethodInfo? getMethodInfo = property.GetGetMethod(true);
if (getMethodInfo is null || getMethodInfo.IsPrivate)
throw new ArgumentException(
$"Cannot create a two-way binding for '{expression}' because the property has no getter.",
$"Cannot create a two-way binding for '{expression}' because the property has no getter or the getter is private.",
nameof(expression));

if (property.GetSetMethod() is null)
MethodInfo? setMethodInfo = property.GetSetMethod(true);
if (setMethodInfo is null || setMethodInfo.IsPrivate)
throw new ArgumentException(
$"Cannot create a two-way binding for '{expression}' because the property has no setter.",
$"Cannot create a two-way binding for '{expression}' because the property has no setter or the setter is private.",
nameof(expression));

// TODO: This is using reflection and mostly untested. Unit test it properly and
Expand Down

0 comments on commit 2b5532c

Please sign in to comment.