From 5103eeeae72876d56f3f14a955318857c013a0b4 Mon Sep 17 00:00:00 2001 From: BoBoBaSs84 <73112377+BoBoBaSs84@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:24:21 +0100 Subject: [PATCH 1/3] feat: do some refactoring closes #144 --- src/BB84.Notifications/NotifiableObject.cs | 4 ++-- .../NotifiablePropertyTests.IsDefault.cs | 7 +++---- .../NotifiablePropertyTests.IsNull.cs | 2 +- tests/BB84.NotificationsTests/NotifiablePropertyTests.cs | 7 ++++++- tests/BB84.NotificationsTests/ReversiblePropertyTests.cs | 7 ++++++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/BB84.Notifications/NotifiableObject.cs b/src/BB84.Notifications/NotifiableObject.cs index ed2ec82..796d8ac 100644 --- a/src/BB84.Notifications/NotifiableObject.cs +++ b/src/BB84.Notifications/NotifiableObject.cs @@ -124,13 +124,13 @@ private void FillCaches() foreach (PropertyInfo propertyInfo in propertiesInfos) { NotifyChangedAttribute? changedAttribute = - propertyInfo.GetCustomAttribute(typeof(NotifyChangedAttribute), false) as NotifyChangedAttribute; + propertyInfo.GetCustomAttribute(false); if (changedAttribute is not null) _propertiesToNotifyOnChange.Add(propertyInfo.Name, changedAttribute.Properties); NotifyChangingAttribute? changingAttribute = - propertyInfo.GetCustomAttribute(typeof(NotifyChangingAttribute), false) as NotifyChangingAttribute; + propertyInfo.GetCustomAttribute(false); if (changingAttribute is not null) _propertiesToNotifyOnChanging.Add(propertyInfo.Name, changingAttribute.Properties); diff --git a/tests/BB84.NotificationsTests/NotifiablePropertyTests.IsDefault.cs b/tests/BB84.NotificationsTests/NotifiablePropertyTests.IsDefault.cs index 95b21c4..f1f9277 100644 --- a/tests/BB84.NotificationsTests/NotifiablePropertyTests.IsDefault.cs +++ b/tests/BB84.NotificationsTests/NotifiablePropertyTests.IsDefault.cs @@ -1,5 +1,4 @@ using BB84.Notifications; -using BB84.Notifications.Interfaces; namespace BB84.NotificationsTests; @@ -16,7 +15,7 @@ public sealed partial class NotifiablePropertyTests [DataRow(default, true)] public void IsDefault(object value, bool expected) { - INotifiableProperty bindableProperty = new NotifiableProperty(value); + NotifiableProperty bindableProperty = new(value); Assert.AreEqual(expected, bindableProperty.IsDefault); } @@ -27,7 +26,7 @@ public void IsDefault(object value, bool expected) [DataRow(default, true)] public void IsDefaultInteger(int value, bool expected) { - INotifiableProperty bindableProperty = new NotifiableProperty(value); + NotifiableProperty bindableProperty = new(value); Assert.AreEqual(expected, bindableProperty.IsDefault); } @@ -38,7 +37,7 @@ public void IsDefaultInteger(int value, bool expected) [DataRow(default, true)] public void IsDefaultNullableInteger(int? value, bool expected) { - INotifiableProperty bindableProperty = new NotifiableProperty(value); + NotifiableProperty bindableProperty = new(value); Assert.AreEqual(expected, bindableProperty.IsDefault); } diff --git a/tests/BB84.NotificationsTests/NotifiablePropertyTests.IsNull.cs b/tests/BB84.NotificationsTests/NotifiablePropertyTests.IsNull.cs index 23724b6..cba2ac9 100644 --- a/tests/BB84.NotificationsTests/NotifiablePropertyTests.IsNull.cs +++ b/tests/BB84.NotificationsTests/NotifiablePropertyTests.IsNull.cs @@ -16,7 +16,7 @@ public sealed partial class NotifiablePropertyTests [DataRow(null, true)] public void IsNull(object? value, bool expected) { - INotifiableProperty bindableProperty = new NotifiableProperty(value); + NotifiableProperty bindableProperty = new(value); Assert.AreEqual(expected, bindableProperty.IsNull); } diff --git a/tests/BB84.NotificationsTests/NotifiablePropertyTests.cs b/tests/BB84.NotificationsTests/NotifiablePropertyTests.cs index e50188b..175d116 100644 --- a/tests/BB84.NotificationsTests/NotifiablePropertyTests.cs +++ b/tests/BB84.NotificationsTests/NotifiablePropertyTests.cs @@ -6,8 +6,13 @@ namespace BB84.NotificationsTests; [TestClass] public sealed partial class NotifiablePropertyTests { - private sealed class TestClass(int bindableProperty) + private sealed class TestClass(int bindableProperty) : ITestClass { public INotifiableProperty BindableProperty { get; set; } = new NotifiableProperty(bindableProperty); } + + private interface ITestClass + { + INotifiableProperty BindableProperty { get; set; } + } } diff --git a/tests/BB84.NotificationsTests/ReversiblePropertyTests.cs b/tests/BB84.NotificationsTests/ReversiblePropertyTests.cs index 3fa0465..ee47fa0 100644 --- a/tests/BB84.NotificationsTests/ReversiblePropertyTests.cs +++ b/tests/BB84.NotificationsTests/ReversiblePropertyTests.cs @@ -24,11 +24,16 @@ public void ReversiblePropertyTest() Assert.AreEqual(default, testClass.Property.Value); } - private sealed class TestClass(int propertyValue) + private sealed class TestClass(int propertyValue) : ITestClass { public TestClass() : this(default) { } public IReversibleProperty Property { get; set; } = new ReversibleProperty(propertyValue); } + + private interface ITestClass + { + IReversibleProperty Property { get; set; } + } } From d7863fcbcc9cc7301678f66507264e03988d173f Mon Sep 17 00:00:00 2001 From: BoBoBaSs84 <73112377+BoBoBaSs84@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:32:27 +0100 Subject: [PATCH 2/3] fix: pipe line fix applied --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4795325..56b03d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,12 +20,9 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' - - - name: Restore - run: dotnet restore - name: Build - run: dotnet build --no-restore --configuration release --verbosity minimal + run: dotnet build --configuration release --verbosity minimal - name: Test run: dotnet test --no-build --configuration release --verbosity minimal \ No newline at end of file From 0162c15643eacc2e10b9091c18ede2aea461cbaa Mon Sep 17 00:00:00 2001 From: BoBoBaSs84 <73112377+BoBoBaSs84@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:35:00 +0100 Subject: [PATCH 3/3] fix: another pipe line fix applied --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56b03d7..16bed4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - name: Checkout @@ -20,9 +20,12 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' + + - name: Restore + run: dotnet restore - name: Build - run: dotnet build --configuration release --verbosity minimal + run: dotnet build --no-restore --configuration release --verbosity minimal - name: Test run: dotnet test --no-build --configuration release --verbosity minimal \ No newline at end of file