@ -1,4 +1,5 @@
using System ;
using System ;
using System.Diagnostics ;
using Avalonia.Data.Core.Plugins ;
using Avalonia.Data.Core.Plugins ;
namespace Avalonia.Data.Core
namespace Avalonia.Data.Core
@ -49,6 +50,18 @@ namespace Avalonia.Data.Core
var accessor = plugin ? . Start ( reference , PropertyName ) ;
var accessor = plugin ? . Start ( reference , PropertyName ) ;
// We need to handle accessor fallback before handling validation. Validators do not support null accessors.
if ( accessor = = null )
{
reference . TryGetTarget ( out object instance ) ;
var message = $"Could not find a matching property accessor for '{PropertyName}' on '{instance}'" ;
var exception = new MissingMemberException ( message ) ;
accessor = new PropertyError ( new BindingNotification ( exception , BindingErrorType . Error ) ) ;
}
if ( _ enableValidation & & Next = = null )
if ( _ enableValidation & & Next = = null )
{
{
foreach ( var validator in ExpressionObserver . DataValidators )
foreach ( var validator in ExpressionObserver . DataValidators )
@ -60,15 +73,9 @@ namespace Avalonia.Data.Core
}
}
}
}
if ( accessor = = null )
if ( accessor is null )
{
{
reference . TryGetTarget ( out object instance ) ;
throw new AvaloniaInternalException ( "Data validators must return non-null accessor." ) ;
var message = $"Could not find a matching property accessor for '{PropertyName}' on '{instance}'" ;
var exception = new MissingMemberException ( message ) ;
accessor = new PropertyError ( new BindingNotification ( exception , BindingErrorType . Error ) ) ;
}
}
_ accessor = accessor ;
_ accessor = accessor ;