Browse Source
Merge pull request #2270 from mstr2/property-hotfix
Fixes a bug in AvaloniaPropertyRegistry
pull/2274/head
Steven Kirk
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
19 additions and
3 deletions
-
src/Avalonia.Base/AvaloniaPropertyRegistry.cs
-
tests/Avalonia.Base.UnitTests/AvaloniaPropertyRegistryTests.cs
|
|
|
@ -13,7 +13,7 @@ namespace Avalonia |
|
|
|
/// </summary>
|
|
|
|
public class AvaloniaPropertyRegistry |
|
|
|
{ |
|
|
|
private readonly IList<AvaloniaProperty> _properties = |
|
|
|
private readonly List<AvaloniaProperty> _properties = |
|
|
|
new List<AvaloniaProperty>(); |
|
|
|
private readonly Dictionary<Type, Dictionary<int, AvaloniaProperty>> _registered = |
|
|
|
new Dictionary<Type, Dictionary<int, AvaloniaProperty>>(); |
|
|
|
@ -30,6 +30,11 @@ namespace Avalonia |
|
|
|
public static AvaloniaPropertyRegistry Instance { get; } |
|
|
|
= new AvaloniaPropertyRegistry(); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a list of all registered properties.
|
|
|
|
/// </summary>
|
|
|
|
internal IReadOnlyList<AvaloniaProperty> Properties => _properties; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets all non-attached <see cref="AvaloniaProperty"/>s registered on a type.
|
|
|
|
/// </summary>
|
|
|
|
@ -250,8 +255,7 @@ namespace Avalonia |
|
|
|
{ |
|
|
|
inner.Add(property.Id, property); |
|
|
|
} |
|
|
|
|
|
|
|
_properties.Add(property); |
|
|
|
|
|
|
|
_attachedCache.Clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -19,6 +19,18 @@ namespace Avalonia.Base.UnitTests |
|
|
|
p = AttachedOwner.AttachedProperty; |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Registered_Properties_Count_Reflects_Newly_Added_Attached_Property() |
|
|
|
{ |
|
|
|
var registry = new AvaloniaPropertyRegistry(); |
|
|
|
var metadata = new StyledPropertyMetadata<int>(); |
|
|
|
var property = new AttachedProperty<int>("test", typeof(object), metadata, true); |
|
|
|
registry.Register(typeof(object), property); |
|
|
|
registry.RegisterAttached(typeof(AvaloniaPropertyRegistryTests), property); |
|
|
|
|
|
|
|
Assert.Equal(1, registry.Properties.Count); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void GetRegistered_Returns_Registered_Properties() |
|
|
|
{ |
|
|
|
|