// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; namespace CommunityToolkit.Mvvm.ComponentModel; /// /// An attribute that can be used to support in generated properties, when applied to /// fields contained in a type that is inheriting from and using any validation attributes. /// When this attribute is used, the generated property setter will also call . /// This allows generated properties to opt-in into validation behavior without having to fallback into a full explicit observable property. /// /// This attribute can be used as follows: /// /// partial class MyViewModel : ObservableValidator /// { /// [ObservableProperty] /// [NotifyDataErrorInfo] /// [Required] /// [MinLength(2)] /// private string username; /// } /// /// /// And with this, code analogous to this will be generated: /// /// partial class MyViewModel /// { /// [Required] /// [MinLength(2)] /// public string Username /// { /// get => username; /// set => SetProperty(ref username, value, validate: true); /// } /// } /// /// [AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, AllowMultiple = false, Inherited = false)] public sealed class NotifyDataErrorInfoAttribute : Attribute { }