diff --git a/src/Avalonia.Base/Metadata/DataTypeInheritFromAttribute.cs b/src/Avalonia.Base/Metadata/DataTypeInheritFromAttribute.cs index 58cbc60773..6bb820d214 100644 --- a/src/Avalonia.Base/Metadata/DataTypeInheritFromAttribute.cs +++ b/src/Avalonia.Base/Metadata/DataTypeInheritFromAttribute.cs @@ -6,25 +6,25 @@ namespace Avalonia.Metadata; /// Instructs the compiler to resolve the compiled bindings data type for the item-specific properties of collection-like controls. /// /// -/// A typical usage example is a ListBox control, where DataTypeInheritFrom is defined on the ItemTemplate property, +/// A typical usage example is a ListBox control, where is defined on the ItemTemplate property, /// allowing the template to inherit the data type from the Items collection binding. /// [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] -public sealed class DataTypeInheritFromAttribute : Attribute +public sealed class InheritDataTypeFromItemsAttribute : Attribute { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The name of the property whose item type should be used on the target property. - public DataTypeInheritFromAttribute(string ancestorProperty) + /// The name of the property whose item type should be used on the target property. + public InheritDataTypeFromItemsAttribute(string ancestorItemsProperty) { - AncestorProperty = ancestorProperty; + AncestorItemsProperty = ancestorItemsProperty; } /// /// The name of the property whose item type should be used on the target property. /// - public string AncestorProperty { get; } + public string AncestorItemsProperty { get; } /// /// The ancestor type to be used in a lookup for the . diff --git a/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs b/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs index 2365e0ab5b..110590fef2 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs @@ -25,7 +25,7 @@ namespace Avalonia.Controls /// //TODO Binding [AssignBinding] - [DataTypeInheritFrom(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))] + [InheritDataTypeFromItems(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))] public virtual IBinding Binding { get diff --git a/src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs b/src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs index 6cf4c881b3..00318e2dd8 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs @@ -24,7 +24,7 @@ namespace Avalonia.Controls (o, v) => o.CellTemplate = v); [Content] - [DataTypeInheritFrom(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))] + [InheritDataTypeFromItems(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))] public IDataTemplate CellTemplate { get { return _cellTemplate; } @@ -51,7 +51,7 @@ namespace Avalonia.Controls /// /// If this property is the column is read-only. /// - [DataTypeInheritFrom(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))] + [InheritDataTypeFromItems(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))] public IDataTemplate CellEditingTemplate { get => _cellEditingCellTemplate; diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs index 5ea3fbb98e..59b5bf48a5 100644 --- a/src/Avalonia.Controls/ItemsControl.cs +++ b/src/Avalonia.Controls/ItemsControl.cs @@ -168,7 +168,7 @@ namespace Avalonia.Controls /// /// Gets or sets the data template used to display the items in the control. /// - [DataTypeInheritFrom(nameof(Items))] + [InheritDataTypeFromItems(nameof(Items))] public IDataTemplate? ItemTemplate { get { return GetValue(ItemTemplateProperty); } diff --git a/src/Avalonia.Controls/Repeater/ItemsRepeater.cs b/src/Avalonia.Controls/Repeater/ItemsRepeater.cs index bfd667d530..6c761ab4cf 100644 --- a/src/Avalonia.Controls/Repeater/ItemsRepeater.cs +++ b/src/Avalonia.Controls/Repeater/ItemsRepeater.cs @@ -122,7 +122,7 @@ namespace Avalonia.Controls /// /// Gets or sets the template used to display each item. /// - [DataTypeInheritFrom(nameof(Items))] + [InheritDataTypeFromItems(nameof(Items))] public IDataTemplate? ItemTemplate { get => GetValue(ItemTemplateProperty); diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs index 18af6d5a39..16049be5dc 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs @@ -72,7 +72,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers { // Infer data type from collection binding on a control that displays items. var property = context.ParentNodes().OfType().FirstOrDefault(); - var attributeType = context.GetAvaloniaTypes().DataTypeInheritFromAttribute; + var attributeType = context.GetAvaloniaTypes().InheritDataTypeFromItemsAttribute; var attribute = property?.Property?.GetClrProperty().CustomAttributes .FirstOrDefault(a => a.Type == attributeType); diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs index 6b36343852..0aa3dda693 100644 --- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs +++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs @@ -30,7 +30,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers public IXamlType AssignBindingAttribute { get; } public IXamlType DependsOnAttribute { get; } public IXamlType DataTypeAttribute { get; } - public IXamlType DataTypeInheritFromAttribute { get; } + public IXamlType InheritDataTypeFromItemsAttribute { get; } public IXamlType MarkupExtensionOptionAttribute { get; } public IXamlType MarkupExtensionDefaultOptionAttribute { get; } public IXamlType OnExtensionType { get; } @@ -136,7 +136,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers AssignBindingAttribute = cfg.TypeSystem.GetType("Avalonia.Data.AssignBindingAttribute"); DependsOnAttribute = cfg.TypeSystem.GetType("Avalonia.Metadata.DependsOnAttribute"); DataTypeAttribute = cfg.TypeSystem.GetType("Avalonia.Metadata.DataTypeAttribute"); - DataTypeInheritFromAttribute = cfg.TypeSystem.GetType("Avalonia.Metadata.DataTypeInheritFromAttribute"); + InheritDataTypeFromItemsAttribute = cfg.TypeSystem.GetType("Avalonia.Metadata.InheritDataTypeFromItemsAttribute"); MarkupExtensionOptionAttribute = cfg.TypeSystem.GetType("Avalonia.Metadata.MarkupExtensionOptionAttribute"); MarkupExtensionDefaultOptionAttribute = cfg.TypeSystem.GetType("Avalonia.Metadata.MarkupExtensionDefaultOptionAttribute"); OnExtensionType = cfg.TypeSystem.GetType("Avalonia.Markup.Xaml.MarkupExtensions.On"); diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index ba4b083e0d..0b33cd9d97 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -1948,10 +1948,10 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions public class DataGridLikeColumn { [AssignBinding] - [DataTypeInheritFrom(nameof(DataGridLikeControl.Items), AncestorType = typeof(DataGridLikeControl))] + [InheritDataTypeFromItems(nameof(DataGridLikeControl.Items), AncestorType = typeof(DataGridLikeControl))] public IBinding Binding { get; set; } - [DataTypeInheritFrom(nameof(DataGridLikeControl.Items), AncestorType = typeof(DataGridLikeControl))] + [InheritDataTypeFromItems(nameof(DataGridLikeControl.Items), AncestorType = typeof(DataGridLikeControl))] public IDataTemplate Template { get; set; } } }