Skip to content

Commit 161fe2e

Browse files
authored
Merge pull request #18 from LibraStack/develop
New functionality and bug fixes.
2 parents 1dc598d + b5c5a05 commit 161fe2e

File tree

69 files changed

+903
-359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+903
-359
lines changed

samples/Unity.Mvvm.Calc/Assets/UI Toolkit/CalcView.uxml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<ui:VisualElement name="BottomPanel" class="bottom-panel">
88
<ui:VisualElement name="Row1" class="elements-row">
99
<UnityMvvmToolkit.UITK.BindableUIElements.BindableButton text="C" name="ButtonClear" command="ClearCommand" class="round-button round-button__clear-label" />
10-
<UnityMvvmToolkit.UITK.BindableUIElements.ButtonUITK text="+/-" name="ButtonSign" enabled="false" class="round-button round-button__operation-label" />
11-
<UnityMvvmToolkit.UITK.BindableUIElements.ButtonUITK text="%" name="ButtonPercentage" enabled="false" class="round-button round-button__operation-label" />
10+
<UnityMvvmToolkit.UITK.BindableUIElements.BindableButton text="+/-" name="ButtonSign" enabled="false" class="round-button round-button__operation-label" />
11+
<UnityMvvmToolkit.UITK.BindableUIElements.BindableButton text="%" name="ButtonPercentage" enabled="false" class="round-button round-button__operation-label" />
1212
<UnityMvvmToolkit.UITK.BindableUIElements.BindableButton text="÷" name="ButtonDivision" command="OperationCommand, ÷" class="round-button round-button__operation-label" />
1313
</ui:VisualElement>
1414
<ui:VisualElement name="Row2" class="elements-row">
@@ -31,7 +31,7 @@
3131
</ui:VisualElement>
3232
<ui:VisualElement name="Row5" class="elements-row">
3333
<UnityMvvmToolkit.UITK.BindableUIElements.BindableButton text="0" name="Button0" command="NumberCommand, 0" class="round-button round-button--wide" />
34-
<UnityMvvmToolkit.UITK.BindableUIElements.ButtonUITK text="." name="ButtonDot" enabled="false" class="round-button" />
34+
<UnityMvvmToolkit.UITK.BindableUIElements.BindableButton text="." name="ButtonDot" enabled="false" class="round-button" />
3535
<UnityMvvmToolkit.UITK.BindableUIElements.BindableButton text="=" name="ButtonEqual" command="CalculateCommand" class="round-button round-button--highlighted" />
3636
</ui:VisualElement>
3737
</ui:VisualElement>

samples/Unity.Mvvm.ToDoList/Assets/UI Toolkit/Styles/check-box.uss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
}
106106

107107
.check-box__tick--animation {
108-
transition-property: width height;
108+
transition-property: width, height;
109109
transition-duration: 150ms, 150ms;
110110
transition-timing-function: ease-out-back, ease-out-back;
111111
}

