Browse Source

Update naming

pull/10121/head
Max Katz 3 years ago
parent
commit
e9a01c6c21
  1. 14
      src/Avalonia.Base/Metadata/DataTypeInheritFromAttribute.cs
  2. 2
      src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs
  3. 4
      src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs
  4. 2
      src/Avalonia.Controls/ItemsControl.cs
  5. 2
      src/Avalonia.Controls/Repeater/ItemsRepeater.cs
  6. 2
      src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs
  7. 4
      src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs
  8. 4
      tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs

14
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.
/// </summary>
/// <remarks>
/// 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 <see cref="InheritDataTypeFromItemsAttribute"/> is defined on the ItemTemplate property,
/// allowing the template to inherit the data type from the Items collection binding.
/// </remarks>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class DataTypeInheritFromAttribute : Attribute
public sealed class InheritDataTypeFromItemsAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="DataTypeInheritFromAttribute"/> class.
/// Initializes a new instance of the <see cref="InheritDataTypeFromItemsAttribute"/> class.
/// </summary>
/// <param name="ancestorProperty">The name of the property whose item type should be used on the target property.</param>
public DataTypeInheritFromAttribute(string ancestorProperty)
/// <param name="ancestorItemsProperty">The name of the property whose item type should be used on the target property.</param>
public InheritDataTypeFromItemsAttribute(string ancestorItemsProperty)
{
AncestorProperty = ancestorProperty;
AncestorItemsProperty = ancestorItemsProperty;
}
/// <summary>
/// The name of the property whose item type should be used on the target property.
/// </summary>
public string AncestorProperty { get; }
public string AncestorItemsProperty { get; }
/// <summary>
/// The ancestor type to be used in a lookup for the <see cref="AncestorProperty"/>.

2
src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs

@ -25,7 +25,7 @@ namespace Avalonia.Controls
/// </summary>
//TODO Binding
[AssignBinding]
[DataTypeInheritFrom(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))]
[InheritDataTypeFromItems(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))]
public virtual IBinding Binding
{
get

4
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
/// <remarks>
/// If this property is <see langword="null"/> the column is read-only.
/// </remarks>
[DataTypeInheritFrom(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))]
[InheritDataTypeFromItems(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))]
public IDataTemplate CellEditingTemplate
{
get => _cellEditingCellTemplate;

2
src/Avalonia.Controls/ItemsControl.cs

@ -168,7 +168,7 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets the data template used to display the items in the control.
/// </summary>
[DataTypeInheritFrom(nameof(Items))]
[InheritDataTypeFromItems(nameof(Items))]
public IDataTemplate? ItemTemplate
{
get { return GetValue(ItemTemplateProperty); }

2
src/Avalonia.Controls/Repeater/ItemsRepeater.cs

@ -122,7 +122,7 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets the template used to display each item.
/// </summary>
[DataTypeInheritFrom(nameof(Items))]
[InheritDataTypeFromItems(nameof(Items))]
public IDataTemplate? ItemTemplate
{
get => GetValue(ItemTemplateProperty);

2
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<XamlPropertyAssignmentNode>().FirstOrDefault();
var attributeType = context.GetAvaloniaTypes().DataTypeInheritFromAttribute;
var attributeType = context.GetAvaloniaTypes().InheritDataTypeFromItemsAttribute;
var attribute = property?.Property?.GetClrProperty().CustomAttributes
.FirstOrDefault(a => a.Type == attributeType);

4
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");

4
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; }
}
}

Loading…
Cancel
Save