From d8cc0d693afc05e5c665cffcd00895d204110e45 Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Wed, 10 Apr 2024 20:21:26 +0200 Subject: [PATCH 1/8] Convert CacheStorageFacts to new style --- src/Catel.Tests/Caching/CacheStorageFacts.cs | 138 +++++++++---------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/src/Catel.Tests/Caching/CacheStorageFacts.cs b/src/Catel.Tests/Caching/CacheStorageFacts.cs index 1cb628399..56b2a847b 100644 --- a/src/Catel.Tests/Caching/CacheStorageFacts.cs +++ b/src/Catel.Tests/Caching/CacheStorageFacts.cs @@ -12,12 +12,12 @@ public class CacheStorageFacts { [TestFixture] - public class TheThreadSafeFunctionality + public class The_ThreadSafe_Functionality { private static readonly ILog Log = LogManager.GetCurrentClassLogger(); private readonly List _randomGuids = new List(); - public TheThreadSafeFunctionality() + public The_ThreadSafe_Functionality() { for (var i = 0; i < 10; i++) { @@ -26,7 +26,7 @@ public TheThreadSafeFunctionality() } [TestCase] - public void RunMultipleThreadsUsingGetFromCacheOrFetch() + public void Run_Multiple_Threads_Using_GetFromCacheOrFetch() { RunMultipleThreadsWithRandomAccessCalls((cache, key) => { @@ -40,7 +40,7 @@ public void RunMultipleThreadsUsingGetFromCacheOrFetch() } [TestCase] - public void RunMultipleThreadsUsingAddAndGet() + public void Run_Multiple_Threads_Using_Add_And_Get() { RunMultipleThreadsWithRandomAccessCalls((cache, key) => { @@ -103,10 +103,10 @@ private void RunMultipleThreadsWithRandomAccessCalls(Func(); @@ -118,7 +118,7 @@ public void ThrowsArgumentNullExceptionForNullKey() } [TestCase] - public void ReturnsRightValueForExistingKey() + public void Returns_Right_Value_For_Existing_Key() { var cache = new CacheStorage(); cache.Add("1", 1); @@ -129,10 +129,10 @@ public void ReturnsRightValueForExistingKey() } [TestFixture] - public class TheGetMethod + public class The_Get_Method { [TestCase] - public void ThrowsArgumentNullExceptionForNullKey() + public void Throws_ArgumentNullException_For_Null_Key() { var cache = new CacheStorage(); @@ -144,7 +144,7 @@ public void ThrowsArgumentNullExceptionForNullKey() } [TestCase] - public void ReturnsRightValueForExistingKey() + public void Returns_Right_Value_For_Existing_Key() { var cache = new CacheStorage(); cache.Add("1", 1); @@ -155,10 +155,10 @@ public void ReturnsRightValueForExistingKey() } [TestFixture] - public class TheContainsMethod + public class The_Contains_Method { [TestCase] - public void ThrowsArgumentNullExceptionForNullKey() + public void Throws_ArgumentNullException_For_Null_Key() { var cache = new CacheStorage(); @@ -166,7 +166,7 @@ public void ThrowsArgumentNullExceptionForNullKey() } [TestCase] - public void ReturnsFalseForNonExistingKey() + public void Returns_False_For_Non_Existing_Key() { var cache = new CacheStorage(); cache.Add("1", 1); @@ -176,7 +176,7 @@ public void ReturnsFalseForNonExistingKey() } [TestCase] - public void ReturnsTrueForExistingKey() + public void Returns_True_For_Existing_Key() { var cache = new CacheStorage(); cache.Add("1", 1); @@ -187,10 +187,10 @@ public void ReturnsTrueForExistingKey() } [TestFixture] - public class TheGetFromCacheOrFetchMethod + public class The_GetFromCacheOrFetch_Method { [TestCase] - public void ThrowsArgumentNullExceptionForNullKey() + public void Throws_ArgumentNullException_For_Null_Key() { var cache = new CacheStorage(); @@ -198,7 +198,7 @@ public void ThrowsArgumentNullExceptionForNullKey() } [TestCase] - public void ThrowsArgumentNullExceptionForNullFunction() + public void Throws_ArgumentNullException_For_Null_Function() { var cache = new CacheStorage(); @@ -206,7 +206,7 @@ public void ThrowsArgumentNullExceptionForNullFunction() } [TestCase] - public void AddsItemToCacheAndReturnsIt() + public void Adds_Item_To_Cache_And_Returns_It() { var cache = new CacheStorage(); @@ -218,7 +218,7 @@ public void AddsItemToCacheAndReturnsIt() } [TestCase] - public void ReturnsCachedItem() + public void Returns_Cached_Item() { var cache = new CacheStorage(); @@ -231,7 +231,7 @@ public void ReturnsCachedItem() } [TestCase] - public void AddsItemToCacheWithOverrideAndReturnsIt() + public void Adds_Item_To_Cache_With_Override_And_Returns_It() { var cache = new CacheStorage(); @@ -245,10 +245,10 @@ public void AddsItemToCacheWithOverrideAndReturnsIt() } [TestFixture] - public class TheAddMethod + public class The_Add_Method { [TestCase] - public void ThrowsArgumentNullExceptionForNullKey() + public void Throws_ArgumentNullException_For_Null_Key() { var cache = new CacheStorage(); @@ -256,7 +256,7 @@ public void ThrowsArgumentNullExceptionForNullKey() } [TestCase] - public void ThrowsArgumentNullExceptionForNullValueIfNotAllowNullValues() + public void Throws_ArgumentNullException_For_Null_Value_If_Not_Allow_Null_Values() { var cache = new CacheStorage(); @@ -264,7 +264,7 @@ public void ThrowsArgumentNullExceptionForNullValueIfNotAllowNullValues() } [TestCase] - public void AddsNonExistingValue() + public void Adds_Non_Existing_Value() { var cache = new CacheStorage(); cache.Add("1", 1); @@ -273,7 +273,7 @@ public void AddsNonExistingValue() } [TestCase] - public void AddsNonExistingValueForTrueOverride() + public void Adds_Non_Existing_Value_For_True_Override() { var cache = new CacheStorage(); cache.Add("1", 1); @@ -283,7 +283,7 @@ public void AddsNonExistingValueForTrueOverride() } [TestCase] - public void DoesNotAddExistingValueForFalseOverride() + public void Does_Not_Add_Existing_Value_For_False_Override() { var cache = new CacheStorage(); cache.Add("1", 1); @@ -294,10 +294,10 @@ public void DoesNotAddExistingValueForFalseOverride() } [TestFixture] - public class TheRemoveMethod + public class The_Remove_Method { [TestCase] - public void ThrowsArgumentNullExceptionForNullKey() + public void Throws_ArgumentNullException_For_Null_Key() { var cache = new CacheStorage(); @@ -305,7 +305,7 @@ public void ThrowsArgumentNullExceptionForNullKey() } [TestCase] - public void RemovesExistingValue() + public void Removes_Existing_Value() { var cache = new CacheStorage(); cache.Add("1", 1); @@ -318,14 +318,14 @@ public void RemovesExistingValue() } [TestCase] - public void RemovesNonExistingValue() + public void Removes_Non_Existing_Value() { var cache = new CacheStorage(); cache.Remove("1"); } [TestCase] - public void DoesNotRaiseExpiringEventOnItemRemoval() + public void Does_Not_Raise_Expiring_Event_On_Item_Removal() { var counter = 0; var cache = new CacheStorage(); @@ -336,7 +336,7 @@ public void DoesNotRaiseExpiringEventOnItemRemoval() } [TestCase] - public void DoesNotRaiseExpiredEventOnItemRemoval() + public void Does_Not_Raise_Expired_Event_On_Item_Removal() { var counter = 0; var cache = new CacheStorage(); @@ -348,10 +348,10 @@ public void DoesNotRaiseExpiredEventOnItemRemoval() } [TestFixture] - public class TheClearMethod + public class The_Clear_Method { [TestCase] - public void DoesNotRaiseExpiringEventOnClearStorage() + public void Does_Not_Raise_Expiring_Event_On_Clear_Storage() { var counter = 0; var cache = new CacheStorage(); @@ -362,7 +362,7 @@ public void DoesNotRaiseExpiringEventOnClearStorage() } [TestCase] - public void DoesNotRaiseExpiredEventOnClearStorage() + public void Does_Not_Raise_Expired_Event_On_Clear_Storage() { var counter = 0; var cache = new CacheStorage(); @@ -374,10 +374,10 @@ public void DoesNotRaiseExpiredEventOnClearStorage() } [TestFixture] - public class TheAutoExpireFunctionality + public class The_AutoExpire_Functionality { [TestCase] - public void IsAutomaticallyEnabledWhenStartedDisabledButAddingItemWithCustomExpirationPolicy() + public void Is_Automatically_Enabled_When_Started_Disabled_But_Adding_Item_With_Custom_ExpirationPolicy() { var cache = new CacheStorage(); cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250); @@ -392,7 +392,7 @@ public void IsAutomaticallyEnabledWhenStartedDisabledButAddingItemWithCustomExpi } [TestCase] - public void AutomaticallyRemovesExpiredItems() + public void Automatically_Removes_Expired_Items() { var cache = new CacheStorage(); cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250); @@ -407,7 +407,7 @@ public void AutomaticallyRemovesExpiredItems() } [TestCase] - public void AutomaticallyRemovesExpiredItemsOfACacheStorageWithDefaultExpirationPolicyInitializationCode() + public void Automatically_Removes_Expired_Items_Of_A_CacheStorage_With_Default_ExpirationPolicy_Initialization_Code() { var cache = new CacheStorage(() => ExpirationPolicy.Duration(TimeSpan.FromMilliseconds(250))); cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250); @@ -422,7 +422,7 @@ public void AutomaticallyRemovesExpiredItemsOfACacheStorageWithDefaultExpiration } [TestCase] - public void AddsAndExpiresSeveralItems() + public void Adds_And_Expires_Several_Items() { var cache = new CacheStorage(); cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250); @@ -439,7 +439,7 @@ public void AddsAndExpiresSeveralItems() } [TestCase] - public void RaisesExpiringEventWithCorrectEventArgsWhenItemExpires() + public void Raises_Expiring_Event_With_Correct_EventArgs_When_Item_Expires() { var key = "1"; var expirationPolicy = new SlidingExpirationPolicy(TimeSpan.FromMilliseconds(250)); @@ -467,7 +467,7 @@ public void RaisesExpiringEventWithCorrectEventArgsWhenItemExpires() } [TestCase] - public void ItemStaysInCacheWhenExpiringEventIsCanceled() + public void Item_Stays_In_Cache_When_Expiring_Event_Is_Canceled() { var key = "1"; var value = 1; @@ -487,7 +487,7 @@ public void ItemStaysInCacheWhenExpiringEventIsCanceled() } [TestCase] - public void RaisesExpiredEventWithCorrectEventArgsWhenItemExpires() + public void Raises_Expired_Event_With_Correct_EventArgs_When_Item_Expires() { var dispose = true; var key = "1"; @@ -517,25 +517,25 @@ public void RaisesExpiredEventWithCorrectEventArgsWhenItemExpires() } [TestFixture] - public class TheDisposeItemsOnRemovalFunctionality + public class The_DisposeItemsOnRemoval_Functionality { private sealed class CustomDisposable : IDisposable { public CustomDisposable() { - IsDiposed = false; + IsDisposed = false; } - public bool IsDiposed { get; private set; } + public bool IsDisposed { get; private set; } public void Dispose() { - IsDiposed = true; + IsDisposed = true; } } [TestCase] - public void DisposesExpiredItemsWhenDisposingEnabled() + public void Disposes_Expired_Items_When_Disposing_Enabled() { using (var disposable = new CustomDisposable()) { @@ -545,16 +545,16 @@ public void DisposesExpiredItemsWhenDisposingEnabled() cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250)); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); ThreadHelper.Sleep(750); - Assert.That(disposable.IsDiposed, Is.True); + Assert.That(disposable.IsDisposed, Is.True); } } [TestCase] - public void DisposesItemOnRemoveWhenDisposingEnabled() + public void Disposes_Item_On_Remove_When_Disposing_Enabled() { using (var disposable = new CustomDisposable()) { @@ -564,16 +564,16 @@ public void DisposesItemOnRemoveWhenDisposingEnabled() cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250)); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); cache.Remove("disposable"); - Assert.That(disposable.IsDiposed, Is.True); + Assert.That(disposable.IsDisposed, Is.True); } } [TestCase] - public void DisposesItemsOnClearWhenDisposingEnabled() + public void Disposes_Items_On_Clear_When_Disposing_Enabled() { using (var disposable = new CustomDisposable()) { @@ -583,16 +583,16 @@ public void DisposesItemsOnClearWhenDisposingEnabled() cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250)); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); cache.Clear(); - Assert.That(disposable.IsDiposed, Is.True); + Assert.That(disposable.IsDisposed, Is.True); } } [TestCase] - public void DoesNotDisposeExpiredItemWhenDisposingEnabledButCanceledByEventArgs() + public void Does_Not_Dispose_Expired_Item_When_Disposing_Enabled_But_Canceled_By_EventArgs() { using (var disposable = new CustomDisposable()) { @@ -608,12 +608,12 @@ public void DoesNotDisposeExpiredItemWhenDisposingEnabledButCanceledByEventArgs( ThreadHelper.Sleep(750); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); } } [TestCase] - public void DoesNotDisposeExpiredItemWhenDisposingNotEnabled() + public void Does_Not_Dispose_Expired_Item_When_Disposing_Not_Enabled() { using (var disposable = new CustomDisposable()) { @@ -622,16 +622,16 @@ public void DoesNotDisposeExpiredItemWhenDisposingNotEnabled() cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250)); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); ThreadHelper.Sleep(750); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); } } [TestCase] - public void DoesNotDisposeItemOnRemoveWhenDisposingNotEnabled() + public void Does_Not_Dispose_Item_On_Remove_When_Disposing_Not_Enabled() { using (var disposable = new CustomDisposable()) { @@ -640,16 +640,16 @@ public void DoesNotDisposeItemOnRemoveWhenDisposingNotEnabled() cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250)); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); cache.Remove("disposable"); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); } } [TestCase] - public void DoesNotDisposeItemsOnClearWhenDisposingNotEnabled() + public void Does_Not_Dispose_Items_On_Clear_When_Disposing_Not_Enabled() { using (var disposable = new CustomDisposable()) { @@ -658,16 +658,16 @@ public void DoesNotDisposeItemsOnClearWhenDisposingNotEnabled() cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250)); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); cache.Clear(); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); } } [TestCase] - public void DisposesExpiredItemWhenDisposingNotEnabledButForcedByEventArgs() + public void Disposes_Expired_Item_When_Disposing_Not_Enabled_But_Forced_By_EventArgs() { using (var disposable = new CustomDisposable()) { @@ -682,7 +682,7 @@ public void DisposesExpiredItemWhenDisposingNotEnabledButForcedByEventArgs() ThreadHelper.Sleep(750); - Assert.That(disposable.IsDiposed, Is.True); + Assert.That(disposable.IsDisposed, Is.True); } } } From 44d2fcd82a55f6147978ad453edaddb41da4875d Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Wed, 10 Apr 2024 20:26:31 +0200 Subject: [PATCH 2/8] Convert more tests --- .../Caching/CacheStorageValueInfoFacts.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Catel.Tests/Caching/CacheStorageValueInfoFacts.cs b/src/Catel.Tests/Caching/CacheStorageValueInfoFacts.cs index e5e05c979..ef99ee645 100644 --- a/src/Catel.Tests/Caching/CacheStorageValueInfoFacts.cs +++ b/src/Catel.Tests/Caching/CacheStorageValueInfoFacts.cs @@ -9,10 +9,10 @@ public class CacheStorageValueInfoFacts { [TestFixture] - public class TheCanExpireProperty + public class The_CanExpire_Property { [TestCase] - public void ReturnsTrueWhenTimeSpanIsNotZero() + public void Returns_True_When_TimeSpan_Is_Not_Zero() { var valueInfo = new CacheStorageValueInfo(0, new TimeSpan(0, 0, 5)); @@ -21,10 +21,10 @@ public void ReturnsTrueWhenTimeSpanIsNotZero() } [TestFixture] - public class TheIsExpiredProperty + public class The_IsExpired_Property { [TestCase] - public void ReturnsFalseWhenTimeSpanIsZero() + public void Returns_False_When_TimeSpan_Is_Zero() { var valueInfo = new CacheStorageValueInfo(0, new TimeSpan(0)); @@ -32,7 +32,7 @@ public void ReturnsFalseWhenTimeSpanIsZero() } [TestCase] - public void ReturnsFalseWhenTimeSpanIsNotZeroButValueIsNotExpired() + public void Returns_False_When_TimeSpan_Is_Not_Zero_But_Value_Is_Not_Expired() { var valueInfo = new CacheStorageValueInfo(0, new TimeSpan(0, 0, 2)); @@ -40,7 +40,7 @@ public void ReturnsFalseWhenTimeSpanIsNotZeroButValueIsNotExpired() } [TestCase] - public void ReturnsFalseWhileTheValueIsReadAndSlidingPolicyIsUsed() + public void Returns_False_While_The_Value_Is_Read_And_Sliding_Policy_Is_Used() { var valueInfo = new CacheStorageValueInfo(0, new SlidingExpirationPolicy(new TimeSpan(0, 0, 1))); var startTime = FastDateTime.Now; @@ -55,7 +55,7 @@ public void ReturnsFalseWhileTheValueIsReadAndSlidingPolicyIsUsed() } [TestCase] - public void ReturnsTrueWhenTheValueIsNotReadAndSlidingPolicyIsUsed() + public void Returns_True_When_The_Value_Is_Not_Read_And_Sliding_Policy_Is_Used() { var valueInfo = new CacheStorageValueInfo(0, new SlidingExpirationPolicy(new TimeSpan(0, 0, 0, 0, 250))); @@ -65,7 +65,7 @@ public void ReturnsTrueWhenTheValueIsNotReadAndSlidingPolicyIsUsed() } [TestCase] - public void ReturnsTrueWhenTimeSpanIsNotZeroAndValueIsExpired() + public void Returns_True_When_TimeSpan_Is_Not_Zero_And_Value_Is_Expired() { var valueInfo = new CacheStorageValueInfo(0, new TimeSpan(0, 0, 0, 0, 250)); @@ -76,36 +76,36 @@ public void ReturnsTrueWhenTimeSpanIsNotZeroAndValueIsExpired() } [TestFixture] - public class TheDisposeValueMethod + public class The_DisposeValue_Method { private sealed class CustomDisposable : IDisposable { public CustomDisposable() { - IsDiposed = false; + IsDisposed = false; } - public bool IsDiposed { get; private set; } + public bool IsDisposed { get; private set; } public void Dispose() { - IsDiposed = true; + IsDisposed = true; } } [TestCase] - public void ValueIsNotDisposedBeforeCall() + public void Value_Is_Not_Disposed_Before_Call() { using (var disposable = new CustomDisposable()) { var valueInfo = new CacheStorageValueInfo(disposable, TimeSpan.FromMilliseconds(250)); - Assert.That(disposable.IsDiposed, Is.False); + Assert.That(disposable.IsDisposed, Is.False); } } [TestCase] - public void ValueIsDisposedAfterCall() + public void Value_Is_Disposed_After_Call() { using (var disposable = new CustomDisposable()) { @@ -113,7 +113,7 @@ public void ValueIsDisposedAfterCall() valueInfo.DisposeValue(); - Assert.That(disposable.IsDiposed, Is.True); + Assert.That(disposable.IsDisposed, Is.True); } } } From 1267e993be9459914d0fd54c2dcd4672ec1b8fa4 Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Wed, 10 Apr 2024 20:37:34 +0200 Subject: [PATCH 3/8] #2195 CacheStorage should not enable auto expiration by default without default policy --- src/Catel.Core/Caching/CacheStorage.cs | 30 ++++++++++++++----- .../Caching/Interfaces/ICacheStorage.cs | 8 ++--- src/Catel.Tests/Caching/CacheStorageFacts.cs | 15 ++++++++++ ...re_HasNoBreakingChanges_Async.verified.txt | 13 ++++---- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/Catel.Core/Caching/CacheStorage.cs b/src/Catel.Core/Caching/CacheStorage.cs index 690e47d43..e54e7cc79 100644 --- a/src/Catel.Core/Caching/CacheStorage.cs +++ b/src/Catel.Core/Caching/CacheStorage.cs @@ -245,11 +245,11 @@ public TValue GetFromCacheOrFetch(TKey key, Func code, ExpirationPolicy? /// The instance initialized by the . /// If is null. /// If is null. - public TValue GetFromCacheOrFetch(TKey key, Func code, bool @override = false, TimeSpan expiration = default) + public TValue GetFromCacheOrFetch(TKey key, Func code, bool @override = false, TimeSpan? expiration = default) { ArgumentNullException.ThrowIfNull(code); - return GetFromCacheOrFetch(key, code, ExpirationPolicy.Duration(expiration), @override); + return GetFromCacheOrFetch(key, code, CreateDefaultExpirationPolicy(expiration), @override); } /// @@ -308,7 +308,7 @@ public Task GetFromCacheOrFetchAsync(TKey key, Func> code, /// /// Adds a value to the cache associated with to a key asynchronously. /// - /// Note that this is a wrapper around . + /// Note that this is a wrapper around . /// /// The key. /// The deferred initialization code of the value. @@ -317,9 +317,9 @@ public Task GetFromCacheOrFetchAsync(TKey key, Func> code, /// The instance initialized by the . /// If is null. /// If is null. - public Task GetFromCacheOrFetchAsync(TKey key, Func> code, bool @override = false, TimeSpan expiration = default) + public Task GetFromCacheOrFetchAsync(TKey key, Func> code, bool @override = false, TimeSpan? expiration = default) { - return GetFromCacheOrFetchAsync(key, code, ExpirationPolicy.Duration(expiration), @override); + return GetFromCacheOrFetchAsync(key, code, CreateDefaultExpirationPolicy(expiration), @override); } /// @@ -330,9 +330,9 @@ public Task GetFromCacheOrFetchAsync(TKey key, Func> code, /// Indicates if the key exists the value will be overridden. /// The timespan in which the cache item should expire when added. /// The is null. - public void Add(TKey key, TValue @value, bool @override = false, TimeSpan expiration = default(TimeSpan)) + public void Add(TKey key, TValue @value, bool @override = false, TimeSpan? expiration = default) { - Add(key, value, ExpirationPolicy.Duration(expiration), @override); + Add(key, value, CreateDefaultExpirationPolicy(expiration), @override); } /// @@ -392,6 +392,22 @@ public void Clear() } } + /// + /// Creates the default expiration policy. + /// + /// + /// + protected virtual ExpirationPolicy? CreateDefaultExpirationPolicy(TimeSpan? expiration) + { + if (expiration is null || + expiration == default(TimeSpan)) + { + return null; + } + + return ExpirationPolicy.Duration(expiration.Value); + } + /// /// Removes the expired items from the cache. /// diff --git a/src/Catel.Core/Caching/Interfaces/ICacheStorage.cs b/src/Catel.Core/Caching/Interfaces/ICacheStorage.cs index d7b883216..bb0cbdc62 100644 --- a/src/Catel.Core/Caching/Interfaces/ICacheStorage.cs +++ b/src/Catel.Core/Caching/Interfaces/ICacheStorage.cs @@ -78,7 +78,7 @@ public interface ICacheStorage /// If is null. /// If is null. /// If is null. - TValue GetFromCacheOrFetch(TKey key, Func code, bool @override = false, TimeSpan expiration = default); + TValue GetFromCacheOrFetch(TKey key, Func code, bool @override = false, TimeSpan? expiration = default); /// /// Adds a value to the cache associated with to a key. @@ -100,7 +100,7 @@ public interface ICacheStorage /// Indicates if the key exists the value will be overridden. /// The timespan in which the cache item should expire when added. /// The is null. - void Add(TKey key, TValue @value, bool @override = false, TimeSpan expiration = default); + void Add(TKey key, TValue @value, bool @override = false, TimeSpan? expiration = default); /// /// Removes an item from the cache. @@ -142,7 +142,7 @@ public interface ICacheStorage /// /// Adds a value to the cache associated with to a key asynchronously. /// - /// Note that this is a wrapper around . + /// Note that this is a wrapper around . /// /// The key. /// The deferred initialization code of the value. @@ -151,6 +151,6 @@ public interface ICacheStorage /// The instance initialized by the . /// If is null. /// If is null. - Task GetFromCacheOrFetchAsync(TKey key, Func> code, bool @override = false, TimeSpan expiration = default); + Task GetFromCacheOrFetchAsync(TKey key, Func> code, bool @override = false, TimeSpan? expiration = default); } } diff --git a/src/Catel.Tests/Caching/CacheStorageFacts.cs b/src/Catel.Tests/Caching/CacheStorageFacts.cs index 56b2a847b..d2eca8d6b 100644 --- a/src/Catel.Tests/Caching/CacheStorageFacts.cs +++ b/src/Catel.Tests/Caching/CacheStorageFacts.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Threading; + using System.Threading.Tasks; using Catel.Caching; using Catel.Caching.Policies; using Catel.Logging; @@ -514,6 +515,20 @@ public void Raises_Expired_Event_With_Correct_EventArgs_When_Item_Expires() Assert.That(evKey, Is.EqualTo(key)); Assert.That(evValue, Is.EqualTo(value)); } + + [TestCase] + public async Task Is_Disabled_By_Default_Async() + { + var cache = new CacheStorage(); + + cache.Add("1", 1); + + Assert.That(cache.Contains("1"), Is.True); + + await Task.Delay(TimeSpan.FromSeconds(2)); + + Assert.That(cache.Contains("1"), Is.True); + } } [TestFixture] diff --git a/src/Catel.Tests/PublicApiFacts.Catel_Core_HasNoBreakingChanges_Async.verified.txt b/src/Catel.Tests/PublicApiFacts.Catel_Core_HasNoBreakingChanges_Async.verified.txt index f0a06010c..441836fa4 100644 --- a/src/Catel.Tests/PublicApiFacts.Catel_Core_HasNoBreakingChanges_Async.verified.txt +++ b/src/Catel.Tests/PublicApiFacts.Catel_Core_HasNoBreakingChanges_Async.verified.txt @@ -546,14 +546,15 @@ namespace Catel.Caching public event System.EventHandler>? Expired; public event System.EventHandler>? Expiring; public void Add(TKey key, TValue value, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false) { } - public void Add(TKey key, TValue value, bool override = false, System.TimeSpan expiration = default) { } + public void Add(TKey key, TValue value, bool override = false, System.TimeSpan? expiration = default) { } public void Clear() { } public bool Contains(TKey key) { } + protected virtual Catel.Caching.Policies.ExpirationPolicy? CreateDefaultExpirationPolicy(System.TimeSpan? expiration) { } public TValue? Get(TKey key) { } public TValue GetFromCacheOrFetch(TKey key, System.Func code, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false) { } - public TValue GetFromCacheOrFetch(TKey key, System.Func code, bool override = false, System.TimeSpan expiration = default) { } + public TValue GetFromCacheOrFetch(TKey key, System.Func code, bool override = false, System.TimeSpan? expiration = default) { } public System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false) { } - public System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, bool override = false, System.TimeSpan expiration = default) { } + public System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, bool override = false, System.TimeSpan? expiration = default) { } public void Remove(TKey key, System.Action? action = null) { } } public class ExpiredEventArgs : System.EventArgs @@ -583,14 +584,14 @@ namespace Catel.Caching event System.EventHandler>? Expired; event System.EventHandler>? Expiring; void Add(TKey key, TValue value, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false); - void Add(TKey key, TValue value, bool override = false, System.TimeSpan expiration = default); + void Add(TKey key, TValue value, bool override = false, System.TimeSpan? expiration = default); void Clear(); bool Contains(TKey key); TValue? Get(TKey key); TValue GetFromCacheOrFetch(TKey key, System.Func code, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false); - TValue GetFromCacheOrFetch(TKey key, System.Func code, bool override = false, System.TimeSpan expiration = default); + TValue GetFromCacheOrFetch(TKey key, System.Func code, bool override = false, System.TimeSpan? expiration = default); System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false); - System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, bool override = false, System.TimeSpan expiration = default); + System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, bool override = false, System.TimeSpan? expiration = default); void Remove(TKey key, System.Action? action = null); } } From 9e4b60c0bc2f2650593113b4e6e2cc1fee4e08b2 Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Wed, 10 Apr 2024 20:40:32 +0200 Subject: [PATCH 4/8] Update year --- src/SolutionAssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SolutionAssemblyInfo.cs b/src/SolutionAssemblyInfo.cs index 005da2de6..bb4c44756 100644 --- a/src/SolutionAssemblyInfo.cs +++ b/src/SolutionAssemblyInfo.cs @@ -9,5 +9,5 @@ [assembly: AssemblyVersion("6.0.2")] [assembly: AssemblyFileVersion("6.0.2")] [assembly: AssemblyInformationalVersion("6.0.2-beta.1336")] -[assembly: AssemblyCopyright("Copyright © CatenaLogic 2010 - 2023")] +[assembly: AssemblyCopyright("Copyright © CatenaLogic 2010 - 2024")] From 4ed13f37dea6fac48148452a8caf4851d6175f20 Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Wed, 10 Apr 2024 20:46:58 +0200 Subject: [PATCH 5/8] Small code smell fixes --- .../Collections/Extensions/CollectionExtensions.cs | 2 +- src/Catel.Core/Logging/Log.cs | 2 +- src/Catel.Core/Reflection/Helpers/PropertyHelper.cs | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Catel.Core/Collections/Extensions/CollectionExtensions.cs b/src/Catel.Core/Collections/Extensions/CollectionExtensions.cs index d5af78cf6..50499d531 100644 --- a/src/Catel.Core/Collections/Extensions/CollectionExtensions.cs +++ b/src/Catel.Core/Collections/Extensions/CollectionExtensions.cs @@ -351,7 +351,7 @@ public static Array ToArray(this IEnumerable collection, Type elementType) { ArgumentNullException.ThrowIfNull(collection); - var internalList = new List(collection is not null ? collection.Cast() : Array.Empty()); + var internalList = new List(collection.Cast()); var array = Array.CreateInstance(elementType, internalList.Count); var index = 0; diff --git a/src/Catel.Core/Logging/Log.cs b/src/Catel.Core/Logging/Log.cs index ba0c70d07..8f721dbec 100644 --- a/src/Catel.Core/Logging/Log.cs +++ b/src/Catel.Core/Logging/Log.cs @@ -46,7 +46,7 @@ public Log(string name, Type targetType) Name = name; TargetType = targetType; - IsCatelLogging = targetType?.IsCatelType() ?? false; + IsCatelLogging = targetType.IsCatelType(); _shouldIgnoreIfCatelLoggingIsDisabled = new Lazy(ShouldIgnoreIfCatelLoggingIsDisabled); } diff --git a/src/Catel.Core/Reflection/Helpers/PropertyHelper.cs b/src/Catel.Core/Reflection/Helpers/PropertyHelper.cs index bc7e321b5..da86ea1ac 100644 --- a/src/Catel.Core/Reflection/Helpers/PropertyHelper.cs +++ b/src/Catel.Core/Reflection/Helpers/PropertyHelper.cs @@ -357,9 +357,11 @@ public static TValue GetHiddenPropertyValue(object obj, string property, { var objectType = obj.GetType(); + var stringComparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; + if (!ignoreCase) { - // Use old mechanism to ensure no breaking changes / performance hite + // Use old mechanism to ensure no breaking changes / performance hits return objectType.GetPropertyEx(property); } @@ -367,7 +369,7 @@ public static TValue GetHiddenPropertyValue(object obj, string property, foreach (var propertyInfo in allProperties) { - if (string.Equals(propertyInfo.Name, property, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) + if (string.Equals(propertyInfo.Name, property, stringComparison)) { return propertyInfo; } From 8a97cee8db6f1a384ad2cb72b8a0162a44ee5dd3 Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Wed, 10 Apr 2024 20:48:54 +0200 Subject: [PATCH 6/8] Build script maintenance --- deployment/cake/docker-tasks.cake | 2 +- deployment/cake/generic-variables.cake | 4 ++-- deployment/cake/github-pages-tasks.cake | 2 +- deployment/cake/issuetrackers-github.cake | 2 +- deployment/cake/lib-msbuild.cake | 4 ++-- deployment/cake/sourcecontrol-github.cake | 2 +- deployment/cake/tasks.cake | 20 ++++++++++---------- deployment/cake/tests-nunit.cake | 2 +- src/Directory.Build.analyzers.props | 2 +- src/Directory.Build.shared.implicit.props | 8 ++++++++ 10 files changed, 28 insertions(+), 20 deletions(-) diff --git a/deployment/cake/docker-tasks.cake b/deployment/cake/docker-tasks.cake index 79350bf38..007572d7a 100644 --- a/deployment/cake/docker-tasks.cake +++ b/deployment/cake/docker-tasks.cake @@ -1,7 +1,7 @@ #l "docker-variables.cake" #l "lib-octopusdeploy.cake" -#addin "nuget:?package=Cake.Docker&version=1.2.3" +#addin "nuget:?package=Cake.Docker&version=1.3.0" //------------------------------------------------------------- diff --git a/deployment/cake/generic-variables.cake b/deployment/cake/generic-variables.cake index a3a34d2ad..246657fd9 100644 --- a/deployment/cake/generic-variables.cake +++ b/deployment/cake/generic-variables.cake @@ -400,7 +400,7 @@ public class SonarQubeContext : BuildContextBase public string Url { get; set; } public string Organization { get; set; } public string Username { get; set; } - public string Password { get; set; } + public string Token { get; set; } public string Project { get; set; } protected override void ValidateContext() @@ -514,7 +514,7 @@ private GeneralContext InitializeGeneralContext(BuildContext buildContext, IBuil Url = buildContext.BuildServer.GetVariable("SonarUrl", showValue: true), Organization = buildContext.BuildServer.GetVariable("SonarOrganization", showValue: true), Username = buildContext.BuildServer.GetVariable("SonarUsername", showValue: false), - Password = buildContext.BuildServer.GetVariable("SonarPassword", showValue: false), + Token = buildContext.BuildServer.GetVariable("SonarToken", showValue: false), Project = buildContext.BuildServer.GetVariable("SonarProject", data.Solution.Name, showValue: true) }; diff --git a/deployment/cake/github-pages-tasks.cake b/deployment/cake/github-pages-tasks.cake index 9e0082738..98aad9aef 100644 --- a/deployment/cake/github-pages-tasks.cake +++ b/deployment/cake/github-pages-tasks.cake @@ -1,6 +1,6 @@ #l "github-pages-variables.cake" -#addin "nuget:?package=Cake.Git&version=3.0.0" +#addin "nuget:?package=Cake.Git&version=4.0.0" //------------------------------------------------------------- diff --git a/deployment/cake/issuetrackers-github.cake b/deployment/cake/issuetrackers-github.cake index 027491259..efa409b93 100644 --- a/deployment/cake/issuetrackers-github.cake +++ b/deployment/cake/issuetrackers-github.cake @@ -1,4 +1,4 @@ -#tool "nuget:?package=gitreleasemanager&version=0.16.0" +#tool "nuget:?package=gitreleasemanager&version=0.17.0" //------------------------------------------------------------- diff --git a/deployment/cake/lib-msbuild.cake b/deployment/cake/lib-msbuild.cake index 9df7f61e5..ec71055b8 100644 --- a/deployment/cake/lib-msbuild.cake +++ b/deployment/cake/lib-msbuild.cake @@ -1,5 +1,5 @@ -#addin "nuget:?package=Cake.Issues&version=3.0.0" -#addin "nuget:?package=Cake.Issues.MsBuild&version=3.0.0" +#addin "nuget:?package=Cake.Issues&version=4.1.0" +#addin "nuget:?package=Cake.Issues.MsBuild&version=4.1.0" #tool "nuget:?package=MSBuild.Extension.Pack&version=1.9.1" diff --git a/deployment/cake/sourcecontrol-github.cake b/deployment/cake/sourcecontrol-github.cake index 6b06b4a36..a481e8413 100644 --- a/deployment/cake/sourcecontrol-github.cake +++ b/deployment/cake/sourcecontrol-github.cake @@ -1,5 +1,5 @@ #addin "nuget:?package=Cake.GitHub&version=0.1.0" -#addin "nuget:?package=Octokit&version=9.0.0" +#addin "nuget:?package=Octokit&version=10.0.0" //------------------------------------------------------------- diff --git a/deployment/cake/tasks.cake b/deployment/cake/tasks.cake index 7fa530e19..9f4dc7590 100644 --- a/deployment/cake/tasks.cake +++ b/deployment/cake/tasks.cake @@ -24,8 +24,8 @@ #l "tests.cake" #l "templates-tasks.cake" -#addin "nuget:?package=Cake.FileHelpers&version=6.1.3" -#addin "nuget:?package=Cake.Sonar&version=1.1.32" +#addin "nuget:?package=Cake.FileHelpers&version=7.0.0" +#addin "nuget:?package=Cake.Sonar&version=1.1.33" #addin "nuget:?package=MagicChunks&version=2.0.0.119" #addin "nuget:?package=Newtonsoft.Json&version=13.0.3" @@ -36,7 +36,7 @@ // It probably means the tool is not correctly installed. // `dotnet tool install --global dotnet-sonarscanner --ignore-failed-sources` //#tool "nuget:?package=MSBuild.SonarQube.Runner.Tool&version=4.8.0" -#tool "nuget:?package=dotnet-sonarscanner&version=6.0.0" +#tool "nuget:?package=dotnet-sonarscanner&version=6.2.0" //------------------------------------------------------------- // BACKWARDS COMPATIBILITY CODE - START @@ -397,9 +397,9 @@ Task("Build") sonarSettings.Login = buildContext.General.SonarQube.Username; } - if (!string.IsNullOrWhiteSpace(buildContext.General.SonarQube.Password)) + if (!string.IsNullOrWhiteSpace(buildContext.General.SonarQube.Token)) { - sonarSettings.Password = buildContext.General.SonarQube.Password; + sonarSettings.Token = buildContext.General.SonarQube.Token; } // see https://cakebuild.net/api/Cake.Sonar/SonarBeginSettings/ for more information on @@ -450,7 +450,7 @@ Task("Build") { await buildContext.SourceControl.MarkBuildAsPendingAsync("SonarQube"); - var sonarEndSettings = new SonarEndSettings + var sonarSettings = new SonarEndSettings { // Use core clr version of SonarQube UseCoreClr = true @@ -458,17 +458,17 @@ Task("Build") if (!string.IsNullOrWhiteSpace(buildContext.General.SonarQube.Username)) { - sonarEndSettings.Login = buildContext.General.SonarQube.Username; + sonarSettings.Login = buildContext.General.SonarQube.Username; } - if (!string.IsNullOrWhiteSpace(buildContext.General.SonarQube.Password)) + if (!string.IsNullOrWhiteSpace(buildContext.General.SonarQube.Token)) { - sonarEndSettings.Password = buildContext.General.SonarQube.Password; + sonarSettings.Token = buildContext.General.SonarQube.Token; } Information("Ending SonarQube"); - SonarEnd(sonarEndSettings); + SonarEnd(sonarSettings); await buildContext.SourceControl.MarkBuildAsSucceededAsync("SonarQube"); } diff --git a/deployment/cake/tests-nunit.cake b/deployment/cake/tests-nunit.cake index a9216a8ea..59b559a30 100644 --- a/deployment/cake/tests-nunit.cake +++ b/deployment/cake/tests-nunit.cake @@ -1,4 +1,4 @@ -#tool "nuget:?package=NUnit.ConsoleRunner&version=3.16.3" +#tool "nuget:?package=NUnit.ConsoleRunner&version=3.17.0" //------------------------------------------------------------- diff --git a/src/Directory.Build.analyzers.props b/src/Directory.Build.analyzers.props index ec23151bd..595ea76b4 100644 --- a/src/Directory.Build.analyzers.props +++ b/src/Directory.Build.analyzers.props @@ -16,7 +16,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Directory.Build.shared.implicit.props b/src/Directory.Build.shared.implicit.props index b223f6f69..87dbcba9b 100644 --- a/src/Directory.Build.shared.implicit.props +++ b/src/Directory.Build.shared.implicit.props @@ -53,6 +53,14 @@ true + + + + direct + + low + + true From 4264ff01b30d4ff2540a30b54a84fc9c54c6a522 Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Wed, 10 Apr 2024 20:50:46 +0200 Subject: [PATCH 7/8] Bump --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index c33ff7cb5..da200cdae 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "3.2.0", + "version": "4.0.0", "commands": [ "dotnet-cake" ] From 3937d56889f918f1fbde7098d0b0e7a0d016fd73 Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Wed, 10 Apr 2024 21:04:22 +0200 Subject: [PATCH 8/8] Prevent API changes --- src/Catel.Core/Caching/CacheStorage.cs | 8 ++++---- src/Catel.Core/Caching/Interfaces/ICacheStorage.cs | 8 ++++---- ...atel_Core_HasNoBreakingChanges_Async.verified.txt | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Catel.Core/Caching/CacheStorage.cs b/src/Catel.Core/Caching/CacheStorage.cs index e54e7cc79..54c52016c 100644 --- a/src/Catel.Core/Caching/CacheStorage.cs +++ b/src/Catel.Core/Caching/CacheStorage.cs @@ -245,7 +245,7 @@ public TValue GetFromCacheOrFetch(TKey key, Func code, ExpirationPolicy? /// The instance initialized by the . /// If is null. /// If is null. - public TValue GetFromCacheOrFetch(TKey key, Func code, bool @override = false, TimeSpan? expiration = default) + public TValue GetFromCacheOrFetch(TKey key, Func code, bool @override = false, TimeSpan expiration = default) { ArgumentNullException.ThrowIfNull(code); @@ -308,7 +308,7 @@ public Task GetFromCacheOrFetchAsync(TKey key, Func> code, /// /// Adds a value to the cache associated with to a key asynchronously. /// - /// Note that this is a wrapper around . + /// Note that this is a wrapper around . /// /// The key. /// The deferred initialization code of the value. @@ -317,7 +317,7 @@ public Task GetFromCacheOrFetchAsync(TKey key, Func> code, /// The instance initialized by the . /// If is null. /// If is null. - public Task GetFromCacheOrFetchAsync(TKey key, Func> code, bool @override = false, TimeSpan? expiration = default) + public Task GetFromCacheOrFetchAsync(TKey key, Func> code, bool @override = false, TimeSpan expiration = default) { return GetFromCacheOrFetchAsync(key, code, CreateDefaultExpirationPolicy(expiration), @override); } @@ -330,7 +330,7 @@ public Task GetFromCacheOrFetchAsync(TKey key, Func> code, /// Indicates if the key exists the value will be overridden. /// The timespan in which the cache item should expire when added. /// The is null. - public void Add(TKey key, TValue @value, bool @override = false, TimeSpan? expiration = default) + public void Add(TKey key, TValue @value, bool @override = false, TimeSpan expiration = default) { Add(key, value, CreateDefaultExpirationPolicy(expiration), @override); } diff --git a/src/Catel.Core/Caching/Interfaces/ICacheStorage.cs b/src/Catel.Core/Caching/Interfaces/ICacheStorage.cs index bb0cbdc62..d7b883216 100644 --- a/src/Catel.Core/Caching/Interfaces/ICacheStorage.cs +++ b/src/Catel.Core/Caching/Interfaces/ICacheStorage.cs @@ -78,7 +78,7 @@ public interface ICacheStorage /// If is null. /// If is null. /// If is null. - TValue GetFromCacheOrFetch(TKey key, Func code, bool @override = false, TimeSpan? expiration = default); + TValue GetFromCacheOrFetch(TKey key, Func code, bool @override = false, TimeSpan expiration = default); /// /// Adds a value to the cache associated with to a key. @@ -100,7 +100,7 @@ public interface ICacheStorage /// Indicates if the key exists the value will be overridden. /// The timespan in which the cache item should expire when added. /// The is null. - void Add(TKey key, TValue @value, bool @override = false, TimeSpan? expiration = default); + void Add(TKey key, TValue @value, bool @override = false, TimeSpan expiration = default); /// /// Removes an item from the cache. @@ -142,7 +142,7 @@ public interface ICacheStorage /// /// Adds a value to the cache associated with to a key asynchronously. /// - /// Note that this is a wrapper around . + /// Note that this is a wrapper around . /// /// The key. /// The deferred initialization code of the value. @@ -151,6 +151,6 @@ public interface ICacheStorage /// The instance initialized by the . /// If is null. /// If is null. - Task GetFromCacheOrFetchAsync(TKey key, Func> code, bool @override = false, TimeSpan? expiration = default); + Task GetFromCacheOrFetchAsync(TKey key, Func> code, bool @override = false, TimeSpan expiration = default); } } diff --git a/src/Catel.Tests/PublicApiFacts.Catel_Core_HasNoBreakingChanges_Async.verified.txt b/src/Catel.Tests/PublicApiFacts.Catel_Core_HasNoBreakingChanges_Async.verified.txt index 441836fa4..8c04f1ad2 100644 --- a/src/Catel.Tests/PublicApiFacts.Catel_Core_HasNoBreakingChanges_Async.verified.txt +++ b/src/Catel.Tests/PublicApiFacts.Catel_Core_HasNoBreakingChanges_Async.verified.txt @@ -546,15 +546,15 @@ namespace Catel.Caching public event System.EventHandler>? Expired; public event System.EventHandler>? Expiring; public void Add(TKey key, TValue value, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false) { } - public void Add(TKey key, TValue value, bool override = false, System.TimeSpan? expiration = default) { } + public void Add(TKey key, TValue value, bool override = false, System.TimeSpan expiration = default) { } public void Clear() { } public bool Contains(TKey key) { } protected virtual Catel.Caching.Policies.ExpirationPolicy? CreateDefaultExpirationPolicy(System.TimeSpan? expiration) { } public TValue? Get(TKey key) { } public TValue GetFromCacheOrFetch(TKey key, System.Func code, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false) { } - public TValue GetFromCacheOrFetch(TKey key, System.Func code, bool override = false, System.TimeSpan? expiration = default) { } + public TValue GetFromCacheOrFetch(TKey key, System.Func code, bool override = false, System.TimeSpan expiration = default) { } public System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false) { } - public System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, bool override = false, System.TimeSpan? expiration = default) { } + public System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, bool override = false, System.TimeSpan expiration = default) { } public void Remove(TKey key, System.Action? action = null) { } } public class ExpiredEventArgs : System.EventArgs @@ -584,14 +584,14 @@ namespace Catel.Caching event System.EventHandler>? Expired; event System.EventHandler>? Expiring; void Add(TKey key, TValue value, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false); - void Add(TKey key, TValue value, bool override = false, System.TimeSpan? expiration = default); + void Add(TKey key, TValue value, bool override = false, System.TimeSpan expiration = default); void Clear(); bool Contains(TKey key); TValue? Get(TKey key); TValue GetFromCacheOrFetch(TKey key, System.Func code, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false); - TValue GetFromCacheOrFetch(TKey key, System.Func code, bool override = false, System.TimeSpan? expiration = default); + TValue GetFromCacheOrFetch(TKey key, System.Func code, bool override = false, System.TimeSpan expiration = default); System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, Catel.Caching.Policies.ExpirationPolicy? expirationPolicy, bool override = false); - System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, bool override = false, System.TimeSpan? expiration = default); + System.Threading.Tasks.Task GetFromCacheOrFetchAsync(TKey key, System.Func> code, bool override = false, System.TimeSpan expiration = default); void Remove(TKey key, System.Action? action = null); } }