src/UnityMvvmToolkit.Core/.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"dotnet-stryker": {
6-
"version": "3.7.1",
6+
"version": "3.9.0",
77
"commands": [
88
"dotnet-stryker"
99
]

src/UnityMvvmToolkit.Core/Attributes/ObservableAttribute.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
using System;
22

3-
namespace System.Runtime.CompilerServices
4-
{
5-
internal static class IsExternalInit {}
6-
}
7-
83
namespace UnityMvvmToolkit.Core.Attributes
94
{
10-
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
5+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
116
public sealed class ObservableAttribute : Attribute
127
{
138
/// <summary>

src/UnityMvvmToolkit.Core/BindingContextObjectProvider.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ public TCommand GetCommand<TCommand>(IBindingContext context, string propertyNam
109109
{
110110
EnsureIsNotNullOrWhiteSpace(propertyName, nameof(propertyName));
111111

112-
if (TryGetContextMemberInfo(context.GetType(), propertyName, out var memberInfo) == false ||
113-
memberInfo.MemberType != MemberTypes.Property)
112+
if (TryGetContextMemberInfo(context.GetType(), propertyName, out var memberInfo) == false)
114113
{
115114
throw new InvalidOperationException($"Command '{propertyName}' not found.");
116115
}
@@ -131,8 +130,7 @@ public IBaseCommand RentCommandWrapper(IBindingContext context, CommandBindingDa
131130
EnsureIsNotNullOrWhiteSpace(bindingData.ParameterValue,
132131
$"Command '{bindingData.PropertyName}' has no parameter. Use {nameof(GetCommand)} instead.");
133132

134-
if (TryGetContextMemberInfo(context.GetType(), bindingData.PropertyName, out var memberInfo) == false ||
135-
memberInfo.MemberType != MemberTypes.Property)
133+
if (TryGetContextMemberInfo(context.GetType(), bindingData.PropertyName, out var memberInfo) == false)
136134
{
137135
throw new InvalidOperationException($"Command '{bindingData.PropertyName}' not found.");
138136
}

src/UnityMvvmToolkit.Core/Internal/BindingContextMemberProvider.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,39 @@ private static bool TryGetFieldHashCode(Type contextType, FieldInfo fieldInfo, o
5858
return false;
5959
}
6060

61-
if (fieldInfo.IsPublic)
61+
if (HasObservableAttribute(fieldInfo, out var propertyName))
6262
{
63-
return TryGetHashCode(contextType, fieldInfo.Name, fieldInfo.FieldType, out hashCode);
63+
return string.IsNullOrWhiteSpace(propertyName)
64+
? TryGetHashCode(contextType, GetBindableName(fieldInfo.Name), fieldInfo.FieldType, out hashCode)
65+
: TryGetHashCode(contextType, propertyName, fieldInfo.FieldType, out hashCode);
6466
}
6567

66-
if (HasObservableAttribute(fieldInfo, out var propertyName) == false)
68+
if (fieldInfo.IsPublic)
6769
{
68-
hashCode = default;
69-
return false;
70+
return TryGetHashCode(contextType, fieldInfo.Name, fieldInfo.FieldType, out hashCode);
7071
}
7172

72-
return string.IsNullOrWhiteSpace(propertyName)
73-
? TryGetHashCode(contextType, GetFieldName(fieldInfo.Name), fieldInfo.FieldType, out hashCode)
74-
: TryGetHashCode(contextType, propertyName, fieldInfo.FieldType, out hashCode);
73+
hashCode = default;
74+
return false;
7575
}
7676

7777
[MethodImpl(MethodImplOptions.AggressiveInlining)]
7878
private static bool TryGetPropertyHashCode(Type contextType, PropertyInfo propertyInfo, out int hashCode)
7979
{
80-
if (propertyInfo.GetMethod.IsPrivate)
80+
if (HasObservableAttribute(propertyInfo, out var propertyName))
8181
{
82-
hashCode = default;
83-
return false;
82+
return string.IsNullOrWhiteSpace(propertyName)
83+
? TryGetHashCode(contextType, GetBindableName(propertyInfo.Name), propertyInfo.PropertyType, out hashCode)
84+
: TryGetHashCode(contextType, propertyName, propertyInfo.PropertyType, out hashCode);
8485
}
8586

86-
return TryGetHashCode(contextType, propertyInfo.Name, propertyInfo.PropertyType, out hashCode);
87+
if (propertyInfo.GetMethod.IsPublic)
88+
{
89+
return TryGetHashCode(contextType, propertyInfo.Name, propertyInfo.PropertyType, out hashCode);
90+
}
91+
92+
hashCode = default;
93+
return false;
8794
}
8895

8996
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -116,9 +123,9 @@ private static bool HasObservableAttribute(MemberInfo fieldInfo, out string prop
116123
}
117124

118125
[MethodImpl(MethodImplOptions.AggressiveInlining)]
119-
private static string GetFieldName(string fieldName)
126+
private static string GetBindableName(string memberName)
120127
{
121-
var resultName = fieldName;
128+
var resultName = memberName;
122129

123130
if (resultName.Length > 1)
124131
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.ComponentModel;
2+
3+
// ReSharper disable CheckNamespace
4+
// ReSharper disable UnusedType.Global
5+
6+
namespace System.Runtime.CompilerServices
7+
{
8+
[EditorBrowsable(EditorBrowsableState.Never)]
9+
internal static class IsExternalInit
10+
{
11+
}
12+
}

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Common/Extensions/VisualElementExtensions.cs

Lines changed: 0 additions & 81 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using UnityMvvmToolkit.Core.Interfaces;
2+
3+
namespace UnityMvvmToolkit.Common.Interfaces
4+
{
5+
public interface IBindableCollection : IBindableElement
6+
{
7+
}
8+
}

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Common/Interfaces/IBindableCollection.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)