Skip to content

Commit 2b5532c

Browse files
authored
Merge pull request #290 from CodeDevAM/allow_internal_properties_in_expressions
Allow internal properties in expressions
2 parents fb96820 + 061d64b commit 2b5532c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Avalonia.Controls.TreeDataGrid/Experimental/Data/TypedBinding`1.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ public static TypedBinding<TIn, TOut> TwoWay<TOut>(Expression<Func<TIn, TOut>> e
4545
$"Cannot create a two-way binding for '{expression}' because the expression does not target a property.",
4646
nameof(expression));
4747

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

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

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

0 commit comments

Comments
 (0)