diff --git a/src/DynamicData.Tests/Cache/AutoRefreshFixture.cs b/src/DynamicData.Tests/Cache/AutoRefreshFixture.cs index 67d9e3b54..096b3bc0b 100644 --- a/src/DynamicData.Tests/Cache/AutoRefreshFixture.cs +++ b/src/DynamicData.Tests/Cache/AutoRefreshFixture.cs @@ -89,13 +89,13 @@ public void AutoRefreshFromObservable() [Fact] public void MakeSelectMagicWorkWithObservable() { - var initialItem = new IntHolder { Value = 1, Description = "Initial Description" }; + var initialItem = new IntHolder(1, "Initial Description"); var sourceList = new SourceList(); sourceList.Add(initialItem); var descriptionStream = sourceList.Connect().AutoRefresh(intHolder => intHolder!.Description).Transform(intHolder => intHolder!.Description, true).Do(x => { }) // <--- Add break point here to check the overload fixes it - .Bind(out ReadOnlyObservableCollection resultCollection); + .Bind(out ReadOnlyObservableCollection resultCollection); using (descriptionStream.Subscribe()) { @@ -109,11 +109,17 @@ public void MakeSelectMagicWorkWithObservable() public class IntHolder : AbstractNotifyPropertyChanged { - public string? _description_; + public string _description_; public int _value; - public string? Description + public IntHolder(int value, string description) + { + _value = value; + _description_ = description; + } + + public string Description { get => _description_; set => SetAndRaise(ref _description_, value); diff --git a/src/DynamicData.Tests/Cache/ObservableChangeSetFixture.cs b/src/DynamicData.Tests/Cache/ObservableChangeSetFixture.cs index da9b53705..5ce7d3821 100644 --- a/src/DynamicData.Tests/Cache/ObservableChangeSetFixture.cs +++ b/src/DynamicData.Tests/Cache/ObservableChangeSetFixture.cs @@ -217,6 +217,7 @@ public void LoadsAndDisposeUsingDisposableAsync() private void SubscribeAndAssert(IObservable> observableChangeset, bool expectsError = false, Action>? checkContentAction = null) where TKey : notnull + where TObject : notnull { Exception? error = null; bool complete = false; diff --git a/src/DynamicData.Tests/Cache/TransformFixture.cs b/src/DynamicData.Tests/Cache/TransformFixture.cs index 98700988c..7abe37476 100644 --- a/src/DynamicData.Tests/Cache/TransformFixture.cs +++ b/src/DynamicData.Tests/Cache/TransformFixture.cs @@ -135,18 +135,6 @@ public void SameKeyChanges() onlyItemInCache.Should().Be(lastTransformed, "Incorrect transform result"); } - [Fact] - public void TransformToNull() - { - using var source = new SourceCache(p => p.Name); - using var results = new ChangeSetAggregator(source.Connect().Transform((Func)(p => null))); - source.AddOrUpdate(new Person("Adult1", 50)); - - results.Messages.Count.Should().Be(1, "Should be 1 updates"); - results.Data.Count.Should().Be(1, "Should be 1 item in the cache"); - results.Data.Items.First().Should().Be(null, "Should be same person"); - } - [Fact] public void Update() { diff --git a/src/DynamicData.Tests/Cache/TransformFixtureParallel.cs b/src/DynamicData.Tests/Cache/TransformFixtureParallel.cs index 720a29a37..52b908b6c 100644 --- a/src/DynamicData.Tests/Cache/TransformFixtureParallel.cs +++ b/src/DynamicData.Tests/Cache/TransformFixtureParallel.cs @@ -109,19 +109,6 @@ public void SameKeyChanges() onlyItemInCache.Should().Be(lastTransformed, "Incorrect transform result"); } - [Fact] - public void TransformToNull() - { - using var source = new SourceCache(p => p.Name); - using var results = new ChangeSetAggregator(source.Connect() - .Transform((Func)(p => null), new ParallelisationOptions(ParallelType.Parallelise))); - source.AddOrUpdate(new Person("Adult1", 50)); - - results.Messages.Count.Should().Be(1, "Should be 1 updates"); - results.Data.Count.Should().Be(1, "Should be 1 item in the cache"); - results.Data.Items.First().Should().Be(null, "Should be same person"); - } - [Fact] public void Update() { diff --git a/src/DynamicData.Tests/List/CreationFixtures.cs b/src/DynamicData.Tests/List/CreationFixtures.cs index 756e32c2a..cef67e4a1 100644 --- a/src/DynamicData.Tests/List/CreationFixtures.cs +++ b/src/DynamicData.Tests/List/CreationFixtures.cs @@ -26,6 +26,7 @@ public void Create() } private void SubscribeAndAssert(IObservable> observableChangeset, bool expectsError = false) + where T : notnull { Exception? error = null; bool complete = false; diff --git a/src/DynamicData.Tests/List/SortFixture.cs b/src/DynamicData.Tests/List/SortFixture.cs index 4d55d51e4..54fbe70ab 100644 --- a/src/DynamicData.Tests/List/SortFixture.cs +++ b/src/DynamicData.Tests/List/SortFixture.cs @@ -51,7 +51,7 @@ public ListItem(int number) Number = number; } - public int CompareTo([AllowNull] ListItem other) => DefaultComparer.Compare(this, other); + public int CompareTo(ListItem? other) => DefaultComparer.Compare(this, other); } } diff --git a/src/DynamicData.Tests/List/TransformFixture.cs b/src/DynamicData.Tests/List/TransformFixture.cs index 77be742b6..248de0e83 100644 --- a/src/DynamicData.Tests/List/TransformFixture.cs +++ b/src/DynamicData.Tests/List/TransformFixture.cs @@ -117,19 +117,6 @@ public void SameKeyChanges() _results.Data.Count.Should().Be(10, "Should result in 10 records"); } - [Fact] - public void TransformToNull() - { - using var source = new SourceList(); - using var results = new ChangeSetAggregator(source.Connect() - .Transform((Func)(p => null))); - source.Add(new Person("Adult1", 50)); - - results.Messages.Count.Should().Be(1, "Should be 1 updates"); - results.Data.Count.Should().Be(1, "Should be 1 item in the cache"); - results.Data.Items.First().Should().Be(null, "Should be same person"); - } - [Fact] public void Update() { diff --git a/src/DynamicData/Aggregation/AggregateEnumerator.cs b/src/DynamicData/Aggregation/AggregateEnumerator.cs index f4c456b26..9fedd0742 100644 --- a/src/DynamicData/Aggregation/AggregateEnumerator.cs +++ b/src/DynamicData/Aggregation/AggregateEnumerator.cs @@ -9,6 +9,7 @@ namespace DynamicData.Aggregation; internal class AggregateEnumerator : IAggregateChangeSet + where T : notnull { private readonly IChangeSet _source; @@ -64,6 +65,7 @@ IEnumerator IEnumerable.GetEnumerator() [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Same name, different generics.")] internal class AggregateEnumerator : IAggregateChangeSet + where TObject : notnull where TKey : notnull { private readonly IChangeSet _source; diff --git a/src/DynamicData/Aggregation/AggregationEx.cs b/src/DynamicData/Aggregation/AggregationEx.cs index 004b303e9..eb9a94b32 100644 --- a/src/DynamicData/Aggregation/AggregationEx.cs +++ b/src/DynamicData/Aggregation/AggregationEx.cs @@ -22,6 +22,7 @@ public static class AggregationEx /// The source. /// The aggregated change set. public static IObservable> ForAggregation(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -39,6 +40,7 @@ public static IObservable> ForAggregationThe source. /// The aggregated change set. public static IObservable> ForAggregation(this IObservable> source) + where TObject : notnull { if (source is null) { @@ -87,6 +89,7 @@ public static IObservable InvalidateWhen(this IObservable sou /// The remove action. /// An observable with the accumulated value. internal static IObservable Accumulate(this IObservable> source, TResult seed, Func accessor, Func addAction, Func removeAction) + where TObject : notnull { return source.ForAggregation().Accumulate(seed, accessor, addAction, removeAction); } @@ -105,6 +108,7 @@ internal static IObservable Accumulate(this IObservab /// The remove action. /// An observable with the accumulated value. internal static IObservable Accumulate(this IObservable> source, TResult seed, Func accessor, Func addAction, Func removeAction) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Accumulate(seed, accessor, addAction, removeAction); diff --git a/src/DynamicData/Aggregation/AvgEx.cs b/src/DynamicData/Aggregation/AvgEx.cs index 3d7893238..0686c5b06 100644 --- a/src/DynamicData/Aggregation/AvgEx.cs +++ b/src/DynamicData/Aggregation/AvgEx.cs @@ -25,6 +25,7 @@ public static class AvgEx /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -42,6 +43,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -59,6 +61,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -76,6 +79,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -93,6 +97,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -110,6 +115,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -127,6 +133,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -144,6 +151,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -161,6 +169,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -178,6 +187,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); @@ -194,6 +204,7 @@ public static IObservable Avg(this IObservable public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } @@ -209,6 +220,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, int emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } @@ -224,6 +236,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } @@ -239,6 +252,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, long emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } @@ -254,6 +268,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } @@ -269,6 +284,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, double emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } @@ -284,6 +300,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } @@ -299,6 +316,7 @@ public static IObservable Avg(this IObservable> source /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, decimal emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } @@ -314,6 +332,7 @@ public static IObservable Avg(this IObservable> source /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } @@ -329,6 +348,7 @@ public static IObservable Avg(this IObservable> source, /// An observable of averages. /// public static IObservable Avg(this IObservable> source, Func valueSelector, float emptyValue = 0) + where T : notnull { return source.ForAggregation().Avg(valueSelector, emptyValue); } diff --git a/src/DynamicData/Aggregation/CountEx.cs b/src/DynamicData/Aggregation/CountEx.cs index 14c82d8da..c5f7d2a81 100644 --- a/src/DynamicData/Aggregation/CountEx.cs +++ b/src/DynamicData/Aggregation/CountEx.cs @@ -20,6 +20,7 @@ public static class CountEx /// The source. /// An observable which emits the count. public static IObservable Count(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Count(); @@ -32,6 +33,7 @@ public static IObservable Count(this IObservableThe source. /// An observable which emits the count. public static IObservable Count(this IObservable> source) + where TObject : notnull { return source.ForAggregation().Count(); } @@ -68,6 +70,7 @@ public static IObservable Count(this IObservableThe source. /// An observable which emits the count. public static IObservable IsEmpty(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Count().StartWith(0).Select(count => count == 0); @@ -81,6 +84,7 @@ public static IObservable IsEmpty(this IObservableThe source. /// An observable which emits the count. public static IObservable IsEmpty(this IObservable> source) + where TObject : notnull { return source.ForAggregation().Count().StartWith(0).Select(count => count == 0); } @@ -94,6 +98,7 @@ public static IObservable IsEmpty(this IObservableThe source. /// An observable which emits the count. public static IObservable IsNotEmpty(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Count().StartWith(0).Select(count => count > 0); @@ -107,6 +112,7 @@ public static IObservable IsNotEmpty(this IObservableThe source. /// An observable which emits the count. public static IObservable IsNotEmpty(this IObservable> source) + where TObject : notnull { return source.ForAggregation().Count().StartWith(0).Select(count => count > 0); } diff --git a/src/DynamicData/Aggregation/MaxEx.cs b/src/DynamicData/Aggregation/MaxEx.cs index cdbb69808..ef888d9a1 100644 --- a/src/DynamicData/Aggregation/MaxEx.cs +++ b/src/DynamicData/Aggregation/MaxEx.cs @@ -33,6 +33,7 @@ private enum MaxOrMin /// A distinct observable of the maximum item. /// public static IObservable Maximum(this IObservable> source, Func valueSelector, TResult emptyValue = default) + where TObject : notnull where TResult : struct, IComparable { return source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Max, emptyValue); @@ -51,6 +52,7 @@ public static IObservable Maximum(this IObservable public static IObservable Maximum(this IObservable> source, Func valueSelector, TResult emptyValue = default) + where TObject : notnull where TKey : notnull where TResult : struct, IComparable { @@ -67,6 +69,7 @@ public static IObservable Maximum(this IObserva /// The value to use when the underlying collection is empty. /// A distinct observable of the minimums item. public static IObservable Minimum(this IObservable> source, Func valueSelector, TResult emptyValue = default) + where TObject : notnull where TResult : struct, IComparable { return source.ToChangesAndCollection().Calculate(valueSelector, MaxOrMin.Min, emptyValue); @@ -85,6 +88,7 @@ public static IObservable Minimum(this IObservable public static IObservable Minimum(this IObservable> source, Func valueSelector, TResult emptyValue = default) + where TObject : notnull where TKey : notnull where TResult : struct, IComparable { @@ -162,6 +166,7 @@ private static IObservable Calculate(this IObservable } private static IObservable> ToChangesAndCollection(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -179,6 +184,7 @@ private static IObservable> ToChangesAndCollection } private static IObservable> ToChangesAndCollection(this IObservable> source) + where TObject : notnull { if (source is null) { diff --git a/src/DynamicData/Aggregation/StdDevEx.cs b/src/DynamicData/Aggregation/StdDevEx.cs index 3fd79c2b7..b857645a6 100644 --- a/src/DynamicData/Aggregation/StdDevEx.cs +++ b/src/DynamicData/Aggregation/StdDevEx.cs @@ -22,6 +22,7 @@ public static class StdDevEx /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, int fallbackValue) + where T : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); } @@ -35,6 +36,7 @@ public static IObservable StdDev(this IObservable> sour /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, long fallbackValue) + where T : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); } @@ -48,6 +50,7 @@ public static IObservable StdDev(this IObservable> sour /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, double fallbackValue) + where T : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); } @@ -61,6 +64,7 @@ public static IObservable StdDev(this IObservable> sour /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, decimal fallbackValue) + where T : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); } @@ -74,6 +78,7 @@ public static IObservable StdDev(this IObservable> sour /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, float fallbackValue = 0) + where T : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); } @@ -88,6 +93,7 @@ public static IObservable StdDev(this IObservable> sour /// The fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, int fallbackValue) + where TObject : notnull where TKey : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); @@ -103,6 +109,7 @@ public static IObservable StdDev(this IObservableThe fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, long fallbackValue) + where TObject : notnull where TKey : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); @@ -118,6 +125,7 @@ public static IObservable StdDev(this IObservableThe fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, double fallbackValue) + where TObject : notnull where TKey : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); @@ -133,6 +141,7 @@ public static IObservable StdDev(this IObservableThe fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, decimal fallbackValue) + where TObject : notnull where TKey : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); @@ -148,6 +157,7 @@ public static IObservable StdDev(this IObservableThe fallback value. /// An observable which emits the standard deviation value. public static IObservable StdDev(this IObservable> source, Func valueSelector, float fallbackValue = 0) + where TObject : notnull where TKey : notnull { return source.ForAggregation().StdDev(valueSelector, fallbackValue); diff --git a/src/DynamicData/Aggregation/SumEx.cs b/src/DynamicData/Aggregation/SumEx.cs index e2a702590..1eaeb2360 100644 --- a/src/DynamicData/Aggregation/SumEx.cs +++ b/src/DynamicData/Aggregation/SumEx.cs @@ -22,6 +22,7 @@ public static class SumEx /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -36,6 +37,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -50,6 +52,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -64,6 +67,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -78,6 +82,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -92,6 +97,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -106,6 +112,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -120,6 +127,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -134,6 +142,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -148,6 +157,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull { return source.ForAggregation().Sum(valueSelector); @@ -161,6 +171,7 @@ public static IObservable Sum(this IObservableThe value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } @@ -173,6 +184,7 @@ public static IObservable Sum(this IObservable> source, Fu /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } @@ -185,6 +197,7 @@ public static IObservable Sum(this IObservable> source, Fu /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } @@ -197,6 +210,7 @@ public static IObservable Sum(this IObservable> source, F /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } @@ -209,6 +223,7 @@ public static IObservable Sum(this IObservable> source, F /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } @@ -221,6 +236,7 @@ public static IObservable Sum(this IObservable> source, /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } @@ -233,6 +249,7 @@ public static IObservable Sum(this IObservable> source, /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } @@ -245,6 +262,7 @@ public static IObservable Sum(this IObservable> source /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } @@ -257,6 +275,7 @@ public static IObservable Sum(this IObservable> source /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } @@ -269,6 +288,7 @@ public static IObservable Sum(this IObservable> source, /// The value selector. /// An observable which emits the summed value. public static IObservable Sum(this IObservable> source, Func valueSelector) + where T : notnull { return source.ForAggregation().Sum(valueSelector); } diff --git a/src/DynamicData/Alias/ObservableCacheAlias.cs b/src/DynamicData/Alias/ObservableCacheAlias.cs index aff02493a..8b44dedee 100644 --- a/src/DynamicData/Alias/ObservableCacheAlias.cs +++ b/src/DynamicData/Alias/ObservableCacheAlias.cs @@ -31,6 +31,8 @@ public static class ObservableCacheAlias /// or /// transformFactory. public static IObservable> Select(this IObservable> source, Func transformFactory, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -67,6 +69,8 @@ public static IObservable> Select public static IObservable> Select(this IObservable> source, Func transformFactory, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { return source.Transform(transformFactory, forceTransform); @@ -88,6 +92,8 @@ public static IObservable> Select public static IObservable> Select(this IObservable> source, Func transformFactory, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { return source.Transform(transformFactory, forceTransform); @@ -109,6 +115,8 @@ public static IObservable> Select public static IObservable> Select(this IObservable> source, Func transformFactory, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -136,7 +144,9 @@ public static IObservable> SelectThe key selector which must be unique across all. /// An observable which emits the change set. public static IObservable> SelectMany(this IObservable> source, Func> manySelector, Func keySelector) + where TDestination : notnull where TDestinationKey : notnull + where TSource : notnull where TSourceKey : notnull { return source.TransformMany(manySelector, keySelector); @@ -162,6 +172,8 @@ public static IObservable> SelectMany< /// or /// transformFactory. public static IObservable> SelectSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -207,6 +219,8 @@ public static IObservable> SelectSafe public static IObservable> SelectSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -247,6 +261,8 @@ public static IObservable> SelectSafe public static IObservable> SelectSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -287,6 +303,8 @@ public static IObservable> SelectSafe public static IObservable> SelectSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { return source.TransformSafe(transformFactory, errorHandler, forceTransform); @@ -301,8 +319,8 @@ public static IObservable> SelectSafeThe pivot on. /// An observable which emits the change set. public static IObservable, TKey>> SelectTree(this IObservable> source, Func pivotOn) - where TKey : notnull where TObject : class + where TKey : notnull { if (source is null) { @@ -326,6 +344,7 @@ public static IObservable, TKey>> SelectTreeThe filter. /// An observable which emits the change set. public static IObservable> Where(this IObservable> source, Func filter) + where TObject : notnull where TKey : notnull { if (source is null) @@ -345,6 +364,7 @@ public static IObservable> Where(this I /// Observable to change the underlying predicate. /// An observable which emits the change set. public static IObservable> Where(this IObservable> source, IObservable> predicateChanged) + where TObject : notnull where TKey : notnull { if (source is null) @@ -369,6 +389,7 @@ public static IObservable> Where(this I /// Observable to re-evaluate whether the filter still matches items. Use when filtering on mutable values. /// An observable which emits the change set. public static IObservable> Where(this IObservable> source, IObservable reapplyFilter) + where TObject : notnull where TKey : notnull { if (source is null) @@ -394,6 +415,7 @@ public static IObservable> Where(this I /// Observable to re-evaluate whether the filter still matches items. Use when filtering on mutable values. /// An observable which emits the change set. public static IObservable> Where(this IObservable> source, IObservable> predicateChanged, IObservable reapplyFilter) + where TObject : notnull where TKey : notnull { if (source is null) diff --git a/src/DynamicData/Alias/ObservableListAlias.cs b/src/DynamicData/Alias/ObservableListAlias.cs index f63d01dc9..def8c0298 100644 --- a/src/DynamicData/Alias/ObservableListAlias.cs +++ b/src/DynamicData/Alias/ObservableListAlias.cs @@ -26,6 +26,8 @@ public static class ObservableListAlias /// valueSelector. /// public static IObservable> Select(this IObservable> source, Func transformFactory) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -50,6 +52,8 @@ public static IObservable> SelectThe selector for the enumerable. /// An observable which emits the change set. public static IObservable> SelectMany(this IObservable> source, Func> manySelector) + where TDestination : notnull + where TSource : notnull { if (source is null) { @@ -73,6 +77,7 @@ public static IObservable> SelectManyAn observable which emits the change set. /// source. public static IObservable> Where(this IObservable> source, Func predicate) + where T : notnull { if (source is null) { @@ -98,6 +103,7 @@ public static IObservable> Where(this IObservable /// or /// filterController. public static IObservable> Where(this IObservable> source, IObservable> predicate) + where T : notnull { if (source is null) { diff --git a/src/DynamicData/Binding/BindingListAdaptor.cs b/src/DynamicData/Binding/BindingListAdaptor.cs index 3f2d1be39..950db581b 100644 --- a/src/DynamicData/Binding/BindingListAdaptor.cs +++ b/src/DynamicData/Binding/BindingListAdaptor.cs @@ -15,6 +15,7 @@ namespace DynamicData.Binding /// /// The type of items. public class BindingListAdaptor : IChangeSetAdaptor + where T : notnull { private readonly BindingList _list; @@ -63,6 +64,7 @@ public void Adapt(IChangeSet changes) /// The type of the key. [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Same class name, different generics")] public class BindingListAdaptor : IChangeSetAdaptor + where TObject : notnull where TKey : notnull { private readonly Cache _cache = new(); diff --git a/src/DynamicData/Binding/BindingListEx.cs b/src/DynamicData/Binding/BindingListEx.cs index 302e2aed1..02cbb4aa4 100644 --- a/src/DynamicData/Binding/BindingListEx.cs +++ b/src/DynamicData/Binding/BindingListEx.cs @@ -15,6 +15,7 @@ namespace DynamicData.Binding; public static class BindingListEx { internal static void Clone(this BindingList source, IEnumerable> changes) + where T : notnull { // ** Copied from ListEx for binding list specific changes if (source is null) throw new ArgumentNullException(nameof(source)); @@ -27,6 +28,7 @@ internal static void Clone(this BindingList source, IEnumerable> } private static void Clone(this BindingList source, Change item, IEqualityComparer equalityComparer) + where T : notnull { switch (item.Reason) { @@ -172,6 +174,7 @@ public static IObservable> ObserveCollectionC /// An observable which emits change set values. /// source. public static IObservable> ToObservableChangeSet(this BindingList source) + where T : notnull { if (source is null) { @@ -194,6 +197,7 @@ public static IObservable> ToObservableChangeSet(this BindingLi /// or /// keySelector. public static IObservable> ToObservableChangeSet(this BindingList source, Func keySelector) + where TObject : notnull where TKey : notnull { if (source is null) @@ -220,6 +224,7 @@ public static IObservable> ToObservableChangeSetsource. public static IObservable> ToObservableChangeSet(this TCollection source) where TCollection : IBindingList, IEnumerable + where T : notnull { if (source is null) { diff --git a/src/DynamicData/Binding/IObservableCollectionAdaptor.cs b/src/DynamicData/Binding/IObservableCollectionAdaptor.cs index 1db2f500e..42bbb92df 100644 --- a/src/DynamicData/Binding/IObservableCollectionAdaptor.cs +++ b/src/DynamicData/Binding/IObservableCollectionAdaptor.cs @@ -11,6 +11,7 @@ namespace DynamicData.Binding; /// The type of the object. /// The type of the key. public interface IObservableCollectionAdaptor + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Binding/IObservableListEx.cs b/src/DynamicData/Binding/IObservableListEx.cs index b0d8024f4..f7c5f4021 100644 --- a/src/DynamicData/Binding/IObservableListEx.cs +++ b/src/DynamicData/Binding/IObservableListEx.cs @@ -26,6 +26,7 @@ public static class IObservableListEx /// The change set for continued chaining. /// source. public static IObservable> BindToObservableList(this IObservable> source, out IObservableList observableList) + where TObject : notnull { if (source is null) { @@ -56,6 +57,7 @@ public static IObservable> BindToObservableList(thi /// The change set for continued chaining. /// source. public static IObservable> BindToObservableList(this IObservable> source, out IObservableList observableList) + where TObject : notnull where TKey : notnull { if (source is null) @@ -87,6 +89,7 @@ public static IObservable> BindToObservableListThe change set for continued chaining. /// source. public static IObservable> BindToObservableList(this IObservable> source, out IObservableList observableList) + where TObject : notnull where TKey : notnull { if (source is null) @@ -143,6 +146,7 @@ public static IObservable> BindToObservableList< /// The list needed to support refresh. /// The down casted . private static IChangeSet RemoveKey(this IChangeSet changeSetWithKey, IExtendedList list) + where TObject : notnull where TKey : notnull { var enumerator = new Cache.Internal.RemoveKeyEnumerator(changeSetWithKey, list); diff --git a/src/DynamicData/Binding/ISortedObservableCollectionAdaptor.cs b/src/DynamicData/Binding/ISortedObservableCollectionAdaptor.cs index 8c0fdb391..1db857e85 100644 --- a/src/DynamicData/Binding/ISortedObservableCollectionAdaptor.cs +++ b/src/DynamicData/Binding/ISortedObservableCollectionAdaptor.cs @@ -11,6 +11,7 @@ namespace DynamicData.Binding; /// The type of the object. /// The type of the key. public interface ISortedObservableCollectionAdaptor + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Binding/ObservableCollectionAdaptor.cs b/src/DynamicData/Binding/ObservableCollectionAdaptor.cs index c837d7f98..035fb4fc9 100644 --- a/src/DynamicData/Binding/ObservableCollectionAdaptor.cs +++ b/src/DynamicData/Binding/ObservableCollectionAdaptor.cs @@ -15,6 +15,7 @@ namespace DynamicData.Binding; /// /// The type of the item. public class ObservableCollectionAdaptor : IChangeSetAdaptor + where T : notnull { private readonly IObservableCollection _collection; @@ -68,6 +69,7 @@ public void Adapt(IChangeSet changes) /// The type of the key. [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Same class name, only generic difference.")] public class ObservableCollectionAdaptor : IObservableCollectionAdaptor + where TObject : notnull where TKey : notnull { private readonly Cache _cache = new(); diff --git a/src/DynamicData/Binding/ObservableCollectionEx.cs b/src/DynamicData/Binding/ObservableCollectionEx.cs index d6624f371..66f39e253 100644 --- a/src/DynamicData/Binding/ObservableCollectionEx.cs +++ b/src/DynamicData/Binding/ObservableCollectionEx.cs @@ -36,6 +36,7 @@ public static IObservable> Observ /// An observable that emits the change set. /// source. public static IObservable> ToObservableChangeSet(this ObservableCollection source) + where T : notnull { if (source is null) { @@ -58,6 +59,7 @@ public static IObservable> ToObservableChangeSet(this Observabl /// or /// keySelector. public static IObservable> ToObservableChangeSet(this ObservableCollection source, Func keySelector) + where TObject : notnull where TKey : notnull { if (source is null) @@ -82,6 +84,7 @@ public static IObservable> ToObservableChangeSetAn observable that emits the change set. /// source. public static IObservable> ToObservableChangeSet(this ReadOnlyObservableCollection source) + where T : notnull { if (source is null) { @@ -104,6 +107,7 @@ public static IObservable> ToObservableChangeSet(this ReadOnlyO /// or /// keySelector. public static IObservable> ToObservableChangeSet(this ReadOnlyObservableCollection source, Func keySelector) + where TObject : notnull where TKey : notnull { if (source is null) @@ -130,6 +134,7 @@ public static IObservable> ToObservableChangeSetsource. public static IObservable> ToObservableChangeSet(this TCollection source) where TCollection : INotifyCollectionChanged, IEnumerable + where T : notnull { if (source is null) { diff --git a/src/DynamicData/Binding/SortedBindingListAdaptor.cs b/src/DynamicData/Binding/SortedBindingListAdaptor.cs index 94fce6304..feb033ebb 100644 --- a/src/DynamicData/Binding/SortedBindingListAdaptor.cs +++ b/src/DynamicData/Binding/SortedBindingListAdaptor.cs @@ -17,6 +17,7 @@ namespace DynamicData.Binding /// The type of object. /// The type of key. public class SortedBindingListAdaptor : ISortedChangeSetAdaptor + where TObject : notnull where TKey : notnull { private readonly BindingList _list; diff --git a/src/DynamicData/Binding/SortedObservableCollectionAdaptor.cs b/src/DynamicData/Binding/SortedObservableCollectionAdaptor.cs index 6054c3822..554958331 100644 --- a/src/DynamicData/Binding/SortedObservableCollectionAdaptor.cs +++ b/src/DynamicData/Binding/SortedObservableCollectionAdaptor.cs @@ -14,6 +14,7 @@ namespace DynamicData.Binding; /// The type of the object. /// The type of the key. public class SortedObservableCollectionAdaptor : ISortedObservableCollectionAdaptor + where TObject : notnull where TKey : notnull { private readonly int _refreshThreshold; diff --git a/src/DynamicData/Cache/CacheChangeSetEx.cs b/src/DynamicData/Cache/CacheChangeSetEx.cs index eb9e15798..004b5e1df 100644 --- a/src/DynamicData/Cache/CacheChangeSetEx.cs +++ b/src/DynamicData/Cache/CacheChangeSetEx.cs @@ -17,6 +17,6 @@ internal static class CacheChangeSetEx /// /// The source change set. public static ChangeSet ToConcreteType(this IChangeSet changeSet) - where TKey : notnull - => (ChangeSet)changeSet; + where TObject : notnull + where TKey : notnull => (ChangeSet)changeSet; } diff --git a/src/DynamicData/Cache/Change.cs b/src/DynamicData/Cache/Change.cs index 4065feb9e..80d00a472 100644 --- a/src/DynamicData/Cache/Change.cs +++ b/src/DynamicData/Cache/Change.cs @@ -16,6 +16,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public readonly struct Change : IEquatable> + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/ChangeAwareCache.cs b/src/DynamicData/Cache/ChangeAwareCache.cs index b7294debc..2f220e48f 100644 --- a/src/DynamicData/Cache/ChangeAwareCache.cs +++ b/src/DynamicData/Cache/ChangeAwareCache.cs @@ -20,6 +20,7 @@ namespace DynamicData; /// The value of the cache. /// The key of the cache. public sealed class ChangeAwareCache : ICache + where TObject : notnull where TKey : notnull { private readonly Dictionary _data; diff --git a/src/DynamicData/Cache/ChangeSet.cs b/src/DynamicData/Cache/ChangeSet.cs index a15cb71e6..06ec3f6aa 100644 --- a/src/DynamicData/Cache/ChangeSet.cs +++ b/src/DynamicData/Cache/ChangeSet.cs @@ -14,6 +14,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public class ChangeSet : List>, IChangeSet + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/GroupChangeSet.cs b/src/DynamicData/Cache/GroupChangeSet.cs index 1d0706a46..0e8dad879 100644 --- a/src/DynamicData/Cache/GroupChangeSet.cs +++ b/src/DynamicData/Cache/GroupChangeSet.cs @@ -8,6 +8,7 @@ namespace DynamicData; internal sealed class GroupChangeSet : ChangeSet, TGroupKey>, IGroupChangeSet + where TObject : notnull where TKey : notnull where TGroupKey : notnull { diff --git a/src/DynamicData/Cache/ICache.cs b/src/DynamicData/Cache/ICache.cs index 9027513a5..c286d2b1c 100644 --- a/src/DynamicData/Cache/ICache.cs +++ b/src/DynamicData/Cache/ICache.cs @@ -16,6 +16,7 @@ namespace DynamicData; /// The type of the key. /// public interface ICache : IQuery + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/ICacheUpdater.cs b/src/DynamicData/Cache/ICacheUpdater.cs index 5351932e5..ad59c3a55 100644 --- a/src/DynamicData/Cache/ICacheUpdater.cs +++ b/src/DynamicData/Cache/ICacheUpdater.cs @@ -21,6 +21,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface ICacheUpdater : IQuery + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IChangeSet.cs b/src/DynamicData/Cache/IChangeSet.cs index 90bfbc493..2c590c1b0 100644 --- a/src/DynamicData/Cache/IChangeSet.cs +++ b/src/DynamicData/Cache/IChangeSet.cs @@ -15,6 +15,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface IChangeSet : IChangeSet, IEnumerable> + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IChangeSetAdaptor.cs b/src/DynamicData/Cache/IChangeSetAdaptor.cs index 30d3ea87b..5889d9122 100644 --- a/src/DynamicData/Cache/IChangeSetAdaptor.cs +++ b/src/DynamicData/Cache/IChangeSetAdaptor.cs @@ -11,6 +11,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface IChangeSetAdaptor + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IConnectableCache.cs b/src/DynamicData/Cache/IConnectableCache.cs index 0e04284e3..d2f5d0248 100644 --- a/src/DynamicData/Cache/IConnectableCache.cs +++ b/src/DynamicData/Cache/IConnectableCache.cs @@ -13,6 +13,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface IConnectableCache + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IGroup.cs b/src/DynamicData/Cache/IGroup.cs index 1fa04d830..d01ef2afa 100644 --- a/src/DynamicData/Cache/IGroup.cs +++ b/src/DynamicData/Cache/IGroup.cs @@ -12,6 +12,7 @@ namespace DynamicData; /// The type of the key. /// The type of value used to group the original stream. public interface IGroup : IKey + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IGroupChangeSet.cs b/src/DynamicData/Cache/IGroupChangeSet.cs index 49807eba4..910a56460 100644 --- a/src/DynamicData/Cache/IGroupChangeSet.cs +++ b/src/DynamicData/Cache/IGroupChangeSet.cs @@ -12,6 +12,7 @@ namespace DynamicData; /// The type of the key.s /// The value on which the stream has been grouped. public interface IGroupChangeSet : IChangeSet, TGroupKey> + where TObject : notnull where TKey : notnull where TGroupKey : notnull { diff --git a/src/DynamicData/Cache/IGrouping.cs b/src/DynamicData/Cache/IGrouping.cs index 9d3c0c430..e80803561 100644 --- a/src/DynamicData/Cache/IGrouping.cs +++ b/src/DynamicData/Cache/IGrouping.cs @@ -16,6 +16,7 @@ namespace DynamicData; /// The type of the key. /// The type of the group key. public interface IGrouping + where TObject : notnull { /// /// Gets the count. diff --git a/src/DynamicData/Cache/IImmutableGroupChangeSet.cs b/src/DynamicData/Cache/IImmutableGroupChangeSet.cs index fbaaec3fa..38d8b5348 100644 --- a/src/DynamicData/Cache/IImmutableGroupChangeSet.cs +++ b/src/DynamicData/Cache/IImmutableGroupChangeSet.cs @@ -11,6 +11,7 @@ namespace DynamicData; /// The type of the key.s /// The value on which the stream has been grouped. public interface IImmutableGroupChangeSet : IChangeSet, TGroupKey> + where TObject : notnull where TKey : notnull where TGroupKey : notnull { diff --git a/src/DynamicData/Cache/IIntermediateCache.cs b/src/DynamicData/Cache/IIntermediateCache.cs index 66f4c8391..38ba51f97 100644 --- a/src/DynamicData/Cache/IIntermediateCache.cs +++ b/src/DynamicData/Cache/IIntermediateCache.cs @@ -15,6 +15,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface IIntermediateCache : IObservableCache + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IObservableCache.cs b/src/DynamicData/Cache/IObservableCache.cs index 7bc4a5c0d..7cf11d3e5 100644 --- a/src/DynamicData/Cache/IObservableCache.cs +++ b/src/DynamicData/Cache/IObservableCache.cs @@ -16,6 +16,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface IObservableCache : IConnectableCache, IDisposable + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IPagedChangeSet.cs b/src/DynamicData/Cache/IPagedChangeSet.cs index 125f603ae..7263b8b55 100644 --- a/src/DynamicData/Cache/IPagedChangeSet.cs +++ b/src/DynamicData/Cache/IPagedChangeSet.cs @@ -13,6 +13,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface IPagedChangeSet : ISortedChangeSet + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IQuery.cs b/src/DynamicData/Cache/IQuery.cs index 907d894a5..4d50d9d7b 100644 --- a/src/DynamicData/Cache/IQuery.cs +++ b/src/DynamicData/Cache/IQuery.cs @@ -15,6 +15,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface IQuery + where TObject : notnull { /// /// Gets the count. diff --git a/src/DynamicData/Cache/ISortedChangeSet.cs b/src/DynamicData/Cache/ISortedChangeSet.cs index c6c9100d3..32d4981b2 100644 --- a/src/DynamicData/Cache/ISortedChangeSet.cs +++ b/src/DynamicData/Cache/ISortedChangeSet.cs @@ -10,6 +10,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface ISortedChangeSet : IChangeSet + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/ISortedChangeSetAdaptor.cs b/src/DynamicData/Cache/ISortedChangeSetAdaptor.cs index 8928bc821..66b6e4701 100644 --- a/src/DynamicData/Cache/ISortedChangeSetAdaptor.cs +++ b/src/DynamicData/Cache/ISortedChangeSetAdaptor.cs @@ -10,6 +10,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface ISortedChangeSetAdaptor + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/ISourceCache.cs b/src/DynamicData/Cache/ISourceCache.cs index ed0901f3e..9ab2a400f 100644 --- a/src/DynamicData/Cache/ISourceCache.cs +++ b/src/DynamicData/Cache/ISourceCache.cs @@ -14,6 +14,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface ISourceCache : IObservableCache + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/ISourceUpdater.cs b/src/DynamicData/Cache/ISourceUpdater.cs index aa7aa7d83..1372fc234 100644 --- a/src/DynamicData/Cache/ISourceUpdater.cs +++ b/src/DynamicData/Cache/ISourceUpdater.cs @@ -21,6 +21,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface ISourceUpdater : ICacheUpdater + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IVirtualChangeSet.cs b/src/DynamicData/Cache/IVirtualChangeSet.cs index dca5932fb..f9004c4c1 100644 --- a/src/DynamicData/Cache/IVirtualChangeSet.cs +++ b/src/DynamicData/Cache/IVirtualChangeSet.cs @@ -10,6 +10,7 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public interface IVirtualChangeSet : ISortedChangeSet + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/IntermediateCache.cs b/src/DynamicData/Cache/IntermediateCache.cs index 5ec93b67e..e33fc7c01 100644 --- a/src/DynamicData/Cache/IntermediateCache.cs +++ b/src/DynamicData/Cache/IntermediateCache.cs @@ -18,6 +18,7 @@ namespace DynamicData; /// The type of the key. [DebuggerDisplay("IntermediateCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] public sealed class IntermediateCache : IIntermediateCache + where TObject : notnull where TKey : notnull { private readonly ObservableCache _innerCache; diff --git a/src/DynamicData/Cache/Internal/AbstractFilter.cs b/src/DynamicData/Cache/Internal/AbstractFilter.cs index b0aa9c65c..6519ff19a 100644 --- a/src/DynamicData/Cache/Internal/AbstractFilter.cs +++ b/src/DynamicData/Cache/Internal/AbstractFilter.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal abstract class AbstractFilter : IFilter + where TObject : notnull where TKey : notnull { private readonly ChangeAwareCache _cache; diff --git a/src/DynamicData/Cache/Internal/AnonymousObservableCache.cs b/src/DynamicData/Cache/Internal/AnonymousObservableCache.cs index 25017fa23..5bb8c8237 100644 --- a/src/DynamicData/Cache/Internal/AnonymousObservableCache.cs +++ b/src/DynamicData/Cache/Internal/AnonymousObservableCache.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; [DebuggerDisplay("AnonymousObservableCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] internal sealed class AnonymousObservableCache : IObservableCache + where TObject : notnull where TKey : notnull { private readonly IObservableCache _cache; diff --git a/src/DynamicData/Cache/Internal/AnonymousQuery.cs b/src/DynamicData/Cache/Internal/AnonymousQuery.cs index 5e77ae9da..557eb0a27 100644 --- a/src/DynamicData/Cache/Internal/AnonymousQuery.cs +++ b/src/DynamicData/Cache/Internal/AnonymousQuery.cs @@ -9,6 +9,7 @@ namespace DynamicData.Cache.Internal; internal sealed class AnonymousQuery : IQuery + where TObject : notnull where TKey : notnull { private readonly Cache _cache; diff --git a/src/DynamicData/Cache/Internal/AutoRefresh.cs b/src/DynamicData/Cache/Internal/AutoRefresh.cs index 97ea7e97c..c7ffa67d3 100644 --- a/src/DynamicData/Cache/Internal/AutoRefresh.cs +++ b/src/DynamicData/Cache/Internal/AutoRefresh.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal class AutoRefresh + where TObject : notnull where TKey : notnull { private readonly TimeSpan? _buffer; diff --git a/src/DynamicData/Cache/Internal/BatchIf.cs b/src/DynamicData/Cache/Internal/BatchIf.cs index a139c9479..c4ed4d379 100644 --- a/src/DynamicData/Cache/Internal/BatchIf.cs +++ b/src/DynamicData/Cache/Internal/BatchIf.cs @@ -13,6 +13,7 @@ namespace DynamicData.Cache.Internal; internal sealed class BatchIf + where TObject : notnull where TKey : notnull { private readonly bool _initialPauseState; diff --git a/src/DynamicData/Cache/Internal/Cache.cs b/src/DynamicData/Cache/Internal/Cache.cs index 5e6af39d7..c85e71850 100644 --- a/src/DynamicData/Cache/Internal/Cache.cs +++ b/src/DynamicData/Cache/Internal/Cache.cs @@ -12,6 +12,7 @@ namespace DynamicData.Cache.Internal; [DebuggerDisplay("Cache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] internal class Cache : ICache + where TObject : notnull where TKey : notnull { public static readonly Cache Empty = new(); diff --git a/src/DynamicData/Cache/Internal/CacheEx.cs b/src/DynamicData/Cache/Internal/CacheEx.cs index 16e252606..08c856ca5 100644 --- a/src/DynamicData/Cache/Internal/CacheEx.cs +++ b/src/DynamicData/Cache/Internal/CacheEx.cs @@ -12,6 +12,7 @@ internal static class CacheEx { public static void Clone(this IDictionary source, IChangeSet changes) where TKey : notnull + where TObject : notnull { foreach (var item in changes.ToConcreteType()) { @@ -30,6 +31,7 @@ public static void Clone(this IDictionary source, } public static IChangeSet GetInitialUpdates(this ChangeAwareCache source, Func? filter = null) + where TObject : notnull where TKey : notnull { var filtered = filter is null ? source.KeyValues : source.KeyValues.Where(kv => filter(kv.Value)); diff --git a/src/DynamicData/Cache/Internal/CacheUpdater.cs b/src/DynamicData/Cache/Internal/CacheUpdater.cs index 8efb54ed6..8b1c20f80 100644 --- a/src/DynamicData/Cache/Internal/CacheUpdater.cs +++ b/src/DynamicData/Cache/Internal/CacheUpdater.cs @@ -11,6 +11,7 @@ namespace DynamicData.Cache.Internal; internal class CacheUpdater : ISourceUpdater + where TObject : notnull where TKey : notnull { private readonly ICache _cache; diff --git a/src/DynamicData/Cache/Internal/Cast.cs b/src/DynamicData/Cache/Internal/Cast.cs index 95736e0c8..1021d5427 100644 --- a/src/DynamicData/Cache/Internal/Cast.cs +++ b/src/DynamicData/Cache/Internal/Cast.cs @@ -11,7 +11,9 @@ namespace DynamicData.Cache.Internal; internal class Cast + where TSource : notnull where TKey : notnull + where TDestination : notnull { private readonly Func _converter; diff --git a/src/DynamicData/Cache/Internal/Combiner.cs b/src/DynamicData/Cache/Internal/Combiner.cs index 678745fb7..dbe5a8f98 100644 --- a/src/DynamicData/Cache/Internal/Combiner.cs +++ b/src/DynamicData/Cache/Internal/Combiner.cs @@ -15,6 +15,7 @@ namespace DynamicData.Cache.Internal; /// Combines multiple caches using logical operators. /// internal sealed class Combiner + where TObject : notnull where TKey : notnull { private readonly ChangeAwareCache _combinedCache = new(); diff --git a/src/DynamicData/Cache/Internal/DeferUntilLoaded.cs b/src/DynamicData/Cache/Internal/DeferUntilLoaded.cs index 7b3b97649..968f6adb1 100644 --- a/src/DynamicData/Cache/Internal/DeferUntilLoaded.cs +++ b/src/DynamicData/Cache/Internal/DeferUntilLoaded.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal class DeferUntilLoaded + where TObject : notnull where TKey : notnull { private readonly IObservable> _result; diff --git a/src/DynamicData/Cache/Internal/DisposeMany.cs b/src/DynamicData/Cache/Internal/DisposeMany.cs index c0ee3309a..bc67b3161 100644 --- a/src/DynamicData/Cache/Internal/DisposeMany.cs +++ b/src/DynamicData/Cache/Internal/DisposeMany.cs @@ -11,6 +11,7 @@ namespace DynamicData.Cache.Internal; internal sealed class DisposeMany + where TObject : notnull where TKey : notnull { private readonly Action _removeAction; diff --git a/src/DynamicData/Cache/Internal/DistinctCalculator.cs b/src/DynamicData/Cache/Internal/DistinctCalculator.cs index f6276b8b8..da743f449 100644 --- a/src/DynamicData/Cache/Internal/DistinctCalculator.cs +++ b/src/DynamicData/Cache/Internal/DistinctCalculator.cs @@ -11,8 +11,9 @@ namespace DynamicData.Cache.Internal; internal sealed class DistinctCalculator - where TValue : notnull + where TObject : notnull where TKey : notnull + where TValue : notnull { private readonly IDictionary _itemCache = new Dictionary(); diff --git a/src/DynamicData/Cache/Internal/DynamicCombiner.cs b/src/DynamicData/Cache/Internal/DynamicCombiner.cs index a018a67b0..e71ced02d 100644 --- a/src/DynamicData/Cache/Internal/DynamicCombiner.cs +++ b/src/DynamicData/Cache/Internal/DynamicCombiner.cs @@ -13,6 +13,7 @@ namespace DynamicData.Cache.Internal; internal sealed class DynamicCombiner + where TObject : notnull where TKey : notnull { private readonly IObservableList>> _source; diff --git a/src/DynamicData/Cache/Internal/DynamicFilter.cs b/src/DynamicData/Cache/Internal/DynamicFilter.cs index 1541a2a50..e440f2e96 100644 --- a/src/DynamicData/Cache/Internal/DynamicFilter.cs +++ b/src/DynamicData/Cache/Internal/DynamicFilter.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal class DynamicFilter + where TObject : notnull where TKey : notnull { private readonly IObservable> _predicateChanged; diff --git a/src/DynamicData/Cache/Internal/EditDiff.cs b/src/DynamicData/Cache/Internal/EditDiff.cs index de71536d5..338462151 100644 --- a/src/DynamicData/Cache/Internal/EditDiff.cs +++ b/src/DynamicData/Cache/Internal/EditDiff.cs @@ -7,6 +7,7 @@ namespace DynamicData.Cache.Internal; internal class EditDiff + where TObject : notnull where TKey : notnull { private readonly Func _areEqual; diff --git a/src/DynamicData/Cache/Internal/FilterEx.cs b/src/DynamicData/Cache/Internal/FilterEx.cs index 9dba8644b..154b45f80 100644 --- a/src/DynamicData/Cache/Internal/FilterEx.cs +++ b/src/DynamicData/Cache/Internal/FilterEx.cs @@ -9,6 +9,7 @@ namespace DynamicData.Cache.Internal; internal static class FilterEx { public static void FilterChanges(this ChangeAwareCache cache, IChangeSet changes, Func predicate) + where TObject : notnull where TKey : notnull { foreach (var change in changes.ToConcreteType()) @@ -72,6 +73,7 @@ public static void FilterChanges(this ChangeAwareCache RefreshFilteredFrom(this ChangeAwareCache filtered, Cache allData, Func predicate) + where TObject : notnull where TKey : notnull { if (allData.Count == 0) diff --git a/src/DynamicData/Cache/Internal/FilterOnProperty.cs b/src/DynamicData/Cache/Internal/FilterOnProperty.cs index 779dfe8c8..d59d9d7cc 100644 --- a/src/DynamicData/Cache/Internal/FilterOnProperty.cs +++ b/src/DynamicData/Cache/Internal/FilterOnProperty.cs @@ -11,8 +11,8 @@ namespace DynamicData.Cache.Internal; [Obsolete("Use AutoRefresh(), followed by Filter() instead")] internal class FilterOnProperty - where TKey : notnull where TObject : INotifyPropertyChanged + where TKey : notnull { private readonly Func _predicate; diff --git a/src/DynamicData/Cache/Internal/FilteredIndexCalculator.cs b/src/DynamicData/Cache/Internal/FilteredIndexCalculator.cs index e042da7d6..50e64f4ec 100644 --- a/src/DynamicData/Cache/Internal/FilteredIndexCalculator.cs +++ b/src/DynamicData/Cache/Internal/FilteredIndexCalculator.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal static class FilteredIndexCalculator + where TObject : notnull where TKey : notnull { public static IList> Calculate(IKeyValueCollection currentItems, IKeyValueCollection previousItems, IChangeSet? sourceUpdates) diff --git a/src/DynamicData/Cache/Internal/FullJoin.cs b/src/DynamicData/Cache/Internal/FullJoin.cs index 7c8d73ed4..4e49dd7fa 100644 --- a/src/DynamicData/Cache/Internal/FullJoin.cs +++ b/src/DynamicData/Cache/Internal/FullJoin.cs @@ -11,8 +11,11 @@ namespace DynamicData.Cache.Internal; internal class FullJoin + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { private readonly IObservable> _left; diff --git a/src/DynamicData/Cache/Internal/FullJoinMany.cs b/src/DynamicData/Cache/Internal/FullJoinMany.cs index 068c8304d..5d35a2db7 100644 --- a/src/DynamicData/Cache/Internal/FullJoinMany.cs +++ b/src/DynamicData/Cache/Internal/FullJoinMany.cs @@ -9,8 +9,11 @@ namespace DynamicData.Cache.Internal; internal class FullJoinMany + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { private readonly IObservable> _left; diff --git a/src/DynamicData/Cache/Internal/GroupOn.cs b/src/DynamicData/Cache/Internal/GroupOn.cs index 5ae37b03f..131dcc1f9 100644 --- a/src/DynamicData/Cache/Internal/GroupOn.cs +++ b/src/DynamicData/Cache/Internal/GroupOn.cs @@ -14,6 +14,7 @@ namespace DynamicData.Cache.Internal; internal sealed class GroupOn + where TObject : notnull where TKey : notnull where TGroupKey : notnull { diff --git a/src/DynamicData/Cache/Internal/GroupOnImmutable.cs b/src/DynamicData/Cache/Internal/GroupOnImmutable.cs index a2dde6bdd..a0644c9f1 100644 --- a/src/DynamicData/Cache/Internal/GroupOnImmutable.cs +++ b/src/DynamicData/Cache/Internal/GroupOnImmutable.cs @@ -13,6 +13,7 @@ namespace DynamicData.Cache.Internal; internal sealed class GroupOnImmutable + where TObject : notnull where TKey : notnull where TGroupKey : notnull { diff --git a/src/DynamicData/Cache/Internal/GroupOnPropertyWithImmutableState.cs b/src/DynamicData/Cache/Internal/GroupOnPropertyWithImmutableState.cs index da516a3b5..b5b358791 100644 --- a/src/DynamicData/Cache/Internal/GroupOnPropertyWithImmutableState.cs +++ b/src/DynamicData/Cache/Internal/GroupOnPropertyWithImmutableState.cs @@ -13,9 +13,9 @@ namespace DynamicData.Cache.Internal; internal class GroupOnPropertyWithImmutableState + where TObject : INotifyPropertyChanged where TKey : notnull where TGroup : notnull - where TObject : INotifyPropertyChanged { private readonly Func _groupSelector; diff --git a/src/DynamicData/Cache/Internal/IFilter.cs b/src/DynamicData/Cache/Internal/IFilter.cs index 7707e6644..c5e19397b 100644 --- a/src/DynamicData/Cache/Internal/IFilter.cs +++ b/src/DynamicData/Cache/Internal/IFilter.cs @@ -13,6 +13,7 @@ namespace DynamicData.Cache.Internal; /// The type of the object. /// The type of the field. internal interface IFilter + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Cache/Internal/ImmutableGroup.cs b/src/DynamicData/Cache/Internal/ImmutableGroup.cs index e9ac5d4f6..1d7c4c44b 100644 --- a/src/DynamicData/Cache/Internal/ImmutableGroup.cs +++ b/src/DynamicData/Cache/Internal/ImmutableGroup.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal sealed class ImmutableGroup : IGrouping, IEquatable> + where TObject : notnull where TKey : notnull where TGroupKey : notnull { diff --git a/src/DynamicData/Cache/Internal/ImmutableGroupChangeSet.cs b/src/DynamicData/Cache/Internal/ImmutableGroupChangeSet.cs index 765fb6104..e26dee117 100644 --- a/src/DynamicData/Cache/Internal/ImmutableGroupChangeSet.cs +++ b/src/DynamicData/Cache/Internal/ImmutableGroupChangeSet.cs @@ -7,6 +7,7 @@ namespace DynamicData.Cache.Internal; internal sealed class ImmutableGroupChangeSet : ChangeSet, TGroupKey>, IImmutableGroupChangeSet + where TObject : notnull where TKey : notnull where TGroupKey : notnull { diff --git a/src/DynamicData/Cache/Internal/IndexCalculator.cs b/src/DynamicData/Cache/Internal/IndexCalculator.cs index 986707d11..48317dfa7 100644 --- a/src/DynamicData/Cache/Internal/IndexCalculator.cs +++ b/src/DynamicData/Cache/Internal/IndexCalculator.cs @@ -14,6 +14,7 @@ namespace DynamicData.Cache.Internal; /// and apply indexed changes with no need to apply ant expensive IndexOf() operations. /// internal sealed class IndexCalculator + where TObject : notnull where TKey : notnull { private readonly SortOptimisations _optimisations; diff --git a/src/DynamicData/Cache/Internal/InnerJoin.cs b/src/DynamicData/Cache/Internal/InnerJoin.cs index 86e4af972..15f7d84e2 100644 --- a/src/DynamicData/Cache/Internal/InnerJoin.cs +++ b/src/DynamicData/Cache/Internal/InnerJoin.cs @@ -9,8 +9,11 @@ namespace DynamicData.Cache.Internal; internal class InnerJoin + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { private readonly IObservable> _left; diff --git a/src/DynamicData/Cache/Internal/InnerJoinMany.cs b/src/DynamicData/Cache/Internal/InnerJoinMany.cs index 6540c8192..3157f0987 100644 --- a/src/DynamicData/Cache/Internal/InnerJoinMany.cs +++ b/src/DynamicData/Cache/Internal/InnerJoinMany.cs @@ -7,8 +7,11 @@ namespace DynamicData.Cache.Internal; internal class InnerJoinMany + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { private readonly IObservable> _left; diff --git a/src/DynamicData/Cache/Internal/LeftJoin.cs b/src/DynamicData/Cache/Internal/LeftJoin.cs index 1547d3398..553950a2b 100644 --- a/src/DynamicData/Cache/Internal/LeftJoin.cs +++ b/src/DynamicData/Cache/Internal/LeftJoin.cs @@ -11,8 +11,11 @@ namespace DynamicData.Cache.Internal; internal class LeftJoin + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { private readonly IObservable> _left; diff --git a/src/DynamicData/Cache/Internal/LeftJoinMany.cs b/src/DynamicData/Cache/Internal/LeftJoinMany.cs index 0864e3dc6..4281f69bd 100644 --- a/src/DynamicData/Cache/Internal/LeftJoinMany.cs +++ b/src/DynamicData/Cache/Internal/LeftJoinMany.cs @@ -9,8 +9,11 @@ namespace DynamicData.Cache.Internal; internal class LeftJoinMany + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { private readonly IObservable> _left; diff --git a/src/DynamicData/Cache/Internal/LockFreeObservableCache.cs b/src/DynamicData/Cache/Internal/LockFreeObservableCache.cs index 27882ac2c..b90fa75f1 100644 --- a/src/DynamicData/Cache/Internal/LockFreeObservableCache.cs +++ b/src/DynamicData/Cache/Internal/LockFreeObservableCache.cs @@ -22,6 +22,7 @@ namespace DynamicData.Cache.Internal; /// The type of the key. [DebuggerDisplay("LockFreeObservableCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] public sealed class LockFreeObservableCache : IObservableCache + where TObject : notnull where TKey : notnull { [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "Disposed with _cleanUp")] diff --git a/src/DynamicData/Cache/Internal/ManagedGroup.cs b/src/DynamicData/Cache/Internal/ManagedGroup.cs index 4b0eb4347..086820d14 100644 --- a/src/DynamicData/Cache/Internal/ManagedGroup.cs +++ b/src/DynamicData/Cache/Internal/ManagedGroup.cs @@ -8,6 +8,7 @@ namespace DynamicData.Cache.Internal; internal sealed class ManagedGroup : IGroup, IDisposable + where TObject : notnull where TKey : notnull { private readonly IntermediateCache _cache = new(); diff --git a/src/DynamicData/Cache/Internal/MergeMany.cs b/src/DynamicData/Cache/Internal/MergeMany.cs index bf6f7ae04..29aded015 100644 --- a/src/DynamicData/Cache/Internal/MergeMany.cs +++ b/src/DynamicData/Cache/Internal/MergeMany.cs @@ -7,6 +7,7 @@ namespace DynamicData.Cache.Internal; internal class MergeMany + where TObject : notnull where TKey : notnull { private readonly Func> _observableSelector; diff --git a/src/DynamicData/Cache/Internal/MergeManyItems.cs b/src/DynamicData/Cache/Internal/MergeManyItems.cs index cc75b7f04..8846dcd99 100644 --- a/src/DynamicData/Cache/Internal/MergeManyItems.cs +++ b/src/DynamicData/Cache/Internal/MergeManyItems.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal class MergeManyItems + where TObject : notnull where TKey : notnull { private readonly Func> _observableSelector; diff --git a/src/DynamicData/Cache/Internal/ObservableWithValue.cs b/src/DynamicData/Cache/Internal/ObservableWithValue.cs index e0ff84afb..9c0d5e797 100644 --- a/src/DynamicData/Cache/Internal/ObservableWithValue.cs +++ b/src/DynamicData/Cache/Internal/ObservableWithValue.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal sealed class ObservableWithValue + where TValue : notnull { public ObservableWithValue(TObject item, IObservable source) { diff --git a/src/DynamicData/Cache/Internal/OnBeingRemoved.cs b/src/DynamicData/Cache/Internal/OnBeingRemoved.cs index 2fb7aace2..add1f3354 100644 --- a/src/DynamicData/Cache/Internal/OnBeingRemoved.cs +++ b/src/DynamicData/Cache/Internal/OnBeingRemoved.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal sealed class OnBeingRemoved + where TObject : notnull where TKey : notnull { private readonly Action _removeAction; diff --git a/src/DynamicData/Cache/Internal/Page.cs b/src/DynamicData/Cache/Internal/Page.cs index 73bf33a4e..c4b8bb643 100644 --- a/src/DynamicData/Cache/Internal/Page.cs +++ b/src/DynamicData/Cache/Internal/Page.cs @@ -9,6 +9,7 @@ namespace DynamicData.Cache.Internal; internal class Page + where TObject : notnull where TKey : notnull { private readonly IObservable _pageRequests; diff --git a/src/DynamicData/Cache/Internal/QueryWhenChanged.cs b/src/DynamicData/Cache/Internal/QueryWhenChanged.cs index 590cf3cf2..02c27ea2d 100644 --- a/src/DynamicData/Cache/Internal/QueryWhenChanged.cs +++ b/src/DynamicData/Cache/Internal/QueryWhenChanged.cs @@ -8,6 +8,7 @@ namespace DynamicData.Cache.Internal; internal class QueryWhenChanged + where TObject : notnull where TKey : notnull { private readonly Func>? _itemChangedTrigger; diff --git a/src/DynamicData/Cache/Internal/ReaderWriter.cs b/src/DynamicData/Cache/Internal/ReaderWriter.cs index a34fe3ad8..63bbae02f 100644 --- a/src/DynamicData/Cache/Internal/ReaderWriter.cs +++ b/src/DynamicData/Cache/Internal/ReaderWriter.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal sealed class ReaderWriter + where TObject : notnull where TKey : notnull { private readonly Func? _keySelector; diff --git a/src/DynamicData/Cache/Internal/RefCount.cs b/src/DynamicData/Cache/Internal/RefCount.cs index 7e690f7a3..b64dae3ab 100644 --- a/src/DynamicData/Cache/Internal/RefCount.cs +++ b/src/DynamicData/Cache/Internal/RefCount.cs @@ -9,6 +9,7 @@ namespace DynamicData.Cache.Internal; internal class RefCount + where TObject : notnull where TKey : notnull { private readonly object _locker = new(); diff --git a/src/DynamicData/Cache/Internal/RemoveKeyEnumerator.cs b/src/DynamicData/Cache/Internal/RemoveKeyEnumerator.cs index ed0caa53d..067044eb0 100644 --- a/src/DynamicData/Cache/Internal/RemoveKeyEnumerator.cs +++ b/src/DynamicData/Cache/Internal/RemoveKeyEnumerator.cs @@ -9,6 +9,7 @@ namespace DynamicData.Cache.Internal; internal class RemoveKeyEnumerator : IEnumerable> + where TObject : notnull where TKey : notnull { private readonly IExtendedList? _list; diff --git a/src/DynamicData/Cache/Internal/RightJoin.cs b/src/DynamicData/Cache/Internal/RightJoin.cs index 49635572f..90103ed03 100644 --- a/src/DynamicData/Cache/Internal/RightJoin.cs +++ b/src/DynamicData/Cache/Internal/RightJoin.cs @@ -11,8 +11,11 @@ namespace DynamicData.Cache.Internal; internal class RightJoin + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { private readonly IObservable> _left; diff --git a/src/DynamicData/Cache/Internal/RightJoinMany.cs b/src/DynamicData/Cache/Internal/RightJoinMany.cs index 17b4d91d6..80996c70a 100644 --- a/src/DynamicData/Cache/Internal/RightJoinMany.cs +++ b/src/DynamicData/Cache/Internal/RightJoinMany.cs @@ -9,8 +9,11 @@ namespace DynamicData.Cache.Internal; internal class RightJoinMany + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { private readonly IObservable> _left; diff --git a/src/DynamicData/Cache/Internal/SizeExpirer.cs b/src/DynamicData/Cache/Internal/SizeExpirer.cs index fd762cf56..15acb4ecb 100644 --- a/src/DynamicData/Cache/Internal/SizeExpirer.cs +++ b/src/DynamicData/Cache/Internal/SizeExpirer.cs @@ -12,6 +12,7 @@ namespace DynamicData.Cache.Internal; internal class SizeExpirer + where TObject : notnull where TKey : notnull { private readonly int _size; diff --git a/src/DynamicData/Cache/Internal/SizeLimiter.cs b/src/DynamicData/Cache/Internal/SizeLimiter.cs index 56cc910be..b535ba1e0 100644 --- a/src/DynamicData/Cache/Internal/SizeLimiter.cs +++ b/src/DynamicData/Cache/Internal/SizeLimiter.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal sealed class SizeLimiter + where TObject : notnull where TKey : notnull { private readonly ChangeAwareCache, TKey> _cache = new(); diff --git a/src/DynamicData/Cache/Internal/Sort.cs b/src/DynamicData/Cache/Internal/Sort.cs index 2d0f1121c..260ec7c95 100644 --- a/src/DynamicData/Cache/Internal/Sort.cs +++ b/src/DynamicData/Cache/Internal/Sort.cs @@ -11,6 +11,7 @@ namespace DynamicData.Cache.Internal; internal sealed class Sort + where TObject : notnull where TKey : notnull { private readonly IComparer? _comparer; diff --git a/src/DynamicData/Cache/Internal/SpecifiedGrouper.cs b/src/DynamicData/Cache/Internal/SpecifiedGrouper.cs index 69b0693fa..dd3f7f54b 100644 --- a/src/DynamicData/Cache/Internal/SpecifiedGrouper.cs +++ b/src/DynamicData/Cache/Internal/SpecifiedGrouper.cs @@ -10,6 +10,7 @@ namespace DynamicData.Cache.Internal; internal class SpecifiedGrouper + where TObject : notnull where TKey : notnull where TGroupKey : notnull { diff --git a/src/DynamicData/Cache/Internal/StaticFilter.cs b/src/DynamicData/Cache/Internal/StaticFilter.cs index d8f6283ff..ee2a9887c 100644 --- a/src/DynamicData/Cache/Internal/StaticFilter.cs +++ b/src/DynamicData/Cache/Internal/StaticFilter.cs @@ -8,6 +8,7 @@ namespace DynamicData.Cache.Internal; internal class StaticFilter + where TObject : notnull where TKey : notnull { private readonly Func _filter; diff --git a/src/DynamicData/Cache/Internal/SubscribeMany.cs b/src/DynamicData/Cache/Internal/SubscribeMany.cs index 26c4df67d..a2a5050e5 100644 --- a/src/DynamicData/Cache/Internal/SubscribeMany.cs +++ b/src/DynamicData/Cache/Internal/SubscribeMany.cs @@ -9,6 +9,7 @@ namespace DynamicData.Cache.Internal; internal class SubscribeMany + where TObject : notnull where TKey : notnull { private readonly IObservable> _source; diff --git a/src/DynamicData/Cache/Internal/Switch.cs b/src/DynamicData/Cache/Internal/Switch.cs index dbb063cb8..ef5edb313 100644 --- a/src/DynamicData/Cache/Internal/Switch.cs +++ b/src/DynamicData/Cache/Internal/Switch.cs @@ -9,6 +9,7 @@ namespace DynamicData.Cache.Internal; internal sealed class Switch + where TObject : notnull where TKey : notnull { private readonly IObservable>> _sources; diff --git a/src/DynamicData/Cache/Internal/TimeExpirer.cs b/src/DynamicData/Cache/Internal/TimeExpirer.cs index 61fce6539..0314fc386 100644 --- a/src/DynamicData/Cache/Internal/TimeExpirer.cs +++ b/src/DynamicData/Cache/Internal/TimeExpirer.cs @@ -14,6 +14,7 @@ namespace DynamicData.Cache.Internal; internal class TimeExpirer + where TObject : notnull where TKey : notnull { private readonly TimeSpan? _interval; diff --git a/src/DynamicData/Cache/Internal/ToObservableChangeSet.cs b/src/DynamicData/Cache/Internal/ToObservableChangeSet.cs index d4139feec..f8f9078da 100644 --- a/src/DynamicData/Cache/Internal/ToObservableChangeSet.cs +++ b/src/DynamicData/Cache/Internal/ToObservableChangeSet.cs @@ -9,6 +9,7 @@ namespace DynamicData.Cache.Internal; internal class ToObservableChangeSet + where TObject : notnull where TKey : notnull { private readonly IObservable> _source; diff --git a/src/DynamicData/Cache/Internal/Transform.cs b/src/DynamicData/Cache/Internal/Transform.cs index 243034a07..ea5e6611d 100644 --- a/src/DynamicData/Cache/Internal/Transform.cs +++ b/src/DynamicData/Cache/Internal/Transform.cs @@ -10,6 +10,8 @@ namespace DynamicData.Cache.Internal; internal sealed class Transform + where TDestination : notnull + where TSource : notnull where TKey : notnull { private readonly Action>? _exceptionCallback; diff --git a/src/DynamicData/Cache/Internal/TransformAsync.cs b/src/DynamicData/Cache/Internal/TransformAsync.cs index 626bbab39..29188d2fa 100644 --- a/src/DynamicData/Cache/Internal/TransformAsync.cs +++ b/src/DynamicData/Cache/Internal/TransformAsync.cs @@ -9,6 +9,8 @@ namespace DynamicData.Cache.Internal; internal class TransformAsync + where TDestination : notnull + where TSource : notnull where TKey : notnull { private readonly Action>? _exceptionCallback; diff --git a/src/DynamicData/Cache/Internal/TransformMany.cs b/src/DynamicData/Cache/Internal/TransformMany.cs index 0bdfe75b5..c5ee800bd 100644 --- a/src/DynamicData/Cache/Internal/TransformMany.cs +++ b/src/DynamicData/Cache/Internal/TransformMany.cs @@ -1,280 +1,282 @@ -// Copyright (c) 2011-2020 Roland Pheasant. All rights reserved. -// Roland Pheasant licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reactive.Disposables; -using System.Reactive.Linq; - -using DynamicData.Binding; -using DynamicData.Kernel; - -namespace DynamicData.Cache.Internal; - -internal class TransformMany - where TSourceKey : notnull - where TDestinationKey : notnull -{ - private readonly Func>>? _childChanges; - - private readonly Func _keySelector; - - private readonly Func> _manySelector; - - private readonly IObservable> _source; - - public TransformMany(IObservable> source, Func> manySelector, Func keySelector) - : this( - source, - manySelector, - keySelector, - t => Observable.Defer( - () => - { - var subsequentChanges = manySelector(t).ToObservableChangeSet(keySelector); - - if (manySelector(t).Count > 0) - { - return subsequentChanges; - } - - return Observable.Return(ChangeSet.Empty).Concat(subsequentChanges); - })) - { - } - - public TransformMany(IObservable> source, Func> manySelector, Func keySelector) - : this( - source, - manySelector, - keySelector, - t => Observable.Defer( - () => - { - var subsequentChanges = manySelector(t).ToObservableChangeSet(keySelector); - - if (manySelector(t).Count > 0) - { - return subsequentChanges; - } - - return Observable.Return(ChangeSet.Empty).Concat(subsequentChanges); - })) - { - } - +// Copyright (c) 2011-2020 Roland Pheasant. All rights reserved. +// Roland Pheasant licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reactive.Disposables; +using System.Reactive.Linq; + +using DynamicData.Binding; +using DynamicData.Kernel; + +namespace DynamicData.Cache.Internal; + +internal class TransformMany + where TDestination : notnull + where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull +{ + private readonly Func>>? _childChanges; + + private readonly Func _keySelector; + + private readonly Func> _manySelector; + + private readonly IObservable> _source; + + public TransformMany(IObservable> source, Func> manySelector, Func keySelector) + : this( + source, + manySelector, + keySelector, + t => Observable.Defer( + () => + { + var subsequentChanges = manySelector(t).ToObservableChangeSet(keySelector); + + if (manySelector(t).Count > 0) + { + return subsequentChanges; + } + + return Observable.Return(ChangeSet.Empty).Concat(subsequentChanges); + })) + { + } + + public TransformMany(IObservable> source, Func> manySelector, Func keySelector) + : this( + source, + manySelector, + keySelector, + t => Observable.Defer( + () => + { + var subsequentChanges = manySelector(t).ToObservableChangeSet(keySelector); + + if (manySelector(t).Count > 0) + { + return subsequentChanges; + } + + return Observable.Return(ChangeSet.Empty).Concat(subsequentChanges); + })) + { + } + public TransformMany(IObservable> source, Func> manySelector, Func keySelector) - : this(source, - x => manySelector(x).Items, - keySelector, - t => Observable.Defer( - () => - { - var subsequentChanges = Observable.Create>(o => manySelector(t).Connect().Subscribe(o)); - - if (manySelector(t).Count > 0) - { - return subsequentChanges; - } - - return Observable.Return(ChangeSet.Empty).Concat(subsequentChanges); - })) - { - } - - public TransformMany(IObservable> source, Func> manySelector, Func keySelector, Func>>? childChanges = null) - { - _source = source; - _manySelector = manySelector; - _keySelector = keySelector; - _childChanges = childChanges; - } - - public IObservable> Run() - { - return _childChanges is null ? Create() : CreateWithChangeSet(); - } - - private IObservable> Create() - { - return _source.Transform( - (t, _) => - { - var destination = _manySelector(t).Select(m => new DestinationContainer(m, _keySelector(m))).ToArray(); - return new ManyContainer(() => destination); - }, - true).Select(changes => new ChangeSet(new DestinationEnumerator(changes))); - } - - private IObservable> CreateWithChangeSet() - { - if (_childChanges is null) - { - throw new InvalidOperationException("The childChanges is null and should not be."); - } - - return Observable.Create>( - observer => - { - var result = new ChangeAwareCache(); - - var transformed = _source.Transform( - (t, _) => - { - // Only skip initial for first time Adds where there is initial data records - var locker = new object(); - var changes = _childChanges(t).Synchronize(locker).Skip(1); - return new ManyContainer( - () => - { - var collection = _manySelector(t); - lock (locker) - { - return collection.Select(m => new DestinationContainer(m, _keySelector(m))).ToArray(); - } - }, - changes); - }).Publish(); - - var outerLock = new object(); - var initial = transformed.Synchronize(outerLock).Select(changes => new ChangeSet(new DestinationEnumerator(changes))); - - var subsequent = transformed.MergeMany(x => x.Changes).Synchronize(outerLock); - - var allChanges = initial.Merge(subsequent).Select( - changes => - { - result.Clone(changes); - return result.CaptureChanges(); - }); - - return new CompositeDisposable(allChanges.SubscribeSafe(observer), transformed.Connect()); - }); - } - - private sealed class DestinationContainer - { - public DestinationContainer(TDestination item, TDestinationKey key) - { - Item = item; - Key = key; - } - - public static IEqualityComparer KeyComparer { get; } = new KeyEqualityComparer(); - - public TDestination Item { get; } - - public TDestinationKey Key { get; } - - private sealed class KeyEqualityComparer : IEqualityComparer - { - public bool Equals(DestinationContainer? x, DestinationContainer? y) - { - if (x is null && y is null) - { - return true; - } - - if (x is null || y is null) - { - return false; - } - - return EqualityComparer.Default.Equals(x.Key, y.Key); - } - - public int GetHashCode(DestinationContainer obj) - { - return EqualityComparer.Default.GetHashCode(obj.Key); - } - } - } - - private sealed class DestinationEnumerator : IEnumerable> - { - private readonly IChangeSet _changes; - - public DestinationEnumerator(IChangeSet changes) - { - _changes = changes; - } - - public IEnumerator> GetEnumerator() - { - foreach (var change in _changes) - { - switch (change.Reason) - { - case ChangeReason.Add: - case ChangeReason.Remove: - case ChangeReason.Refresh: - { - foreach (var destination in change.Current.Destination) - { - yield return new Change(change.Reason, destination.Key, destination.Item); - } - } - - break; - case ChangeReason.Update: - { - var previousItems = change.Previous.Value.Destination.AsArray(); - var currentItems = change.Current.Destination.AsArray(); - - var removes = previousItems.Except(currentItems, DestinationContainer.KeyComparer); - var adds = currentItems.Except(previousItems, DestinationContainer.KeyComparer); - var updates = currentItems.Intersect(previousItems, DestinationContainer.KeyComparer); - - foreach (var destination in removes) - { - yield return new Change(ChangeReason.Remove, destination.Key, destination.Item); - } - - foreach (var destination in adds) - { - yield return new Change(ChangeReason.Add, destination.Key, destination.Item); - } - - foreach (var destination in updates) - { - var current = currentItems.First(d => d.Key.Equals(destination.Key)); - var previous = previousItems.First(d => d.Key.Equals(destination.Key)); - - // Do not update is items are the same reference - if (!ReferenceEquals(current.Item, previous.Item)) - { - yield return new Change(ChangeReason.Update, destination.Key, current.Item, previous.Item); - } - } - } - - break; - } - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } - - private sealed class ManyContainer - { - private readonly Func> _initial; - - public ManyContainer(Func> initial, IObservable>? changes = null) - { - _initial = initial; - Changes = changes ?? Observable.Empty>(); - } - - public IObservable> Changes { get; } - - public IEnumerable Destination => _initial(); - } -} + : this(source, + x => manySelector(x).Items, + keySelector, + t => Observable.Defer( + () => + { + var subsequentChanges = Observable.Create>(o => manySelector(t).Connect().Subscribe(o)); + + if (manySelector(t).Count > 0) + { + return subsequentChanges; + } + + return Observable.Return(ChangeSet.Empty).Concat(subsequentChanges); + })) + { + } + + public TransformMany(IObservable> source, Func> manySelector, Func keySelector, Func>>? childChanges = null) + { + _source = source; + _manySelector = manySelector; + _keySelector = keySelector; + _childChanges = childChanges; + } + + public IObservable> Run() + { + return _childChanges is null ? Create() : CreateWithChangeSet(); + } + + private IObservable> Create() + { + return _source.Transform( + (t, _) => + { + var destination = _manySelector(t).Select(m => new DestinationContainer(m, _keySelector(m))).ToArray(); + return new ManyContainer(() => destination); + }, + true).Select(changes => new ChangeSet(new DestinationEnumerator(changes))); + } + + private IObservable> CreateWithChangeSet() + { + if (_childChanges is null) + { + throw new InvalidOperationException("The childChanges is null and should not be."); + } + + return Observable.Create>( + observer => + { + var result = new ChangeAwareCache(); + + var transformed = _source.Transform( + (t, _) => + { + // Only skip initial for first time Adds where there is initial data records + var locker = new object(); + var changes = _childChanges(t).Synchronize(locker).Skip(1); + return new ManyContainer( + () => + { + var collection = _manySelector(t); + lock (locker) + { + return collection.Select(m => new DestinationContainer(m, _keySelector(m))).ToArray(); + } + }, + changes); + }).Publish(); + + var outerLock = new object(); + var initial = transformed.Synchronize(outerLock).Select(changes => new ChangeSet(new DestinationEnumerator(changes))); + + var subsequent = transformed.MergeMany(x => x.Changes).Synchronize(outerLock); + + var allChanges = initial.Merge(subsequent).Select( + changes => + { + result.Clone(changes); + return result.CaptureChanges(); + }); + + return new CompositeDisposable(allChanges.SubscribeSafe(observer), transformed.Connect()); + }); + } + + private sealed class DestinationContainer + { + public DestinationContainer(TDestination item, TDestinationKey key) + { + Item = item; + Key = key; + } + + public static IEqualityComparer KeyComparer { get; } = new KeyEqualityComparer(); + + public TDestination Item { get; } + + public TDestinationKey Key { get; } + + private sealed class KeyEqualityComparer : IEqualityComparer + { + public bool Equals(DestinationContainer? x, DestinationContainer? y) + { + if (x is null && y is null) + { + return true; + } + + if (x is null || y is null) + { + return false; + } + + return EqualityComparer.Default.Equals(x.Key, y.Key); + } + + public int GetHashCode(DestinationContainer obj) + { + return EqualityComparer.Default.GetHashCode(obj.Key); + } + } + } + + private sealed class DestinationEnumerator : IEnumerable> + { + private readonly IChangeSet _changes; + + public DestinationEnumerator(IChangeSet changes) + { + _changes = changes; + } + + public IEnumerator> GetEnumerator() + { + foreach (var change in _changes) + { + switch (change.Reason) + { + case ChangeReason.Add: + case ChangeReason.Remove: + case ChangeReason.Refresh: + { + foreach (var destination in change.Current.Destination) + { + yield return new Change(change.Reason, destination.Key, destination.Item); + } + } + + break; + case ChangeReason.Update: + { + var previousItems = change.Previous.Value.Destination.AsArray(); + var currentItems = change.Current.Destination.AsArray(); + + var removes = previousItems.Except(currentItems, DestinationContainer.KeyComparer); + var adds = currentItems.Except(previousItems, DestinationContainer.KeyComparer); + var updates = currentItems.Intersect(previousItems, DestinationContainer.KeyComparer); + + foreach (var destination in removes) + { + yield return new Change(ChangeReason.Remove, destination.Key, destination.Item); + } + + foreach (var destination in adds) + { + yield return new Change(ChangeReason.Add, destination.Key, destination.Item); + } + + foreach (var destination in updates) + { + var current = currentItems.First(d => d.Key.Equals(destination.Key)); + var previous = previousItems.First(d => d.Key.Equals(destination.Key)); + + // Do not update is items are the same reference + if (!ReferenceEquals(current.Item, previous.Item)) + { + yield return new Change(ChangeReason.Update, destination.Key, current.Item, previous.Item); + } + } + } + + break; + } + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } + + private sealed class ManyContainer + { + private readonly Func> _initial; + + public ManyContainer(Func> initial, IObservable>? changes = null) + { + _initial = initial; + Changes = changes ?? Observable.Empty>(); + } + + public IObservable> Changes { get; } + + public IEnumerable Destination => _initial(); + } +} diff --git a/src/DynamicData/Cache/Internal/TransformWithForcedTransform.cs b/src/DynamicData/Cache/Internal/TransformWithForcedTransform.cs index 218398e66..ec2c02d51 100644 --- a/src/DynamicData/Cache/Internal/TransformWithForcedTransform.cs +++ b/src/DynamicData/Cache/Internal/TransformWithForcedTransform.cs @@ -12,6 +12,8 @@ namespace DynamicData.Cache.Internal; internal sealed class TransformWithForcedTransform + where TDestination : notnull + where TSource : notnull where TKey : notnull { private readonly Action>? _exceptionCallback; diff --git a/src/DynamicData/Cache/Internal/TransformWithInlineUpdate.cs b/src/DynamicData/Cache/Internal/TransformWithInlineUpdate.cs index 3efc10209..7c8f5f021 100644 --- a/src/DynamicData/Cache/Internal/TransformWithInlineUpdate.cs +++ b/src/DynamicData/Cache/Internal/TransformWithInlineUpdate.cs @@ -10,8 +10,9 @@ namespace DynamicData.Cache.Internal; internal sealed class TransformWithInlineUpdate - where TKey : notnull where TDestination : class + where TSource : notnull + where TKey : notnull { private readonly Action>? _exceptionCallback; diff --git a/src/DynamicData/Cache/Internal/TreeBuilder.cs b/src/DynamicData/Cache/Internal/TreeBuilder.cs index 348b39e66..e8bf36a14 100644 --- a/src/DynamicData/Cache/Internal/TreeBuilder.cs +++ b/src/DynamicData/Cache/Internal/TreeBuilder.cs @@ -14,8 +14,8 @@ namespace DynamicData.Cache.Internal; internal class TreeBuilder - where TKey : notnull where TObject : class + where TKey : notnull { private readonly Func _pivotOn; diff --git a/src/DynamicData/Cache/Internal/TrueFor.cs b/src/DynamicData/Cache/Internal/TrueFor.cs index 88b9cace3..537df0b91 100644 --- a/src/DynamicData/Cache/Internal/TrueFor.cs +++ b/src/DynamicData/Cache/Internal/TrueFor.cs @@ -10,7 +10,9 @@ namespace DynamicData.Cache.Internal; internal class TrueFor + where TObject : notnull where TKey : notnull + where TValue : notnull { private readonly Func>, bool> _collectionMatcher; diff --git a/src/DynamicData/Cache/Internal/UniquenessEnforcer.cs b/src/DynamicData/Cache/Internal/UniquenessEnforcer.cs index e43fd2ea5..16f10d856 100644 --- a/src/DynamicData/Cache/Internal/UniquenessEnforcer.cs +++ b/src/DynamicData/Cache/Internal/UniquenessEnforcer.cs @@ -7,6 +7,7 @@ namespace DynamicData.Cache.Internal; internal class UniquenessEnforcer + where TObject : notnull where TKey : notnull { private readonly IObservable> _source; diff --git a/src/DynamicData/Cache/Internal/Virtualise.cs b/src/DynamicData/Cache/Internal/Virtualise.cs index 57cf71216..e3c1455d4 100644 --- a/src/DynamicData/Cache/Internal/Virtualise.cs +++ b/src/DynamicData/Cache/Internal/Virtualise.cs @@ -9,6 +9,7 @@ namespace DynamicData.Cache.Internal; internal sealed class Virtualise + where TObject : notnull where TKey : notnull { private readonly IObservable> _source; diff --git a/src/DynamicData/Cache/Node.cs b/src/DynamicData/Cache/Node.cs index 51cca0797..7ed2dfdf2 100644 --- a/src/DynamicData/Cache/Node.cs +++ b/src/DynamicData/Cache/Node.cs @@ -17,8 +17,8 @@ namespace DynamicData; /// The type of the object. /// The type of the key. public class Node : IDisposable, IEquatable> - where TKey : notnull where TObject : class + where TKey : notnull { [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "Disposed with _cleanUp")] private readonly ISourceCache, TKey> _children = new SourceCache, TKey>(n => n.Key); diff --git a/src/DynamicData/Cache/ObservableCache.cs b/src/DynamicData/Cache/ObservableCache.cs index 7ece112db..c55d913de 100644 --- a/src/DynamicData/Cache/ObservableCache.cs +++ b/src/DynamicData/Cache/ObservableCache.cs @@ -15,6 +15,7 @@ namespace DynamicData; [DebuggerDisplay("ObservableCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] internal sealed class ObservableCache : IObservableCache + where TObject : notnull where TKey : notnull { [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "Disposed with _cleanUp")] diff --git a/src/DynamicData/Cache/ObservableCacheEx.cs b/src/DynamicData/Cache/ObservableCacheEx.cs index adc8ffb5b..455ad234e 100644 --- a/src/DynamicData/Cache/ObservableCacheEx.cs +++ b/src/DynamicData/Cache/ObservableCacheEx.cs @@ -40,6 +40,7 @@ public static class ObservableCacheEx /// destination. /// public static IObservable> Adapt(this IObservable> source, IChangeSetAdaptor adaptor) + where TObject : notnull where TKey : notnull { if (source is null) @@ -69,6 +70,7 @@ public static IObservable> Adapt(this I /// destination. /// public static IObservable> Adapt(this IObservable> source, ISortedChangeSetAdaptor adaptor) + where TObject : notnull where TKey : notnull { if (source is null) @@ -93,6 +95,7 @@ public static IObservable> Adapt(this I /// The item. /// source. public static void AddOrUpdate(this ISourceCache source, TObject item) + where TObject : notnull where TKey : notnull { if (source is null) @@ -113,6 +116,7 @@ public static void AddOrUpdate(this ISourceCache s /// The equality comparer used to determine whether a new item is the same as an existing cached item. /// source. public static void AddOrUpdate(this ISourceCache source, TObject item, IEqualityComparer equalityComparer) + where TObject : notnull where TKey : notnull { if (source is null) @@ -134,6 +138,7 @@ public static void AddOrUpdate(this ISourceCache s /// The items. /// source. public static void AddOrUpdate(this ISourceCache source, IEnumerable items) + where TObject : notnull where TKey : notnull { if (source is null) @@ -156,6 +161,7 @@ public static void AddOrUpdate(this ISourceCache s /// The equality comparer used to determine whether a new item is the same as an existing cached item. /// source. public static void AddOrUpdate(this ISourceCache source, IEnumerable items, IEqualityComparer equalityComparer) + where TObject : notnull where TKey : notnull { if (source is null) @@ -176,6 +182,7 @@ public static void AddOrUpdate(this ISourceCache s /// The key to add or update. /// source. public static void AddOrUpdate(this IIntermediateCache source, TObject item, TKey key) + where TObject : notnull where TKey : notnull { if (source is null) @@ -202,6 +209,7 @@ public static void AddOrUpdate(this IIntermediateCacheAn observable which emits change sets. /// source or others. public static IObservable> And(this IObservable> source, params IObservable>[] others) + where TObject : notnull where TKey : notnull { if (source is null) @@ -230,6 +238,7 @@ public static IObservable> And(this IOb /// others. /// public static IObservable> And(this ICollection>> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -249,6 +258,7 @@ public static IObservable> And(this ICo /// The source. /// An observable which emits change sets. public static IObservable> And(this IObservableList>> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -268,6 +278,7 @@ public static IObservable> And(this IOb /// The source. /// An observable which emits change sets. public static IObservable> And(this IObservableList> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -287,6 +298,7 @@ public static IObservable> And(this IOb /// The source. /// An observable which emits change sets. public static IObservable> And(this IObservableList> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -306,6 +318,7 @@ public static IObservable> And(this IOb /// An observable cache. /// source. public static IObservableCache AsObservableCache(this IObservableCache source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -326,6 +339,7 @@ public static IObservableCache AsObservableCache(t /// An observable cache. /// source. public static IObservableCache AsObservableCache(this IObservable> source, bool applyLocking = true) + where TObject : notnull where TKey : notnull { if (source is null) @@ -352,8 +366,8 @@ public static IObservableCache AsObservableCache(t /// The scheduler. /// An observable change set with additional refresh changes. public static IObservable> AutoRefresh(this IObservable> source, TimeSpan? changeSetBuffer = null, TimeSpan? propertyChangeThrottle = null, IScheduler? scheduler = null) - where TKey : notnull where TObject : INotifyPropertyChanged + where TKey : notnull { if (source is null) { @@ -387,8 +401,8 @@ public static IObservable> AutoRefresh( /// The scheduler. /// An observable change set with additional refresh changes. public static IObservable> AutoRefresh(this IObservable> source, Expression> propertyAccessor, TimeSpan? changeSetBuffer = null, TimeSpan? propertyChangeThrottle = null, IScheduler? scheduler = null) - where TKey : notnull where TObject : INotifyPropertyChanged + where TKey : notnull { if (source is null) { @@ -421,6 +435,7 @@ public static IObservable> AutoRefreshThe scheduler. /// An observable change set with additional refresh changes. public static IObservable> AutoRefreshOnObservable(this IObservable> source, Func> reevaluator, TimeSpan? changeSetBuffer = null, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { return source.AutoRefreshOnObservable((t, _) => reevaluator(t), changeSetBuffer, scheduler); @@ -438,6 +453,7 @@ public static IObservable> AutoRefreshOnObservableThe scheduler. /// An observable change set with additional refresh changes. public static IObservable> AutoRefreshOnObservable(this IObservable> source, Func> reevaluator, TimeSpan? changeSetBuffer = null, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { if (source is null) @@ -466,6 +482,7 @@ public static IObservable> AutoRefreshOnObservable public static IObservable> Batch(this IObservable> source, TimeSpan timeSpan, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { if (source is null) @@ -488,6 +505,7 @@ public static IObservable> Batch(this I /// An observable which emits change sets. /// source. public static IObservable> BatchIf(this IObservable> source, IObservable pauseIfTrueSelector, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { return BatchIf(source, pauseIfTrueSelector, false, scheduler); @@ -506,6 +524,7 @@ public static IObservable> BatchIf(this /// An observable which emits change sets. /// source. public static IObservable> BatchIf(this IObservable> source, IObservable pauseIfTrueSelector, bool initialPauseState = false, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { return new BatchIf(source, pauseIfTrueSelector, null, initialPauseState, scheduler: scheduler).Run(); @@ -524,6 +543,7 @@ public static IObservable> BatchIf(this /// An observable which emits change sets. /// source. public static IObservable> BatchIf(this IObservable> source, IObservable pauseIfTrueSelector, TimeSpan? timeOut = null, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { return BatchIf(source, pauseIfTrueSelector, false, timeOut, scheduler); @@ -543,6 +563,7 @@ public static IObservable> BatchIf(this /// An observable which emits change sets. /// source. public static IObservable> BatchIf(this IObservable> source, IObservable pauseIfTrueSelector, bool initialPauseState = false, TimeSpan? timeOut = null, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { if (source is null) @@ -572,6 +593,7 @@ public static IObservable> BatchIf(this /// An observable which emits change sets. /// source. public static IObservable> BatchIf(this IObservable> source, IObservable pauseIfTrueSelector, bool initialPauseState = false, IObservable? timer = null, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { return new BatchIf(source, pauseIfTrueSelector, null, initialPauseState, timer, scheduler).Run(); @@ -588,6 +610,7 @@ public static IObservable> BatchIf(this /// An observable which will emit change sets. /// source. public static IObservable> Bind(this IObservable> source, IObservableCollection destination, int refreshThreshold = 25) + where TObject : notnull where TKey : notnull { if (source is null) @@ -614,6 +637,7 @@ public static IObservable> Bind(this IO /// An observable which will emit change sets. /// source. public static IObservable> Bind(this IObservable> source, IObservableCollection destination, IObservableCollectionAdaptor updater) + where TObject : notnull where TKey : notnull { if (source is null) @@ -654,6 +678,7 @@ public static IObservable> Bind(this IO /// An observable which will emit change sets. /// source. public static IObservable> Bind(this IObservable> source, IObservableCollection destination) + where TObject : notnull where TKey : notnull { if (source is null) @@ -681,6 +706,7 @@ public static IObservable> Bind(t /// An observable which will emit change sets. /// source. public static IObservable> Bind(this IObservable> source, IObservableCollection destination, ISortedObservableCollectionAdaptor updater) + where TObject : notnull where TKey : notnull { if (source is null) @@ -723,6 +749,7 @@ public static IObservable> Bind(t /// An observable which will emit change sets. /// source. public static IObservable> Bind(this IObservable> source, out ReadOnlyObservableCollection readOnlyObservableCollection, int resetThreshold = 25, ISortedObservableCollectionAdaptor? adaptor = null) + where TObject : notnull where TKey : notnull { if (source is null) @@ -750,6 +777,7 @@ public static IObservable> Bind(this IO /// An observable which will emit change sets. /// source. public static IObservable> Bind(this IObservable> source, out ReadOnlyObservableCollection readOnlyObservableCollection, int resetThreshold = 25, bool useReplaceForUpdates = false, IObservableCollectionAdaptor? adaptor = null) + where TObject : notnull where TKey : notnull { if (source is null) @@ -781,6 +809,7 @@ public static IObservable> Bind(this IO /// targetCollection. /// public static IObservable> Bind(this IObservable> source, BindingList bindingList, int resetThreshold = 25) + where TObject : notnull where TKey : notnull { if (source is null) @@ -815,6 +844,7 @@ public static IObservable> Bind(this IO /// targetCollection. /// public static IObservable> Bind(this IObservable> source, BindingList bindingList, int resetThreshold = 25) + where TObject : notnull where TKey : notnull { if (source is null) @@ -842,6 +872,7 @@ public static IObservable> Bind(this IO /// The scheduler to buffer on. /// An observable which emits change sets. public static IObservable> BufferInitial(this IObservable> source, TimeSpan initialBuffer, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { return source.DeferUntilLoaded().Publish( @@ -864,7 +895,9 @@ public static IObservable> BufferInitialThe conversion factory. /// An observable which emits change sets. public static IObservable> Cast(this IObservable> source, Func converter) + where TSource : notnull where TKey : notnull + where TDestination : notnull { if (source is null) { @@ -884,6 +917,7 @@ public static IObservable> CastThe key selector eg. (item) => newKey. /// An observable which emits change sets. public static IObservable> ChangeKey(this IObservable> source, Func keySelector) + where TObject : notnull where TSourceKey : notnull where TDestinationKey : notnull { @@ -916,6 +950,7 @@ public static IObservable> ChangeKeyAn observable which emits change sets. /// source. public static IObservable> ChangeKey(this IObservable> source, Func keySelector) + where TObject : notnull where TSourceKey : notnull where TDestinationKey : notnull { @@ -945,6 +980,7 @@ public static IObservable> ChangeKeyThe source. /// source. public static void Clear(this ISourceCache source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -963,6 +999,7 @@ public static void Clear(this ISourceCache source) /// The source. /// source. public static void Clear(this IIntermediateCache source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -981,6 +1018,7 @@ public static void Clear(this IIntermediateCache s /// The source. /// source. public static void Clear(this LockFreeObservableCache source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1000,6 +1038,7 @@ public static void Clear(this LockFreeObservableCacheThe target. /// An observable which emits change sets. public static IObservable> Clone(this IObservable> source, ICollection target) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1054,7 +1093,9 @@ public static IObservable> Clone(this I /// An observable which emits change sets. [Obsolete("This was an experiment that did not work. Use Transform instead")] public static IObservable> Convert(this IObservable> source, Func conversionFactory) + where TObject : notnull where TKey : notnull + where TDestination : notnull { if (source is null) { @@ -1082,6 +1123,7 @@ public static IObservable> ConvertThe source. /// An observable which emits change sets. public static IObservable> DeferUntilLoaded(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1100,6 +1142,7 @@ public static IObservable> DeferUntilLoadedThe source. /// An observable which emits change sets. public static IObservable> DeferUntilLoaded(this IObservableCache source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1122,6 +1165,7 @@ public static IObservable> DeferUntilLoadedA continuation of the original stream. /// source. public static IObservable> DisposeMany(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1152,6 +1196,7 @@ public static IObservable> DisposeMany( /// /// source. public static IObservable> DistinctValues(this IObservable> source, Func valueSelector) + where TObject : notnull where TKey : notnull where TValue : notnull { @@ -1179,6 +1224,7 @@ public static IObservable> DistinctValuesThe equality comparer used to determine whether a new item is the same as an existing cached item. /// source. public static void EditDiff(this ISourceCache source, IEnumerable allItems, IEqualityComparer equalityComparer) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1210,6 +1256,7 @@ public static void EditDiff(this ISourceCache sour /// Expression to determine whether an item's value is equal to the old value (current, previous) => current.Version == previous.Version. /// source. public static void EditDiff(this ISourceCache source, IEnumerable allItems, Func areItemsEqual) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1241,6 +1288,7 @@ public static void EditDiff(this ISourceCache sour /// source. [Obsolete(Constants.EvaluateIsDead)] public static void Evaluate(this ISourceCache source, TObject item) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1261,6 +1309,7 @@ public static void Evaluate(this ISourceCache sour /// source. [Obsolete(Constants.EvaluateIsDead)] public static void Evaluate(this ISourceCache source, IEnumerable items) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1280,6 +1329,7 @@ public static void Evaluate(this ISourceCache sour /// source. [Obsolete(Constants.EvaluateIsDead)] public static void Evaluate(this ISourceCache source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1305,6 +1355,7 @@ public static void Evaluate(this ISourceCache sour /// others. /// public static IObservable> Except(this IObservable> source, params IObservable>[] others) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1334,6 +1385,7 @@ public static IObservable> Except(this /// others. /// public static IObservable> Except(this ICollection>> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -1353,6 +1405,7 @@ public static IObservable> Except(this /// The source. /// An observable which emits change sets. public static IObservable> Except(this IObservableList>> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -1372,6 +1425,7 @@ public static IObservable> Except(this /// The source. /// An observable which emits change sets. public static IObservable> Except(this IObservableList> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -1391,6 +1445,7 @@ public static IObservable> Except(this /// The source. /// An observable which emits change sets. public static IObservable> Except(this IObservableList> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -1416,6 +1471,7 @@ public static IObservable> Except(this /// timeSelector. /// public static IObservable> ExpireAfter(this IObservable> source, Func timeSelector) + where TObject : notnull where TKey : notnull { return ExpireAfter(source, timeSelector, Scheduler.Default); @@ -1437,6 +1493,7 @@ public static IObservable> ExpireAfter( /// timeSelector. /// public static IObservable> ExpireAfter(this IObservable> source, Func timeSelector, IScheduler scheduler) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1468,6 +1525,7 @@ public static IObservable> ExpireAfter( /// or /// timeSelector. public static IObservable> ExpireAfter(this IObservable> source, Func timeSelector, TimeSpan? pollingInterval) + where TObject : notnull where TKey : notnull { return ExpireAfter(source, timeSelector, pollingInterval, Scheduler.Default); @@ -1490,6 +1548,7 @@ public static IObservable> ExpireAfter( /// or /// timeSelector. public static IObservable> ExpireAfter(this IObservable> source, Func timeSelector, TimeSpan? pollingInterval, IScheduler scheduler) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1519,6 +1578,7 @@ public static IObservable> ExpireAfter( /// or /// timeSelector. public static IObservable>> ExpireAfter(this ISourceCache source, Func timeSelector, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { return source.ExpireAfter(timeSelector, null, scheduler); @@ -1540,6 +1600,7 @@ public static IObservable>> ExpireAfter< /// or /// timeSelector. public static IObservable>> ExpireAfter(this ISourceCache source, Func timeSelector, TimeSpan? interval = null) + where TObject : notnull where TKey : notnull { return ExpireAfter(source, timeSelector, interval, Scheduler.Default); @@ -1553,6 +1614,7 @@ public static IObservable>> ExpireAfter< /// The type of the key. /// A changeset which guarantees a key is only present at most once in the changeset. public static IObservable> EnsureUniqueKeys(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source == null) @@ -1581,6 +1643,7 @@ public static IObservable> EnsureUniqueKeys [SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Deliberate capture.")] public static IObservable>> ExpireAfter(this ISourceCache source, Func timeSelector, TimeSpan? pollingInterval, IScheduler? scheduler) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1631,6 +1694,7 @@ public static IObservable>> ExpireAfter< /// By default empty changeset notifications are suppressed for performance reasons. Set to false to publish empty changesets. Doing so can be useful for monitoring loading status. /// An observable which emits change sets. public static IObservable> Filter(this IObservable> source, Func filter, bool suppressEmptyChangeSets = true) + where TObject : notnull where TKey : notnull { if (source is null) throw new ArgumentNullException(nameof(source)); @@ -1648,6 +1712,7 @@ public static IObservable> Filter(this /// By default empty changeset notifications are suppressed for performance reasons. Set to false to publish empty changesets. Doing so can be useful for monitoring loading status. /// An observable which emits change sets. public static IObservable> Filter(this IObservable> source, IObservable> predicateChanged, bool suppressEmptyChangeSets = true) + where TObject : notnull where TKey : notnull { if (source is null) throw new ArgumentNullException(nameof(source)); @@ -1666,6 +1731,7 @@ public static IObservable> Filter(this /// By default empty changeset notifications are suppressed for performance reasons. Set to false to publish empty changesets. Doing so can be useful for monitoring loading status. /// An observable which emits change sets. public static IObservable> Filter(this IObservable> source, IObservable reapplyFilter, bool suppressEmptyChangeSets = true) + where TObject : notnull where TKey : notnull { if (source is null) throw new ArgumentNullException(nameof(source)); @@ -1685,6 +1751,7 @@ public static IObservable> Filter(this /// By default empty changeset notifications are suppressed for performance reasons. Set to false to publish empty changesets. Doing so can be useful for monitoring loading status. /// An observable which emits change sets. public static IObservable> Filter(this IObservable> source, IObservable> predicateChanged, IObservable reapplyFilter, bool suppressEmptyChangeSets = true) + where TObject : notnull where TKey : notnull { if (source is null) throw new ArgumentNullException(nameof(source)); @@ -1710,8 +1777,8 @@ public static IObservable> Filter(this /// An observable which emits change sets. [Obsolete("Use AutoRefresh(), followed by Filter() instead")] public static IObservable> FilterOnProperty(this IObservable> source, Expression> propertySelector, Func predicate, TimeSpan? propertyChangedThrottle = null, IScheduler? scheduler = null) - where TKey : notnull where TObject : INotifyPropertyChanged + where TKey : notnull { if (source is null) { @@ -1764,6 +1831,7 @@ public static IObservable FinallySafe(this IObservable source, Action f /// An observable which emits change set values on a flatten result. /// source. public static IObservable> Flatten(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1782,6 +1850,7 @@ public static IObservable> Flatten(this IOb /// The source. /// An observable which emits change sets. public static IObservable> FlattenBufferResult(this IObservable>> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1801,6 +1870,7 @@ public static IObservable> FlattenBufferResultThe action. /// An observable which will perform the action on each item. public static IObservable> ForEachChange(this IObservable> source, Action> action) + where TObject : notnull where TKey : notnull { if (source is null) @@ -1831,8 +1901,11 @@ public static IObservable> ForEachChangeThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> FullJoin(this IObservable> left, IObservable> right, Func rightKeySelector, Func, Optional, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -1872,8 +1945,11 @@ public static IObservable> FullJoinThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> FullJoin(this IObservable> left, IObservable> right, Func rightKeySelector, Func, Optional, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -1913,8 +1989,11 @@ public static IObservable> FullJoinThe result selector.used to transform the combined data into. Example (left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> FullJoinMany(this IObservable> left, IObservable> right, Func rightKeySelector, Func, IGrouping, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -1954,8 +2033,11 @@ public static IObservable> FullJoinManyThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> FullJoinMany(this IObservable> left, IObservable> right, Func rightKeySelector, Func, IGrouping, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -1997,6 +2079,7 @@ public static IObservable> FullJoinMany /// An observable which will emit group change sets. public static IObservable> Group(this IObservable> source, Func groupSelector, IObservable> resultGroupSource) + where TObject : notnull where TKey : notnull where TGroupKey : notnull { @@ -2028,6 +2111,7 @@ public static IObservable> GroupThe group selector key. /// An observable which will emit group change sets. public static IObservable> Group(this IObservable> source, Func groupSelectorKey) + where TObject : notnull where TKey : notnull where TGroupKey : notnull { @@ -2062,6 +2146,7 @@ public static IObservable> Group public static IObservable> Group(this IObservable> source, Func groupSelectorKey, IObservable regrouper) + where TObject : notnull where TKey : notnull where TGroupKey : notnull { @@ -2163,6 +2248,7 @@ public static IObservable> Gr /// groupController. /// public static IObservable> GroupWithImmutableState(this IObservable> source, Func groupSelectorKey, IObservable? regrouper = null) + where TObject : notnull where TKey : notnull where TGroupKey : notnull { @@ -2187,6 +2273,7 @@ public static IObservable> Gr /// The source observable which emits change sets. /// An observable which emits change sets and ignores equal value changes. public static IObservable> IgnoreSameReferenceUpdate(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.IgnoreUpdateWhen((c, p) => ReferenceEquals(c, p)); @@ -2202,6 +2289,7 @@ public static IObservable> IgnoreSameReferenceUpdateThe ignore function (current,previous)=>{ return true to ignore }. /// An observable which emits change sets and ignores updates equal to the lambda. public static IObservable> IgnoreUpdateWhen(this IObservable> source, Func ignoreFunction) + where TObject : notnull where TKey : notnull { return source.Select( @@ -2231,6 +2319,7 @@ public static IObservable> IgnoreUpdateWhenThe include function (current,previous)=>{ return true to include }. /// An observable which emits change sets and ignores updates equal to the lambda. public static IObservable> IncludeUpdateWhen(this IObservable> source, Func includeFunction) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2266,8 +2355,11 @@ public static IObservable> IncludeUpdateWhenThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> InnerJoin(this IObservable> left, IObservable> right, Func rightKeySelector, Func resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -2307,8 +2399,11 @@ public static IObservable> IncludeUpdateWhenThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> InnerJoin(this IObservable> left, IObservable> right, Func rightKeySelector, Func<(TLeftKey leftKey, TRightKey rightKey), TLeft, TRight, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -2348,8 +2443,11 @@ public static IObservable> IncludeUpdateWhenThe result selector.used to transform the combined data into. Example (left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> InnerJoinMany(this IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -2389,8 +2487,11 @@ public static IObservable> InnerJoinManyThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> InnerJoinMany(this IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -2443,8 +2544,11 @@ public static IObservable> InvokeEvaluateThe result selector.used to transform the combined data into. Example (left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> LeftJoin(this IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -2483,8 +2587,11 @@ public static IObservable> LeftJoinThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> LeftJoin(this IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -2524,8 +2631,11 @@ public static IObservable> LeftJoinThe result selector.used to transform the combined data into. Example (left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> LeftJoinMany(this IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -2565,8 +2675,11 @@ public static IObservable> LeftJoinManyThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> LeftJoinMany(this IObservable> left, IObservable> right, Func rightKeySelector, Func, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -2603,6 +2716,7 @@ public static IObservable> LeftJoinManysource. /// size cannot be zero. public static IObservable> LimitSizeTo(this IObservable> source, int size) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2631,6 +2745,7 @@ public static IObservable> LimitSizeTo( /// source. /// Size limit must be greater than zero. public static IObservable>> LimitSizeTo(this ISourceCache source, int sizeLimit, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2679,6 +2794,7 @@ public static IObservable>> LimitSizeTo< /// or /// observableSelector. public static IObservable MergeMany(this IObservable> source, Func> observableSelector) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2708,6 +2824,7 @@ public static IObservable MergeMany(t /// or /// observableSelector. public static IObservable MergeMany(this IObservable> source, Func> observableSelector) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2737,6 +2854,7 @@ public static IObservable MergeMany(t /// or /// observableSelector. public static IObservable> MergeManyItems(this IObservable> source, Func> observableSelector) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2766,6 +2884,7 @@ public static IObservable> MergeManyItems public static IObservable> MergeManyItems(this IObservable> source, Func> observableSelector) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2802,6 +2921,7 @@ public static IObservable MonitorStatus(this IObservable /// An observable which emits change set values when not empty. /// source. public static IObservable> NotEmpty(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2821,6 +2941,7 @@ public static IObservable> NotEmpty(thi /// The add action. /// An observable which emits a change set with items being added. public static IObservable> OnItemAdded(this IObservable> source, Action addAction) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2845,6 +2966,7 @@ public static IObservable> OnItemAdded( /// The refresh action. /// An observable which emits a change set with items being added. public static IObservable> OnItemRefreshed(this IObservable> source, Action refreshAction) + where TObject : notnull where TKey : notnull { Action refreshAction2 = refreshAction; @@ -2882,6 +3004,7 @@ public static IObservable> OnItemRefreshed public static IObservable> OnItemRemoved(this IObservable> source, Action removeAction, bool invokeOnUnsubscribe = true) + where TObject : notnull where TKey : notnull { if (source is null) throw new ArgumentNullException(nameof(source)); @@ -2899,6 +3022,7 @@ public static IObservable> OnItemRemovedThe update action. /// An observable which emits a change set with items being updated. public static IObservable> OnItemUpdated(this IObservable> source, Action updateAction) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2928,6 +3052,7 @@ public static IObservable> OnItemUpdated public static IObservable> Or(this IObservable> source, params IObservable>[] others) + where TObject : notnull where TKey : notnull { if (source is null) @@ -2956,6 +3081,7 @@ public static IObservable> Or(this IObs /// others. /// public static IObservable> Or(this ICollection>> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -2975,6 +3101,7 @@ public static IObservable> Or(this ICol /// The source. /// An observable which emits change sets. public static IObservable> Or(this IObservableList>> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -2994,6 +3121,7 @@ public static IObservable> Or(this IObs /// The source. /// An observable which emits change sets. public static IObservable> Or(this IObservableList> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -3013,6 +3141,7 @@ public static IObservable> Or(this IObs /// The source. /// An observable which emits change sets. public static IObservable> Or(this IObservableList> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -3032,6 +3161,7 @@ public static IObservable> Or(this IObs /// The page requests. /// An observable which emits change sets. public static IObservable> Page(this IObservable> source, IObservable pageRequests) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3061,6 +3191,7 @@ public static IObservable> Page(th /// keySelector. /// public static IDisposable PopulateFrom(this ISourceCache source, IObservable> observable) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3085,6 +3216,7 @@ public static IDisposable PopulateFrom(this ISourceCache public static IDisposable PopulateFrom(this ISourceCache source, IObservable observable) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3109,6 +3241,7 @@ public static IDisposable PopulateFrom(this ISourceCache public static IDisposable PopulateInto(this IObservable> source, ISourceCache destination) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3136,6 +3269,7 @@ public static IDisposable PopulateInto(this IObservable public static IDisposable PopulateInto(this IObservable> source, IIntermediateCache destination) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3160,6 +3294,7 @@ public static IDisposable PopulateInto(this IObservableThe destination. /// A disposable which will unsubscribe from the source. public static IDisposable PopulateInto(this IObservable> source, LockFreeObservableCache destination) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3190,6 +3325,7 @@ public static IDisposable PopulateInto(this IObservable public static IObservable QueryWhenChanged(this IObservable> source, Func, TDestination> resultSelector) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3214,6 +3350,7 @@ public static IObservable QueryWhenChangedAn observable which emits the query. /// source. public static IObservable> QueryWhenChanged(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3235,6 +3372,7 @@ public static IObservable> QueryWhenChanged /// An observable that emits the query. /// source. public static IObservable> QueryWhenChanged(this IObservable> source, Func> itemChangedTrigger) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3258,6 +3396,7 @@ public static IObservable> QueryWhenChangedThe source. /// An observable which emits change sets that are ref counted. public static IObservable> RefCount(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3277,6 +3416,7 @@ public static IObservable> RefCount(thi /// The item. /// source. public static void Refresh(this ISourceCache source, TObject item) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3296,6 +3436,7 @@ public static void Refresh(this ISourceCache sourc /// The items. /// source. public static void Refresh(this ISourceCache source, IEnumerable items) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3314,6 +3455,7 @@ public static void Refresh(this ISourceCache sourc /// The source. /// source. public static void Refresh(this ISourceCache source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3335,6 +3477,7 @@ public static void Refresh(this ISourceCache sourc /// The item. /// source. public static void Remove(this ISourceCache source, TObject item) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3355,6 +3498,7 @@ public static void Remove(this ISourceCache source /// The key. /// source. public static void Remove(this ISourceCache source, TKey key) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3376,6 +3520,7 @@ public static void Remove(this ISourceCache source /// The items. /// source. public static void Remove(this ISourceCache source, IEnumerable items) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3397,6 +3542,7 @@ public static void Remove(this ISourceCache source /// The keys. /// source. public static void Remove(this ISourceCache source, IEnumerable keys) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3417,6 +3563,7 @@ public static void Remove(this ISourceCache source /// The key. /// source. public static void Remove(this IIntermediateCache source, TKey key) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3438,6 +3585,7 @@ public static void Remove(this IIntermediateCache /// The keys. /// source. public static void Remove(this IIntermediateCache source, IEnumerable keys) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3459,6 +3607,7 @@ public static void Remove(this IIntermediateCache /// The source. /// An observable which emits change sets. public static IObservable> RemoveKey(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3484,6 +3633,7 @@ public static IObservable> RemoveKey(this IOb /// The key. /// source. public static void RemoveKey(this ISourceCache source, TKey key) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3504,6 +3654,7 @@ public static void RemoveKey(this ISourceCache sou /// The keys. /// source. public static void RemoveKeys(this ISourceCache source, IEnumerable keys) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3528,8 +3679,11 @@ public static void RemoveKeys(this ISourceCache so /// The result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> RightJoin(this IObservable> left, IObservable> right, Func rightKeySelector, Func, TRight, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -3568,8 +3722,11 @@ public static IObservable> RightJoinThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> RightJoin(this IObservable> left, IObservable> right, Func rightKeySelector, Func, TRight, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -3609,8 +3766,11 @@ public static IObservable> RightJoinThe result selector.used to transform the combined data into. Example (left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> RightJoinMany(this IObservable> left, IObservable> right, Func rightKeySelector, Func, IGrouping, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -3650,8 +3810,11 @@ public static IObservable> RightJoinManyThe result selector.used to transform the combined data into. Example (key, left, right) => new CustomObject(key, left, right). /// An observable which will emit change sets. public static IObservable> RightJoinMany(this IObservable> left, IObservable> right, Func rightKeySelector, Func, IGrouping, TDestination> resultSelector) + where TLeft : notnull where TLeftKey : notnull + where TRight : notnull where TRightKey : notnull + where TDestination : notnull { if (left is null) { @@ -3685,6 +3848,7 @@ public static IObservable> RightJoinManyAn observable which emits change sets. /// source. public static IObservable> SkipInitial(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3713,6 +3877,7 @@ public static IObservable> SkipInitial( /// comparer. /// public static IObservable> Sort(this IObservable> source, IComparer comparer, SortOptimisations sortOptimisations = SortOptimisations.None, int resetThreshold = DefaultSortResetThreshold) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3739,6 +3904,7 @@ public static IObservable> Sort(t /// The reset threshold. /// An observable which emits change sets. public static IObservable> Sort(this IObservable> source, IObservable> comparerObservable, SortOptimisations sortOptimisations = SortOptimisations.None, int resetThreshold = DefaultSortResetThreshold) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3766,6 +3932,7 @@ public static IObservable> Sort(t /// The reset threshold. /// An observable which emits change sets. public static IObservable> Sort(this IObservable> source, IObservable> comparerObservable, IObservable resorter, SortOptimisations sortOptimisations = SortOptimisations.None, int resetThreshold = DefaultSortResetThreshold) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3793,6 +3960,7 @@ public static IObservable> Sort(t /// The reset threshold. /// An observable which emits change sets. public static IObservable> Sort(this IObservable> source, IComparer comparer, IObservable resorter, SortOptimisations sortOptimisations = SortOptimisations.None, int resetThreshold = DefaultSortResetThreshold) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3825,6 +3993,7 @@ public static IObservable> SortBy SortDirection sortOrder = SortDirection.Ascending, SortOptimisations sortOptimisations = SortOptimisations.None, int resetThreshold = DefaultSortResetThreshold) + where TObject : notnull where TKey : notnull { source = source ?? throw new ArgumentNullException(nameof(source)); @@ -3848,6 +4017,7 @@ public static IObservable> SortBy /// The source observable change set. /// An observable which emits change sets. public static IObservable> StartWithEmpty(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.StartWith(ChangeSet.Empty); @@ -3861,6 +4031,7 @@ public static IObservable> StartWithEmptyThe source observable change set. /// An observable which emits sorted change sets. public static IObservable> StartWithEmpty(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.StartWith(SortedChangeSet.Empty); @@ -3874,6 +4045,7 @@ public static IObservable> StartWithEmptyThe source observable change set. /// An observable which emits virtual change sets. public static IObservable> StartWithEmpty(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.StartWith(VirtualChangeSet.Empty); @@ -3887,6 +4059,7 @@ public static IObservable> StartWithEmptyThe source observable change set. /// An observable which emits paged change sets. public static IObservable> StartWithEmpty(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.StartWith(PagedChangeSet.Empty); @@ -3901,6 +4074,7 @@ public static IObservable> StartWithEmptyThe source observable change set. /// An observable which emits group change sets. public static IObservable> StartWithEmpty(this IObservable> source) + where TObject : notnull where TKey : notnull where TGroupKey : notnull { @@ -3916,6 +4090,7 @@ public static IObservable> StartWithEm /// The source observable change set. /// An observable which emits immutable group change sets. public static IObservable> StartWithEmpty(this IObservable> source) + where TObject : notnull where TKey : notnull where TGroupKey : notnull { @@ -3963,6 +4138,7 @@ public static IObservable> StartWithItemThe key. /// An observable which emits change sets. public static IObservable> StartWithItem(this IObservable> source, TObject item, TKey key) + where TObject : notnull where TKey : notnull { if (source is null) @@ -3989,6 +4165,7 @@ public static IObservable> StartWithItem public static IObservable> SubscribeMany(this IObservable> source, Func subscriptionFactory) + where TObject : notnull where TKey : notnull { if (source is null) @@ -4019,6 +4196,7 @@ public static IObservable> SubscribeMany public static IObservable> SubscribeMany(this IObservable> source, Func subscriptionFactory) + where TObject : notnull where TKey : notnull { if (source is null) @@ -4042,6 +4220,7 @@ public static IObservable> SubscribeManyThe source observable change set. /// An observable which emits change sets. public static IObservable> SuppressRefresh(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.WhereReasonsAreNot(ChangeReason.Refresh); @@ -4060,6 +4239,7 @@ public static IObservable> SuppressRefresh public static IObservable> Switch(this IObservable> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -4083,6 +4263,7 @@ public static IObservable> Switch(this /// The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received. /// public static IObservable> Switch(this IObservable>> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -4101,6 +4282,7 @@ public static IObservable> Switch(this /// The source. /// An observable which emits the read only collection. public static IObservable> ToCollection(this IObservable> source) + where TObject : notnull where TKey : notnull { return source.QueryWhenChanged(query => new ReadOnlyCollectionLight(query.Items)); @@ -4122,6 +4304,7 @@ public static IObservable> ToCollection public static IObservable> ToObservableChangeSet(this IObservable source, Func keySelector, Func? expireAfter = null, int limitSizeTo = -1, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { if (source is null) @@ -4153,6 +4336,7 @@ public static IObservable> ToObservableChangeSet public static IObservable> ToObservableChangeSet(this IObservable> source, Func keySelector, Func? expireAfter = null, int limitSizeTo = -1, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { if (source is null) @@ -4179,6 +4363,7 @@ public static IObservable> ToObservableChangeSetsource. /// size;Size should be greater than zero. public static IObservable> Top(this IObservable> source, int size) + where TObject : notnull where TKey : notnull { if (source is null) @@ -4206,6 +4391,7 @@ public static IObservable> Top(t /// source. /// size;Size should be greater than zero. public static IObservable> Top(this IObservable> source, IComparer comparer, int size) + where TObject : notnull where TKey : notnull { if (source is null) @@ -4237,6 +4423,7 @@ public static IObservable> Top(t /// The sort order. Defaults to ascending. /// An observable which emits the read only collection. public static IObservable> ToSortedCollection(this IObservable> source, Func sort, SortDirection sortOrder = SortDirection.Ascending) + where TObject : notnull where TKey : notnull where TSortKey : notnull { @@ -4252,6 +4439,7 @@ public static IObservable> ToSortedCollectionThe sort comparer. /// An observable which emits the read only collection. public static IObservable> ToSortedCollection(this IObservable> source, IComparer comparer) + where TObject : notnull where TKey : notnull { return source.QueryWhenChanged( @@ -4279,6 +4467,8 @@ public static IObservable> ToSortedCollection public static IObservable> Transform(this IObservable> source, Func transformFactory, bool transformOnRefresh) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4310,6 +4500,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func transformFactory, bool transformOnRefresh) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4341,6 +4533,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func, TKey, TDestination> transformFactory, bool transformOnRefresh) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4372,6 +4566,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func transformFactory, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4403,6 +4599,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func transformFactory, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4434,6 +4632,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func, TKey, TDestination> transformFactory, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4470,6 +4670,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func transformFactory, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { return source.Transform((cur, _, _) => transformFactory(cur), forceTransform.ForForced()); @@ -4491,6 +4693,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func transformFactory, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4527,6 +4731,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func, TKey, TDestination> transformFactory, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4563,6 +4769,8 @@ public static IObservable> Transform public static IObservable> TransformAsync(this IObservable> source, Func> transformFactory, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4594,6 +4802,8 @@ public static IObservable> TransformAsync public static IObservable> TransformAsync(this IObservable> source, Func> transformFactory, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4625,6 +4835,8 @@ public static IObservable> TransformAsync public static IObservable> TransformAsync(this IObservable> source, Func, TKey, Task> transformFactory, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4652,8 +4864,10 @@ public static IObservable> TransformAsyncWill select a enumerable of values. /// The key selector which must be unique across all. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, Func keySelector) - where TSourceKey : notnull + where TDestination : notnull where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { return new TransformMany(source, manySelector, keySelector).Run(); } @@ -4670,8 +4884,10 @@ public static IObservable> TransformMa /// Will select a enumerable of values. /// The key selector which must be unique across all. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, Func keySelector) - where TSourceKey : notnull + where TDestination : notnull where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { return new TransformMany(source, manySelector, keySelector).Run(); } @@ -4688,8 +4904,10 @@ public static IObservable> TransformMa /// Will select a enumerable of values. /// The key selector which must be unique across all. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, Func keySelector) - where TSourceKey : notnull + where TDestination : notnull where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { return new TransformMany(source, manySelector, keySelector).Run(); } @@ -4706,8 +4924,10 @@ public static IObservable> TransformMa /// Will select an observable cache of values. /// The key selector which must be unique across all. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, Func keySelector) - where TSourceKey : notnull + where TDestination : notnull where TDestinationKey : notnull + where TSource : notnull + where TSourceKey : notnull { return new TransformMany(source, manySelector, keySelector).Run(); } @@ -4730,6 +4950,8 @@ public static IObservable> TransformMa /// or /// transformFactory. public static IObservable> TransformSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4768,6 +4990,8 @@ public static IObservable> TransformSafe public static IObservable> TransformSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4806,6 +5030,8 @@ public static IObservable> TransformSafe public static IObservable> TransformSafe(this IObservable> source, Func, TKey, TDestination> transformFactory, Action> errorHandler, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4849,6 +5075,8 @@ public static IObservable> TransformSafe public static IObservable> TransformSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { return source.TransformSafe((cur, _, _) => transformFactory(cur), errorHandler, forceTransform.ForForced()); @@ -4872,6 +5100,8 @@ public static IObservable> TransformSafe public static IObservable> TransformSafe(this IObservable> source, Func transformFactory, Action> errorHandler, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4910,6 +5140,8 @@ public static IObservable> TransformSafe public static IObservable> TransformSafe(this IObservable> source, Func, TKey, TDestination> transformFactory, Action> errorHandler, IObservable forceTransform) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4947,6 +5179,8 @@ public static IObservable> TransformSafe public static IObservable> TransformSafeAsync(this IObservable> source, Func> transformFactory, Action> errorHandler, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -4984,6 +5218,8 @@ public static IObservable> TransformSafeAsync public static IObservable> TransformSafeAsync(this IObservable> source, Func> transformFactory, Action> errorHandler, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -5021,6 +5257,8 @@ public static IObservable> TransformSafeAsync public static IObservable> TransformSafeAsync(this IObservable> source, Func, TKey, Task> transformFactory, Action> errorHandler, IObservable>? forceTransform = null) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -5051,8 +5289,8 @@ public static IObservable> TransformSafeAsyncObservable to change the underlying predicate. /// An observable which will emit change sets. public static IObservable, TKey>> TransformToTree(this IObservable> source, Func pivotOn, IObservable, bool>>? predicateChanged = null) - where TKey : notnull where TObject : class + where TKey : notnull { if (source is null) { @@ -5083,8 +5321,9 @@ public static IObservable, TKey>> TransformToTree /// or /// transformFactory. public static IObservable> TransformWithInlineUpdate(this IObservable> source, Func transformFactory, Action updateAction) - where TKey : notnull where TDestination : class + where TSource : notnull + where TKey : notnull { if (source is null) { @@ -5121,8 +5360,9 @@ public static IObservable> TransformWithInlineUpd /// or /// transformFactory. public static IObservable> TransformWithInlineUpdate(this IObservable> source, Func transformFactory, Action updateAction, Action> errorHandler) - where TKey : notnull where TDestination : class + where TSource : notnull + where TKey : notnull { if (source is null) { @@ -5155,6 +5395,7 @@ public static IObservable> TransformWithInlineUpd /// The source. /// the same SortedChangeSets, except all moves are replaced with remove + add. public static IObservable> TreatMovesAsRemoveAdd(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -5198,7 +5439,9 @@ IEnumerable> ReplaceMoves(IChangeSet items) /// An observable which boolean values indicating if true. /// source. public static IObservable TrueForAll(this IObservable> source, Func> observableSelector, Func equalityCondition) + where TObject : notnull where TKey : notnull + where TValue : notnull { return source.TrueFor(observableSelector, items => items.All(o => o.LatestValue.HasValue && equalityCondition(o.LatestValue.Value))); } @@ -5219,7 +5462,9 @@ public static IObservable TrueForAll(this IObservab /// An observable which boolean values indicating if true. /// source. public static IObservable TrueForAll(this IObservable> source, Func> observableSelector, Func equalityCondition) + where TObject : notnull where TKey : notnull + where TValue : notnull { return source.TrueFor(observableSelector, items => items.All(o => o.LatestValue.HasValue && equalityCondition(o.Item, o.LatestValue.Value))); } @@ -5245,7 +5490,9 @@ public static IObservable TrueForAll(this IObservab /// equalityCondition. /// public static IObservable TrueForAny(this IObservable> source, Func> observableSelector, Func equalityCondition) + where TObject : notnull where TKey : notnull + where TValue : notnull { return source.TrueFor(observableSelector, items => items.Any(o => o.LatestValue.HasValue && equalityCondition(o.Item, o.LatestValue.Value))); } @@ -5271,7 +5518,9 @@ public static IObservable TrueForAny(this IObservab /// equalityCondition. /// public static IObservable TrueForAny(this IObservable> source, Func> observableSelector, Func equalityCondition) + where TObject : notnull where TKey : notnull + where TValue : notnull { if (source is null) { @@ -5299,8 +5548,8 @@ public static IObservable TrueForAny(this IObservab /// The source. /// An observable which emits the sorted change set. public static IObservable> UpdateIndex(this IObservable> source) - where TKey : notnull where TObject : IIndexAware + where TKey : notnull { return source.Do(changes => changes.SortedItems.Select((update, index) => new { update, index }).ForEach(u => u.update.Value.Index = u.index)); } @@ -5315,6 +5564,7 @@ public static IObservable> UpdateIndexAn observable which will emit virtual change sets. /// source. public static IObservable> Virtualise(this IObservable> source, IObservable virtualRequests) + where TObject : notnull where TKey : notnull { if (source is null) @@ -5339,6 +5589,7 @@ public static IObservable> VirtualiseThe key. /// An observable which emits the change. public static IObservable> Watch(this IObservable> source, TKey key) + where TObject : notnull where TKey : notnull { if (source is null) @@ -5359,6 +5610,7 @@ public static IObservable> Watch(this IObse /// An observable which emits the object value. /// source. public static IObservable WatchValue(this IObservableCache source, TKey key) + where TObject : notnull where TKey : notnull { if (source is null) @@ -5379,6 +5631,7 @@ public static IObservable WatchValue(this IObservableCac /// An observable which emits the object value. /// source. public static IObservable WatchValue(this IObservable> source, TKey key) + where TObject : notnull where TKey : notnull { if (source is null) @@ -5398,8 +5651,8 @@ public static IObservable WatchValue(this IObservablespecify properties to Monitor, or omit to monitor all property changes. /// An observable which emits the object which has had a property changed. public static IObservable WhenAnyPropertyChanged(this IObservable> source, params string[] propertiesToMonitor) - where TKey : notnull where TObject : INotifyPropertyChanged + where TKey : notnull { if (source is null) { @@ -5420,8 +5673,8 @@ public static IObservable WatchValue(this IObservableif set to true [notify on initial value]. /// An observable which emits a property when it has changed. public static IObservable> WhenPropertyChanged(this IObservable> source, Expression> propertyAccessor, bool notifyOnInitialValue = true) - where TKey : notnull where TObject : INotifyPropertyChanged + where TKey : notnull { if (source is null) { @@ -5447,8 +5700,8 @@ public static IObservable> WhenPropertyChangedif set to true [notify on initial value]. /// An observable which emits a value when it has changed. public static IObservable WhenValueChanged(this IObservable> source, Expression> propertyAccessor, bool notifyOnInitialValue = true) - where TKey : notnull where TObject : INotifyPropertyChanged + where TKey : notnull { if (source is null) { @@ -5474,6 +5727,7 @@ public static IObservable> WhenPropertyChangedreasons. /// Must select at least on reason. public static IObservable> WhereReasonsAre(this IObservable> source, params ChangeReason[] reasons) + where TObject : notnull where TKey : notnull { if (reasons is null) @@ -5502,6 +5756,7 @@ public static IObservable> WhereReasonsArereasons. /// Must select at least on reason. public static IObservable> WhereReasonsAreNot(this IObservable> source, params ChangeReason[] reasons) + where TObject : notnull where TKey : notnull { if (reasons is null) @@ -5534,6 +5789,7 @@ public static IObservable> WhereReasonsAreNot public static IObservable> Xor(this IObservable> source, params IObservable>[] others) + where TObject : notnull where TKey : notnull { if (source is null) @@ -5563,6 +5819,7 @@ public static IObservable> Xor(this IOb /// others. /// public static IObservable> Xor(this ICollection>> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -5582,6 +5839,7 @@ public static IObservable> Xor(this ICo /// The source. /// An observable which emits a change set. public static IObservable> Xor(this IObservableList>> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -5601,6 +5859,7 @@ public static IObservable> Xor(this IOb /// The source. /// An observable which emits a change set. public static IObservable> Xor(this IObservableList> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -5620,6 +5879,7 @@ public static IObservable> Xor(this IOb /// The source. /// An observable which emits a change set. public static IObservable> Xor(this IObservableList> sources) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -5647,12 +5907,14 @@ public static IObservable> Xor(this IOb /// or /// timeSelector. internal static IObservable>> ForExpiry(this IObservable> source, Func timeSelector, TimeSpan? interval, IScheduler scheduler) + where TObject : notnull where TKey : notnull { return new TimeExpirer(source, timeSelector, interval, scheduler).ForExpiry(); } private static IObservable> Combine(this IObservableList> source, CombineOperator type) + where TObject : notnull where TKey : notnull { if (source is null) @@ -5670,6 +5932,7 @@ private static IObservable> Combine(thi } private static IObservable> Combine(this IObservableList> source, CombineOperator type) + where TObject : notnull where TKey : notnull { if (source is null) @@ -5687,6 +5950,7 @@ private static IObservable> Combine(thi } private static IObservable> Combine(this IObservableList>> source, CombineOperator type) + where TObject : notnull where TKey : notnull { if (source is null) @@ -5698,6 +5962,7 @@ private static IObservable> Combine(thi } private static IObservable> Combine(this ICollection>> sources, CombineOperator type) + where TObject : notnull where TKey : notnull { if (sources is null) @@ -5737,6 +6002,7 @@ void UpdateAction(IChangeSet updates) } private static IObservable> Combine(this IObservable> source, CombineOperator type, params IObservable>[] combineTarget) + where TObject : notnull where TKey : notnull { if (combineTarget is null) @@ -5802,7 +6068,9 @@ void UpdateAction(IChangeSet updates) } private static IObservable TrueFor(this IObservable> source, Func> observableSelector, Func>, bool> collectionMatcher) + where TObject : notnull where TKey : notnull + where TValue : notnull { return new TrueFor(source, observableSelector, collectionMatcher).Run(); } diff --git a/src/DynamicData/Cache/PagedChangeSet.cs b/src/DynamicData/Cache/PagedChangeSet.cs index a0b287d42..2d084daf4 100644 --- a/src/DynamicData/Cache/PagedChangeSet.cs +++ b/src/DynamicData/Cache/PagedChangeSet.cs @@ -12,6 +12,7 @@ namespace DynamicData; internal sealed class PagedChangeSet : ChangeSet, IPagedChangeSet + where TObject : notnull where TKey : notnull { public static readonly new IPagedChangeSet Empty = new PagedChangeSet(); diff --git a/src/DynamicData/Cache/SortedChangeSet.cs b/src/DynamicData/Cache/SortedChangeSet.cs index 05872f16e..5920e3703 100644 --- a/src/DynamicData/Cache/SortedChangeSet.cs +++ b/src/DynamicData/Cache/SortedChangeSet.cs @@ -11,6 +11,7 @@ namespace DynamicData; internal class SortedChangeSet : ChangeSet, ISortedChangeSet + where TObject : notnull where TKey : notnull { public static readonly new ISortedChangeSet Empty = new SortedChangeSet(); diff --git a/src/DynamicData/Cache/SourceCache.cs b/src/DynamicData/Cache/SourceCache.cs index d2fc14b25..9d424b586 100644 --- a/src/DynamicData/Cache/SourceCache.cs +++ b/src/DynamicData/Cache/SourceCache.cs @@ -16,6 +16,7 @@ namespace DynamicData; /// The type of the key. [DebuggerDisplay("SourceCache<{typeof(TObject).Name}, {typeof(TKey).Name}> ({Count} Items)")] public sealed class SourceCache : ISourceCache + where TObject : notnull where TKey : notnull { private readonly ObservableCache _innerCache; diff --git a/src/DynamicData/Cache/SourceCacheEx.cs b/src/DynamicData/Cache/SourceCacheEx.cs index e6f0a049f..76d1a1b6e 100644 --- a/src/DynamicData/Cache/SourceCacheEx.cs +++ b/src/DynamicData/Cache/SourceCacheEx.cs @@ -23,7 +23,9 @@ public static class SourceCacheEx /// The conversion factory. /// An observable which emits the change set. public static IObservable> Cast(this IObservableCache source, Func converter) + where TSource : notnull where TKey : notnull + where TDestination : notnull { if (source is null) { diff --git a/src/DynamicData/Cache/Tests/ChangeSetAggregator.cs b/src/DynamicData/Cache/Tests/ChangeSetAggregator.cs index 122ab87bf..d14176f41 100644 --- a/src/DynamicData/Cache/Tests/ChangeSetAggregator.cs +++ b/src/DynamicData/Cache/Tests/ChangeSetAggregator.cs @@ -18,6 +18,7 @@ namespace DynamicData.Tests; /// The type of the object. /// The type of the key. public class ChangeSetAggregator : IDisposable + where TObject : notnull where TKey : notnull { private readonly IDisposable _disposer; diff --git a/src/DynamicData/Cache/Tests/PagedChangeSetAggregator.cs b/src/DynamicData/Cache/Tests/PagedChangeSetAggregator.cs index 85373dec1..4a98d5d84 100644 --- a/src/DynamicData/Cache/Tests/PagedChangeSetAggregator.cs +++ b/src/DynamicData/Cache/Tests/PagedChangeSetAggregator.cs @@ -18,6 +18,7 @@ namespace DynamicData.Tests; /// The type of the object. /// The type of the key. public class PagedChangeSetAggregator : IDisposable + where TObject : notnull where TKey : notnull { private readonly IDisposable _disposer; diff --git a/src/DynamicData/Cache/Tests/SortedChangeSetAggregator.cs b/src/DynamicData/Cache/Tests/SortedChangeSetAggregator.cs index 05f41ee1f..aa8b577dc 100644 --- a/src/DynamicData/Cache/Tests/SortedChangeSetAggregator.cs +++ b/src/DynamicData/Cache/Tests/SortedChangeSetAggregator.cs @@ -18,6 +18,7 @@ namespace DynamicData.Tests; /// The type of the object. /// The type of the key. public class SortedChangeSetAggregator : IDisposable + where TObject : notnull where TKey : notnull { private readonly IDisposable _disposer; diff --git a/src/DynamicData/Cache/Tests/TestEx.cs b/src/DynamicData/Cache/Tests/TestEx.cs index d938013c0..5888a3f1a 100644 --- a/src/DynamicData/Cache/Tests/TestEx.cs +++ b/src/DynamicData/Cache/Tests/TestEx.cs @@ -20,6 +20,7 @@ public static class TestEx /// The source. /// The change set aggregator. public static ChangeSetAggregator AsAggregator(this IObservable> source) + where TObject : notnull where TKey : notnull { return new(source); @@ -52,6 +53,7 @@ public static DistinctChangeSetAggregator AsAggregator(this IObs /// The sorted change set aggregator. /// source. public static SortedChangeSetAggregator AsAggregator(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -71,6 +73,7 @@ public static SortedChangeSetAggregator AsAggregatorThe virtual change set aggregator. /// source. public static VirtualChangeSetAggregator AsAggregator(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) @@ -89,6 +92,7 @@ public static VirtualChangeSetAggregator AsAggregatorThe source. /// The paged change set aggregator. public static PagedChangeSetAggregator AsAggregator(this IObservable> source) + where TObject : notnull where TKey : notnull { if (source is null) diff --git a/src/DynamicData/Cache/Tests/VirtualChangeSetAggregator.cs b/src/DynamicData/Cache/Tests/VirtualChangeSetAggregator.cs index 12dd52b24..1c079c912 100644 --- a/src/DynamicData/Cache/Tests/VirtualChangeSetAggregator.cs +++ b/src/DynamicData/Cache/Tests/VirtualChangeSetAggregator.cs @@ -18,6 +18,7 @@ namespace DynamicData.Tests; /// The type of the object. /// The type of the key. public class VirtualChangeSetAggregator : IDisposable + where TObject : notnull where TKey : notnull { private readonly IDisposable _disposer; diff --git a/src/DynamicData/Cache/VirtualChangeSet.cs b/src/DynamicData/Cache/VirtualChangeSet.cs index 5433ca211..227261aea 100644 --- a/src/DynamicData/Cache/VirtualChangeSet.cs +++ b/src/DynamicData/Cache/VirtualChangeSet.cs @@ -11,6 +11,7 @@ namespace DynamicData; internal sealed class VirtualChangeSet : ChangeSet, IVirtualChangeSet, IEquatable> + where TObject : notnull where TKey : notnull { public static readonly new IVirtualChangeSet Empty = new VirtualChangeSet(); diff --git a/src/DynamicData/Diagnostics/DiagnosticOperators.cs b/src/DynamicData/Diagnostics/DiagnosticOperators.cs index aa0459e5a..7606c79d2 100644 --- a/src/DynamicData/Diagnostics/DiagnosticOperators.cs +++ b/src/DynamicData/Diagnostics/DiagnosticOperators.cs @@ -21,6 +21,7 @@ public static class DiagnosticOperators /// An observable which emits the change summary. /// source. public static IObservable CollectUpdateStats(this IObservable> source) + where TSource : notnull where TKey : notnull { if (source is null) @@ -54,6 +55,7 @@ public static IObservable CollectUpdateStats(this /// An observable which emits the change summary. /// source. public static IObservable CollectUpdateStats(this IObservable> source) + where TSource : notnull { if (source is null) { diff --git a/src/DynamicData/EnumerableEx.cs b/src/DynamicData/EnumerableEx.cs index 1c850b928..8bfc6f64b 100644 --- a/src/DynamicData/EnumerableEx.cs +++ b/src/DynamicData/EnumerableEx.cs @@ -29,6 +29,7 @@ public static class EnumerableEx /// or /// keySelector. public static IObservable> AsObservableChangeSet(this IEnumerable source, Func keySelector, bool completable = false) + where TObject : notnull where TKey : notnull { if (source is null) @@ -66,6 +67,7 @@ public static IObservable> AsObservableChangeSetAn observable change set. /// source. public static IObservable> AsObservableChangeSet(this IEnumerable source, bool completable = false) + where TObject : notnull { if (source is null) { diff --git a/src/DynamicData/Experimental/ExperimentalEx.cs b/src/DynamicData/Experimental/ExperimentalEx.cs index 698a93be9..8105e5549 100644 --- a/src/DynamicData/Experimental/ExperimentalEx.cs +++ b/src/DynamicData/Experimental/ExperimentalEx.cs @@ -22,6 +22,7 @@ public static class ExperimentalEx /// The watcher. /// source. public static IWatcher AsWatcher(this IObservable> source, IScheduler? scheduler = null) + where TObject : notnull where TKey : notnull { if (source is null) diff --git a/src/DynamicData/Experimental/IWatcher.cs b/src/DynamicData/Experimental/IWatcher.cs index 32b6e6bc0..b9cbcc7c0 100644 --- a/src/DynamicData/Experimental/IWatcher.cs +++ b/src/DynamicData/Experimental/IWatcher.cs @@ -12,6 +12,7 @@ namespace DynamicData.Experimental; /// The type of the object. /// The type of the key. public interface IWatcher : IDisposable + where TObject : notnull where TKey : notnull { /// diff --git a/src/DynamicData/Experimental/Watcher.cs b/src/DynamicData/Experimental/Watcher.cs index 43335e5d0..f6422a739 100644 --- a/src/DynamicData/Experimental/Watcher.cs +++ b/src/DynamicData/Experimental/Watcher.cs @@ -13,6 +13,7 @@ namespace DynamicData.Experimental; internal sealed class Watcher : IWatcher + where TObject : notnull where TKey : notnull { private readonly IDisposable _disposer; diff --git a/src/DynamicData/Kernel/EnumerableIList.cs b/src/DynamicData/Kernel/EnumerableIList.cs index 2a5e5dc0c..06834410b 100644 --- a/src/DynamicData/Kernel/EnumerableIList.cs +++ b/src/DynamicData/Kernel/EnumerableIList.cs @@ -74,6 +74,7 @@ internal static class EnumerableIList public static EnumerableIList Create(IList list) => new(list); public static EnumerableIList> Create(IChangeSet changeSet) + where TObject : notnull where TKey : notnull => Create((IList>)changeSet); } diff --git a/src/DynamicData/Kernel/OptionExtensions.cs b/src/DynamicData/Kernel/OptionExtensions.cs index 36a4b5892..4dd2ed494 100644 --- a/src/DynamicData/Kernel/OptionExtensions.cs +++ b/src/DynamicData/Kernel/OptionExtensions.cs @@ -23,6 +23,8 @@ public static class OptionExtensions /// The converted value. /// converter. public static Optional Convert(this Optional source, Func converter) + where TSource : notnull + where TDestination : notnull { if (converter is null) { @@ -47,6 +49,7 @@ public static Optional Convert(this Optiona /// fallbackConverter. /// public static TDestination? ConvertOr(this Optional source, Func converter, Func fallbackConverter) + where TSource : notnull { if (converter is null) { @@ -71,6 +74,7 @@ public static Optional Convert(this Optiona /// The selector. /// The first value or none. public static Optional FirstOrOptional(this IEnumerable source, Func selector) + where T : notnull { if (source is null) { @@ -96,6 +100,7 @@ public static Optional FirstOrOptional(this IEnumerable source, FuncThe action. /// The optional else extension. public static OptionElse IfHasValue(this Optional source, Action action) + where T : notnull { if (!source.HasValue || source.Value is null) { @@ -119,6 +124,7 @@ public static OptionElse IfHasValue(this Optional source, Action action /// The action. /// The optional else extension. public static OptionElse IfHasValue(this Optional? source, Action action) + where T : notnull { if (!source.HasValue) { @@ -150,6 +156,7 @@ public static OptionElse IfHasValue(this Optional? source, Action actio /// The key. /// The option of the looked up value. public static Optional Lookup(this IDictionary source, TKey key) + where TValue : notnull { if (source is null) { @@ -186,6 +193,7 @@ public static bool RemoveIfContained(this IDictionaryThe source. /// An enumerable of the selected items. public static IEnumerable SelectValues(this IEnumerable> source) + where T : notnull { return source.Where(t => t.HasValue && t.Value is not null).Select(t => t.Value!); } @@ -212,6 +220,7 @@ public static T ValueOr(this T? source, T defaultValue) /// If the value or a provided default. /// valueSelector. public static T ValueOr(this Optional source, Func valueSelector) + where T : notnull { if (valueSelector is null) { @@ -228,6 +237,7 @@ public static T ValueOr(this Optional source, Func valueSelector) /// The source. /// The value or default. public static T? ValueOrDefault(this Optional source) + where T : notnull { if (source.HasValue) { @@ -246,6 +256,7 @@ public static T ValueOr(this Optional source, Func valueSelector) /// The value. /// exceptionGenerator. public static T ValueOrThrow(this Optional source, Func exceptionGenerator) + where T : notnull { if (exceptionGenerator is null) { diff --git a/src/DynamicData/Kernel/Optional.cs b/src/DynamicData/Kernel/Optional.cs index 845160757..167b17dfb 100644 --- a/src/DynamicData/Kernel/Optional.cs +++ b/src/DynamicData/Kernel/Optional.cs @@ -17,6 +17,7 @@ namespace DynamicData.Kernel; [SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "Deliberate usage.")] [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Class names the same, generic differences.")] public readonly struct Optional : IEquatable> + where T : notnull { private readonly T? _value; @@ -185,7 +186,9 @@ public static class Optional /// /// The type of the item. /// The optional value. - public static Optional None() => Optional.None; + public static Optional None() + where T : notnull + => Optional.None; /// /// Wraps the specified value in an Optional container. @@ -193,5 +196,7 @@ public static class Optional /// The type of the item. /// The value. /// The optional value. - public static Optional Some(T value) => new(value); + public static Optional Some(T? value) + where T : notnull + => new(value); } diff --git a/src/DynamicData/List/Change.cs b/src/DynamicData/List/Change.cs index 607e5713b..f5ceb82db 100644 --- a/src/DynamicData/List/Change.cs +++ b/src/DynamicData/List/Change.cs @@ -12,6 +12,7 @@ namespace DynamicData; /// /// The type of the item. public sealed class Change : IEquatable> + where T : notnull { /// /// Initializes a new instance of the class. diff --git a/src/DynamicData/List/ChangeAwareList.cs b/src/DynamicData/List/ChangeAwareList.cs index d735c6dae..d3a5aed23 100644 --- a/src/DynamicData/List/ChangeAwareList.cs +++ b/src/DynamicData/List/ChangeAwareList.cs @@ -19,6 +19,7 @@ namespace DynamicData; /// The item type. /// public class ChangeAwareList : IExtendedList + where T : notnull { private readonly List _innerList; diff --git a/src/DynamicData/List/ChangeAwareListWithRefCounts.cs b/src/DynamicData/List/ChangeAwareListWithRefCounts.cs index 66fa8505b..101513370 100644 --- a/src/DynamicData/List/ChangeAwareListWithRefCounts.cs +++ b/src/DynamicData/List/ChangeAwareListWithRefCounts.cs @@ -11,6 +11,7 @@ namespace DynamicData; internal class ChangeAwareListWithRefCounts : ChangeAwareList + where T : notnull { private readonly ReferenceCountTracker _tracker = new(); diff --git a/src/DynamicData/List/ChangeSet.cs b/src/DynamicData/List/ChangeSet.cs index 93de82669..4752663ec 100644 --- a/src/DynamicData/List/ChangeSet.cs +++ b/src/DynamicData/List/ChangeSet.cs @@ -13,6 +13,7 @@ namespace DynamicData; /// /// The type of the object. public class ChangeSet : List>, IChangeSet + where T : notnull { /// /// An empty change set. diff --git a/src/DynamicData/List/ChangeSetEx.cs b/src/DynamicData/List/ChangeSetEx.cs index 2d865dec6..8b40d1b0f 100644 --- a/src/DynamicData/List/ChangeSetEx.cs +++ b/src/DynamicData/List/ChangeSetEx.cs @@ -22,6 +22,7 @@ public static class ChangeSetEx /// An enumerable of change sets. /// source. public static IEnumerable> Flatten(this IChangeSet source) + where T : notnull { if (source is null) { @@ -71,6 +72,8 @@ public static ChangeType GetChangeType(this ListChangeReason source) /// transformer. /// public static IChangeSet Transform(this IChangeSet source, Func transformer) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -103,6 +106,7 @@ public static IChangeSet Transform(this ICh /// The source. /// An enumerable of changes. public static IEnumerable> YieldWithoutIndex(this IEnumerable> source) + where T : notnull { return new WithoutIndexEnumerator(source); } @@ -115,6 +119,7 @@ public static IEnumerable> YieldWithoutIndex(this IEnumerableAn enumerable of changes. /// source. internal static IEnumerable> Unified(this IChangeSet source) + where T : notnull { if (source is null) { diff --git a/src/DynamicData/List/IChangeSet.cs b/src/DynamicData/List/IChangeSet.cs index 3d1de2891..2dbcd7d96 100644 --- a/src/DynamicData/List/IChangeSet.cs +++ b/src/DynamicData/List/IChangeSet.cs @@ -14,6 +14,7 @@ namespace DynamicData; /// /// The type of the object. public interface IChangeSet : IEnumerable>, IChangeSet + where TObject : notnull { /// /// Gets the number of updates. diff --git a/src/DynamicData/List/IChangeSetAdaptor.cs b/src/DynamicData/List/IChangeSetAdaptor.cs index 65c4fea07..86cd07d3e 100644 --- a/src/DynamicData/List/IChangeSetAdaptor.cs +++ b/src/DynamicData/List/IChangeSetAdaptor.cs @@ -9,6 +9,7 @@ namespace DynamicData; /// /// The type of the object. public interface IChangeSetAdaptor + where T : notnull { /// /// Adapts the specified change. diff --git a/src/DynamicData/List/IGroup.cs b/src/DynamicData/List/IGroup.cs index 310a9e8fd..e8677f1b0 100644 --- a/src/DynamicData/List/IGroup.cs +++ b/src/DynamicData/List/IGroup.cs @@ -10,6 +10,7 @@ namespace DynamicData; /// The type of the object. /// The type of the group. public interface IGroup + where TObject : notnull { /// /// Gets the group key. diff --git a/src/DynamicData/List/IObservableList.cs b/src/DynamicData/List/IObservableList.cs index 772204e7e..c17b5bc21 100644 --- a/src/DynamicData/List/IObservableList.cs +++ b/src/DynamicData/List/IObservableList.cs @@ -14,6 +14,7 @@ namespace DynamicData; /// /// The type of item. public interface IObservableList : IDisposable + where T : notnull { /// /// Gets the count. diff --git a/src/DynamicData/List/IPageChangeSet.cs b/src/DynamicData/List/IPageChangeSet.cs index f674e3b55..e46af024e 100644 --- a/src/DynamicData/List/IPageChangeSet.cs +++ b/src/DynamicData/List/IPageChangeSet.cs @@ -13,6 +13,7 @@ namespace DynamicData; /// /// The type of the object. public interface IPageChangeSet : IChangeSet + where T : notnull { /// /// Gets the parameters used to virtualise the stream. diff --git a/src/DynamicData/List/ISourceList.cs b/src/DynamicData/List/ISourceList.cs index c42855f01..6533064c0 100644 --- a/src/DynamicData/List/ISourceList.cs +++ b/src/DynamicData/List/ISourceList.cs @@ -13,6 +13,7 @@ namespace DynamicData; /// /// The type of the item. public interface ISourceList : IObservableList + where T : notnull { /// /// Edit the inner list within the list's internal locking mechanism. diff --git a/src/DynamicData/List/IVirtualChangeSet.cs b/src/DynamicData/List/IVirtualChangeSet.cs index fa0ff603b..754eadf9c 100644 --- a/src/DynamicData/List/IVirtualChangeSet.cs +++ b/src/DynamicData/List/IVirtualChangeSet.cs @@ -10,6 +10,7 @@ namespace DynamicData; /// /// The type of the object. public interface IVirtualChangeSet : IChangeSet + where T : notnull { /// /// Gets the parameters used to virtualise the stream. diff --git a/src/DynamicData/List/Internal/AnonymousObservableList.cs b/src/DynamicData/List/Internal/AnonymousObservableList.cs index 413db8578..71013ae5f 100644 --- a/src/DynamicData/List/Internal/AnonymousObservableList.cs +++ b/src/DynamicData/List/Internal/AnonymousObservableList.cs @@ -9,6 +9,7 @@ namespace DynamicData.List.Internal; [DebuggerDisplay("AnonymousObservableList<{typeof(T).Name}> ({Count} Items)")] internal sealed class AnonymousObservableList : IObservableList + where T : notnull { private readonly ISourceList _sourceList; private readonly IDisposable _cleanUp; diff --git a/src/DynamicData/List/Internal/AutoRefresh.cs b/src/DynamicData/List/Internal/AutoRefresh.cs index 1fee47587..328852123 100644 --- a/src/DynamicData/List/Internal/AutoRefresh.cs +++ b/src/DynamicData/List/Internal/AutoRefresh.cs @@ -13,6 +13,7 @@ namespace DynamicData.List.Internal; internal class AutoRefresh + where TObject : notnull { private readonly TimeSpan? _buffer; diff --git a/src/DynamicData/List/Internal/BufferIf.cs b/src/DynamicData/List/Internal/BufferIf.cs index a6f9cf4e7..889a460f5 100644 --- a/src/DynamicData/List/Internal/BufferIf.cs +++ b/src/DynamicData/List/Internal/BufferIf.cs @@ -11,6 +11,7 @@ namespace DynamicData.List.Internal; internal sealed class BufferIf + where T : notnull { private readonly bool _initialPauseState; diff --git a/src/DynamicData/List/Internal/Combiner.cs b/src/DynamicData/List/Internal/Combiner.cs index ceda7d6ec..92dabd8c7 100644 --- a/src/DynamicData/List/Internal/Combiner.cs +++ b/src/DynamicData/List/Internal/Combiner.cs @@ -13,6 +13,7 @@ namespace DynamicData.List.Internal; internal sealed class Combiner + where T : notnull { private readonly object _locker = new(); diff --git a/src/DynamicData/List/Internal/DeferUntilLoaded.cs b/src/DynamicData/List/Internal/DeferUntilLoaded.cs index c95e119fe..7ed9f10ab 100644 --- a/src/DynamicData/List/Internal/DeferUntilLoaded.cs +++ b/src/DynamicData/List/Internal/DeferUntilLoaded.cs @@ -10,6 +10,7 @@ namespace DynamicData.List.Internal; internal class DeferUntilLoaded + where T : notnull { private readonly IObservable> _source; diff --git a/src/DynamicData/List/Internal/Distinct.cs b/src/DynamicData/List/Internal/Distinct.cs index ddf9e55cb..598395aaf 100644 --- a/src/DynamicData/List/Internal/Distinct.cs +++ b/src/DynamicData/List/Internal/Distinct.cs @@ -12,6 +12,7 @@ namespace DynamicData.List.Internal; internal sealed class Distinct + where T : notnull where TValue : notnull { private readonly IObservable> _source; diff --git a/src/DynamicData/List/Internal/DynamicCombiner.cs b/src/DynamicData/List/Internal/DynamicCombiner.cs index 013bcad9f..989612b64 100644 --- a/src/DynamicData/List/Internal/DynamicCombiner.cs +++ b/src/DynamicData/List/Internal/DynamicCombiner.cs @@ -14,6 +14,7 @@ namespace DynamicData.List.Internal; internal sealed class DynamicCombiner + where T : notnull { private readonly object _locker = new(); diff --git a/src/DynamicData/List/Internal/EditDiff.cs b/src/DynamicData/List/Internal/EditDiff.cs index 23e89c1e1..3ae9ad156 100644 --- a/src/DynamicData/List/Internal/EditDiff.cs +++ b/src/DynamicData/List/Internal/EditDiff.cs @@ -11,6 +11,7 @@ namespace DynamicData.List.Internal; internal class EditDiff + where T : notnull { private readonly IEqualityComparer _equalityComparer; diff --git a/src/DynamicData/List/Internal/ExpireAfter.cs b/src/DynamicData/List/Internal/ExpireAfter.cs index 08771888a..ec26958ec 100644 --- a/src/DynamicData/List/Internal/ExpireAfter.cs +++ b/src/DynamicData/List/Internal/ExpireAfter.cs @@ -15,6 +15,7 @@ namespace DynamicData.List.Internal; internal sealed class ExpireAfter + where T : notnull { private readonly Func _expireAfter; diff --git a/src/DynamicData/List/Internal/Filter.cs b/src/DynamicData/List/Internal/Filter.cs index 3192ec643..dfcc9e493 100644 --- a/src/DynamicData/List/Internal/Filter.cs +++ b/src/DynamicData/List/Internal/Filter.cs @@ -12,6 +12,7 @@ namespace DynamicData.List.Internal; internal class Filter + where T : notnull { private readonly ListFilterPolicy _policy; diff --git a/src/DynamicData/List/Internal/FilterOnObservable.cs b/src/DynamicData/List/Internal/FilterOnObservable.cs index 04f9e55a6..591bebe2e 100644 --- a/src/DynamicData/List/Internal/FilterOnObservable.cs +++ b/src/DynamicData/List/Internal/FilterOnObservable.cs @@ -12,6 +12,7 @@ namespace DynamicData.List.Internal; internal class FilterOnObservable + where TObject : notnull { private readonly TimeSpan? _buffer; diff --git a/src/DynamicData/List/Internal/FilterStatic.cs b/src/DynamicData/List/Internal/FilterStatic.cs index 94a261fa1..30cd463ed 100644 --- a/src/DynamicData/List/Internal/FilterStatic.cs +++ b/src/DynamicData/List/Internal/FilterStatic.cs @@ -9,6 +9,7 @@ namespace DynamicData.List.Internal; internal class FilterStatic + where T : notnull { private readonly Func _predicate; diff --git a/src/DynamicData/List/Internal/Group.cs b/src/DynamicData/List/Internal/Group.cs index a072d148e..76763f521 100644 --- a/src/DynamicData/List/Internal/Group.cs +++ b/src/DynamicData/List/Internal/Group.cs @@ -8,6 +8,7 @@ namespace DynamicData.List.Internal; internal class Group : IGroup, IDisposable, IEquatable> + where TObject : notnull { public Group(TGroup groupKey) => GroupKey = groupKey; diff --git a/src/DynamicData/List/Internal/GroupOn.cs b/src/DynamicData/List/Internal/GroupOn.cs index d6428bc5f..6281c4b52 100644 --- a/src/DynamicData/List/Internal/GroupOn.cs +++ b/src/DynamicData/List/Internal/GroupOn.cs @@ -14,6 +14,7 @@ namespace DynamicData.List.Internal; internal sealed class GroupOn + where TObject : notnull where TGroupKey : notnull { private readonly Func _groupSelector; diff --git a/src/DynamicData/List/Internal/GroupOnImmutable.cs b/src/DynamicData/List/Internal/GroupOnImmutable.cs index 84d04ab21..ace1433d8 100644 --- a/src/DynamicData/List/Internal/GroupOnImmutable.cs +++ b/src/DynamicData/List/Internal/GroupOnImmutable.cs @@ -14,6 +14,7 @@ namespace DynamicData.List.Internal; internal sealed class GroupOnImmutable + where TObject : notnull where TGroupKey : notnull { private readonly Func _groupSelector; diff --git a/src/DynamicData/List/Internal/GroupOnProperty.cs b/src/DynamicData/List/Internal/GroupOnProperty.cs index 79a0bdd96..7aa950f0c 100644 --- a/src/DynamicData/List/Internal/GroupOnProperty.cs +++ b/src/DynamicData/List/Internal/GroupOnProperty.cs @@ -13,8 +13,8 @@ namespace DynamicData.List.Internal; internal sealed class GroupOnProperty - where TGroup : notnull where TObject : INotifyPropertyChanged + where TGroup : notnull { private readonly Func _groupSelector; diff --git a/src/DynamicData/List/Internal/GroupOnPropertyWithImmutableState.cs b/src/DynamicData/List/Internal/GroupOnPropertyWithImmutableState.cs index 45cdae373..1e77630ea 100644 --- a/src/DynamicData/List/Internal/GroupOnPropertyWithImmutableState.cs +++ b/src/DynamicData/List/Internal/GroupOnPropertyWithImmutableState.cs @@ -13,8 +13,8 @@ namespace DynamicData.List.Internal; internal sealed class GroupOnPropertyWithImmutableState - where TGroup : notnull where TObject : INotifyPropertyChanged + where TGroup : notnull { private readonly Func _groupSelector; diff --git a/src/DynamicData/List/Internal/LimitSizeTo.cs b/src/DynamicData/List/Internal/LimitSizeTo.cs index fc795a972..1739895c6 100644 --- a/src/DynamicData/List/Internal/LimitSizeTo.cs +++ b/src/DynamicData/List/Internal/LimitSizeTo.cs @@ -12,6 +12,7 @@ namespace DynamicData.List.Internal; internal sealed class LimitSizeTo + where T : notnull { private readonly object _locker; diff --git a/src/DynamicData/List/Internal/MergeMany.cs b/src/DynamicData/List/Internal/MergeMany.cs index 0baf64589..853a6e790 100644 --- a/src/DynamicData/List/Internal/MergeMany.cs +++ b/src/DynamicData/List/Internal/MergeMany.cs @@ -8,6 +8,7 @@ namespace DynamicData.List.Internal; internal sealed class MergeMany + where T : notnull { private readonly Func> _observableSelector; diff --git a/src/DynamicData/List/Internal/OnBeingAdded.cs b/src/DynamicData/List/Internal/OnBeingAdded.cs index 1733b3032..9a5998530 100644 --- a/src/DynamicData/List/Internal/OnBeingAdded.cs +++ b/src/DynamicData/List/Internal/OnBeingAdded.cs @@ -10,6 +10,7 @@ namespace DynamicData.List.Internal; internal sealed class OnBeingAdded + where T : notnull { private readonly Action _callback; diff --git a/src/DynamicData/List/Internal/OnBeingRemoved.cs b/src/DynamicData/List/Internal/OnBeingRemoved.cs index 2b66cedc0..94ffe91b4 100644 --- a/src/DynamicData/List/Internal/OnBeingRemoved.cs +++ b/src/DynamicData/List/Internal/OnBeingRemoved.cs @@ -12,6 +12,7 @@ namespace DynamicData.List.Internal; internal sealed class OnBeingRemoved + where T : notnull { private readonly Action _callback; private readonly bool _invokeOnUnsubscribe; diff --git a/src/DynamicData/List/Internal/Pager.cs b/src/DynamicData/List/Internal/Pager.cs index b271d6e9f..ab4b91357 100644 --- a/src/DynamicData/List/Internal/Pager.cs +++ b/src/DynamicData/List/Internal/Pager.cs @@ -10,6 +10,7 @@ namespace DynamicData.List.Internal; internal class Pager + where T : notnull { private readonly IObservable _requests; diff --git a/src/DynamicData/List/Internal/QueryWhenChanged.cs b/src/DynamicData/List/Internal/QueryWhenChanged.cs index d1a79a1b5..277d6ab5e 100644 --- a/src/DynamicData/List/Internal/QueryWhenChanged.cs +++ b/src/DynamicData/List/Internal/QueryWhenChanged.cs @@ -11,6 +11,7 @@ namespace DynamicData.List.Internal; internal class QueryWhenChanged + where T : notnull { private readonly IObservable> _source; diff --git a/src/DynamicData/List/Internal/ReaderWriter.cs b/src/DynamicData/List/Internal/ReaderWriter.cs index 1368aded2..9129035ba 100644 --- a/src/DynamicData/List/Internal/ReaderWriter.cs +++ b/src/DynamicData/List/Internal/ReaderWriter.cs @@ -9,6 +9,7 @@ namespace DynamicData.List.Internal; internal sealed class ReaderWriter + where T : notnull { private readonly object _locker = new(); diff --git a/src/DynamicData/List/Internal/RefCount.cs b/src/DynamicData/List/Internal/RefCount.cs index b268172bc..3c3ff8201 100644 --- a/src/DynamicData/List/Internal/RefCount.cs +++ b/src/DynamicData/List/Internal/RefCount.cs @@ -9,6 +9,7 @@ namespace DynamicData.List.Internal; internal class RefCount + where T : notnull { private readonly object _locker = new(); diff --git a/src/DynamicData/List/Internal/Sort.cs b/src/DynamicData/List/Internal/Sort.cs index 77a5f9e9b..c659d174c 100644 --- a/src/DynamicData/List/Internal/Sort.cs +++ b/src/DynamicData/List/Internal/Sort.cs @@ -13,6 +13,7 @@ namespace DynamicData.List.Internal; internal sealed class Sort + where T : notnull { private readonly IObservable> _comparerObservable; diff --git a/src/DynamicData/List/Internal/SubscribeMany.cs b/src/DynamicData/List/Internal/SubscribeMany.cs index 3d4f78bc8..6880f53b2 100644 --- a/src/DynamicData/List/Internal/SubscribeMany.cs +++ b/src/DynamicData/List/Internal/SubscribeMany.cs @@ -9,6 +9,7 @@ namespace DynamicData.List.Internal; internal sealed class SubscribeMany + where T : notnull { private readonly IObservable> _source; diff --git a/src/DynamicData/List/Internal/Switch.cs b/src/DynamicData/List/Internal/Switch.cs index 88344760e..32e5db189 100644 --- a/src/DynamicData/List/Internal/Switch.cs +++ b/src/DynamicData/List/Internal/Switch.cs @@ -9,6 +9,7 @@ namespace DynamicData.List.Internal; internal sealed class Switch + where T : notnull { private readonly IObservable>> _sources; diff --git a/src/DynamicData/List/Internal/ToObservableChangeSet.cs b/src/DynamicData/List/Internal/ToObservableChangeSet.cs index 93987fd6f..8ac639a72 100644 --- a/src/DynamicData/List/Internal/ToObservableChangeSet.cs +++ b/src/DynamicData/List/Internal/ToObservableChangeSet.cs @@ -9,6 +9,7 @@ namespace DynamicData.List.Internal; internal class ToObservableChangeSet + where T : notnull { private readonly Func? _expireAfter; diff --git a/src/DynamicData/List/Internal/TransformAsync.cs b/src/DynamicData/List/Internal/TransformAsync.cs index c502509db..eff1fba91 100644 --- a/src/DynamicData/List/Internal/TransformAsync.cs +++ b/src/DynamicData/List/Internal/TransformAsync.cs @@ -10,6 +10,8 @@ namespace DynamicData.List.Internal; internal class TransformAsync + where TSource : notnull + where TDestination : notnull { private readonly Func, int, Task.TransformedItemContainer>> _containerFactory; diff --git a/src/DynamicData/List/Internal/TransformMany.cs b/src/DynamicData/List/Internal/TransformMany.cs index 2ff0a5ef0..adfbf5deb 100644 --- a/src/DynamicData/List/Internal/TransformMany.cs +++ b/src/DynamicData/List/Internal/TransformMany.cs @@ -13,6 +13,8 @@ namespace DynamicData.List.Internal; internal sealed class TransformMany + where TSource : notnull + where TDestination : notnull { private readonly Func>>? _childChanges; diff --git a/src/DynamicData/List/Internal/Transformer.cs b/src/DynamicData/List/Internal/Transformer.cs index 7eac9d75a..80677f753 100644 --- a/src/DynamicData/List/Internal/Transformer.cs +++ b/src/DynamicData/List/Internal/Transformer.cs @@ -12,6 +12,8 @@ namespace DynamicData.List.Internal; internal sealed class Transformer + where TSource : notnull + where TDestination : notnull { private readonly Func, int, TransformedItemContainer> _containerFactory; diff --git a/src/DynamicData/List/Internal/UnifiedChange.cs b/src/DynamicData/List/Internal/UnifiedChange.cs index 96f5c8d5f..20d410d25 100644 --- a/src/DynamicData/List/Internal/UnifiedChange.cs +++ b/src/DynamicData/List/Internal/UnifiedChange.cs @@ -10,6 +10,7 @@ namespace DynamicData.List.Internal; internal readonly struct UnifiedChange : IEquatable> + where T : notnull { public UnifiedChange(ListChangeReason reason, T current) : this(reason, current, Optional.None()) diff --git a/src/DynamicData/List/Internal/Virtualiser.cs b/src/DynamicData/List/Internal/Virtualiser.cs index c08698ba2..29a5b55cb 100644 --- a/src/DynamicData/List/Internal/Virtualiser.cs +++ b/src/DynamicData/List/Internal/Virtualiser.cs @@ -8,6 +8,7 @@ namespace DynamicData.List.Internal; internal sealed class Virtualiser + where T : notnull { private readonly IObservable _requests; diff --git a/src/DynamicData/List/ItemChange.cs b/src/DynamicData/List/ItemChange.cs index 25ae2aab9..d4216aa89 100644 --- a/src/DynamicData/List/ItemChange.cs +++ b/src/DynamicData/List/ItemChange.cs @@ -15,6 +15,7 @@ namespace DynamicData; /// /// The type of the item. public readonly struct ItemChange : IEquatable> + where T : notnull { /// /// An empty change. diff --git a/src/DynamicData/List/Linq/AddKeyEnumerator.cs b/src/DynamicData/List/Linq/AddKeyEnumerator.cs index 30e8be830..484e287ca 100644 --- a/src/DynamicData/List/Linq/AddKeyEnumerator.cs +++ b/src/DynamicData/List/Linq/AddKeyEnumerator.cs @@ -9,6 +9,7 @@ namespace DynamicData.List.Linq; internal class AddKeyEnumerator : IEnumerable> + where TObject : notnull where TKey : notnull { private readonly Func _keySelector; diff --git a/src/DynamicData/List/Linq/ItemChangeEnumerator.cs b/src/DynamicData/List/Linq/ItemChangeEnumerator.cs index 918f2b84d..5b65bea0a 100644 --- a/src/DynamicData/List/Linq/ItemChangeEnumerator.cs +++ b/src/DynamicData/List/Linq/ItemChangeEnumerator.cs @@ -8,6 +8,7 @@ namespace DynamicData.List.Linq; internal class ItemChangeEnumerator : IEnumerable> + where T : notnull { private readonly IChangeSet _changeSet; diff --git a/src/DynamicData/List/Linq/Reverser.cs b/src/DynamicData/List/Linq/Reverser.cs index b6a11ce68..af4b9ca46 100644 --- a/src/DynamicData/List/Linq/Reverser.cs +++ b/src/DynamicData/List/Linq/Reverser.cs @@ -8,6 +8,7 @@ namespace DynamicData.List.Linq; internal class Reverser + where T : notnull { private int _length; diff --git a/src/DynamicData/List/Linq/UnifiedChangeEnumerator.cs b/src/DynamicData/List/Linq/UnifiedChangeEnumerator.cs index e6996e6bb..58ea38429 100644 --- a/src/DynamicData/List/Linq/UnifiedChangeEnumerator.cs +++ b/src/DynamicData/List/Linq/UnifiedChangeEnumerator.cs @@ -10,6 +10,7 @@ namespace DynamicData.List.Linq; internal class UnifiedChangeEnumerator : IEnumerable> + where T : notnull { private readonly IChangeSet _changeSet; diff --git a/src/DynamicData/List/Linq/WithoutIndexEnumerator.cs b/src/DynamicData/List/Linq/WithoutIndexEnumerator.cs index 7fe803567..b1008b34b 100644 --- a/src/DynamicData/List/Linq/WithoutIndexEnumerator.cs +++ b/src/DynamicData/List/Linq/WithoutIndexEnumerator.cs @@ -13,6 +13,7 @@ namespace DynamicData.List.Linq; /// /// The type of the item. internal class WithoutIndexEnumerator : IEnumerable> + where T : notnull { private readonly IEnumerable> _changeSet; diff --git a/src/DynamicData/List/ListEx.cs b/src/DynamicData/List/ListEx.cs index 70ae1b4dd..0a83c53ff 100644 --- a/src/DynamicData/List/ListEx.cs +++ b/src/DynamicData/List/ListEx.cs @@ -251,7 +251,8 @@ public static int BinarySearch(this IList list, TSearch v /// or /// changes. /// - public static void Clone(this IList source, IChangeSet changes) => Clone(source, changes, null); + public static void Clone(this IList source, IChangeSet changes) + where T : notnull => Clone(source, changes, null); /// /// Clones the list from the specified change set. @@ -265,7 +266,8 @@ public static int BinarySearch(this IList list, TSearch v /// or /// changes. /// - public static void Clone(this IList source, IChangeSet changes, IEqualityComparer? equalityComparer) => Clone(source, (IEnumerable>)changes, equalityComparer); + public static void Clone(this IList source, IChangeSet changes, IEqualityComparer? equalityComparer) + where T : notnull => Clone(source, (IEnumerable>)changes, equalityComparer); /// /// Clones the list from the specified enumerable of changes. @@ -280,6 +282,7 @@ public static int BinarySearch(this IList list, TSearch v /// changes. /// public static void Clone(this IList source, IEnumerable> changes, IEqualityComparer? equalityComparer) + where T : notnull { if (source is null) { @@ -554,6 +557,7 @@ public static void ReplaceOrAdd(this IList source, T original, T replaceWi /// The source. /// The change. internal static void ClearOrRemoveMany(this IList source, Change change) + where T : notnull { // apply this to other operators if (source.Count == change.Range.Count) @@ -567,6 +571,7 @@ internal static void ClearOrRemoveMany(this IList source, Change change } internal static bool MovedWithinRange(this Change source, int startIndex, int endIndex) + where T : notnull { if (source.Reason != ListChangeReason.Moved) { @@ -580,6 +585,7 @@ internal static bool MovedWithinRange(this Change source, int startIndex, } private static void Clone(this IList source, Change item, IEqualityComparer equalityComparer) + where T : notnull { var changeAware = source as ChangeAwareList; diff --git a/src/DynamicData/List/ObservableListEx.cs b/src/DynamicData/List/ObservableListEx.cs index d93f38ce6..862702d25 100644 --- a/src/DynamicData/List/ObservableListEx.cs +++ b/src/DynamicData/List/ObservableListEx.cs @@ -37,6 +37,7 @@ public static class ObservableListEx /// adaptor. /// public static IObservable> Adapt(this IObservable> source, IChangeSetAdaptor adaptor) + where T : notnull { if (source is null) { @@ -73,6 +74,7 @@ public static IObservable> Adapt(this IObservable /// The key selector. /// An observable which emits the change set. public static IObservable> AddKey(this IObservable> source, Func keySelector) + where TObject : notnull where TKey : notnull { if (source is null) @@ -97,6 +99,7 @@ public static IObservable> AddKey(this /// The others. /// An observable which emits the change set. public static IObservable> And(this IObservable> source, params IObservable>[] others) + where T : notnull { return source.Combine(CombineOperator.And, others); } @@ -109,6 +112,7 @@ public static IObservable> And(this IObservable> /// The sources. /// An observable which emits the change set. public static IObservable> And(this ICollection>> sources) + where T : notnull { return sources.Combine(CombineOperator.And); } @@ -121,6 +125,7 @@ public static IObservable> And(this ICollectionThe source. /// An observable which emits the change set. public static IObservable> And(this IObservableList>> sources) + where T : notnull { return sources.Combine(CombineOperator.And); } @@ -133,6 +138,7 @@ public static IObservable> And(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> And(this IObservableList> sources) + where T : notnull { return sources.Combine(CombineOperator.And); } @@ -145,6 +151,7 @@ public static IObservable> And(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> And(this IObservableList> sources) + where T : notnull { return sources.Combine(CombineOperator.And); } @@ -157,6 +164,7 @@ public static IObservable> And(this IObservableListAn observable list. /// source. public static IObservableList AsObservableList(this ISourceList source) + where T : notnull { if (source is null) { @@ -174,6 +182,7 @@ public static IObservableList AsObservableList(this ISourceList source) /// An observable list. /// source. public static IObservableList AsObservableList(this IObservable> source) + where T : notnull { if (source is null) { @@ -263,6 +272,7 @@ public static IObservable> AutoRefresh(t /// The scheduler. /// An observable change set with additional refresh changes. public static IObservable> AutoRefreshOnObservable(this IObservable> source, Func> reevaluator, TimeSpan? changeSetBuffer = null, IScheduler? scheduler = null) + where TObject : notnull { if (source is null) { @@ -291,6 +301,7 @@ public static IObservable> AutoRefreshOnObservable public static IObservable> Bind(this IObservable> source, IObservableCollection targetCollection, int resetThreshold = 25) + where T : notnull { if (source is null) { @@ -315,6 +326,7 @@ public static IObservable> Bind(this IObservable> /// The reset threshold. /// A continuation of the source stream. public static IObservable> Bind(this IObservable> source, out ReadOnlyObservableCollection readOnlyObservableCollection, int resetThreshold = 25) + where T : notnull { if (source is null) { @@ -344,6 +356,7 @@ public static IObservable> Bind(this IObservable> /// /// An observable which emits the change set. public static IObservable> Bind(this IObservable> source, BindingList bindingList, int resetThreshold = 25) + where T : notnull { if (source is null) { @@ -371,6 +384,7 @@ public static IObservable> Bind(this IObservable> /// An observable which emits the change set. /// source. public static IObservable> BufferIf(this IObservable> source, IObservable pauseIfTrueSelector, IScheduler? scheduler = null) + where T : notnull { return BufferIf(source, pauseIfTrueSelector, false, scheduler); } @@ -387,6 +401,7 @@ public static IObservable> BufferIf(this IObservableAn observable which emits the change set. /// source. public static IObservable> BufferIf(this IObservable> source, IObservable pauseIfTrueSelector, bool initialPauseState, IScheduler? scheduler = null) + where T : notnull { if (source is null) { @@ -413,6 +428,7 @@ public static IObservable> BufferIf(this IObservableAn observable which emits the change set. /// source. public static IObservable> BufferIf(this IObservable> source, IObservable pauseIfTrueSelector, TimeSpan? timeOut, IScheduler? scheduler = null) + where T : notnull { return BufferIf(source, pauseIfTrueSelector, false, timeOut, scheduler); } @@ -430,6 +446,7 @@ public static IObservable> BufferIf(this IObservableAn observable which emits the change set. /// source. public static IObservable> BufferIf(this IObservable> source, IObservable pauseIfTrueSelector, bool initialPauseState, TimeSpan? timeOut, IScheduler? scheduler = null) + where T : notnull { if (source is null) { @@ -453,6 +470,7 @@ public static IObservable> BufferIf(this IObservableThe scheduler to buffer on. /// An observable which emits the change set. public static IObservable> BufferInitial(this IObservable> source, TimeSpan initialBuffer, IScheduler? scheduler = null) + where TObject : notnull { return source.DeferUntilLoaded().Publish( shared => @@ -470,6 +488,7 @@ public static IObservable> BufferInitial(this IObse /// The source. /// An observable which emits the change set. public static IObservable> Cast(this IObservable> source) + where TDestination : notnull { if (source is null) { @@ -490,6 +509,8 @@ public static IObservable> Cast(this IObs /// The conversion factory. /// An observable which emits the change set. public static IObservable> Cast(this IObservable> source, Func conversionFactory) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -510,9 +531,10 @@ public static IObservable> Cast( /// The type of the item. /// The source. /// An observable which emits the change set. - public static IObservable> CastToObject(this IObservable> source) + public static IObservable> CastToObject(this IObservable> source) + where T : class { - return source.Select(changes => changes.Transform(t => (object?)t)); + return source.Select(changes => changes.Transform(t => (object)t)); } /// @@ -524,6 +546,7 @@ public static IObservable> Cast( /// An observable which emits the change set. /// source. public static IObservable> Clone(this IObservable> source, IList target) + where T : notnull { if (source is null) { @@ -545,6 +568,8 @@ public static IObservable> Clone(this IObservable /// An observable which emits the change set. [Obsolete("Prefer Cast as it is does the same thing but is semantically correct")] public static IObservable> Convert(this IObservable> source, Func conversionFactory) + where TObject : notnull + where TDestination : notnull { if (source is null) { @@ -566,6 +591,7 @@ public static IObservable> ConvertThe source. /// An observable which emits the change set. public static IObservable> DeferUntilLoaded(this IObservable> source) + where T : notnull { if (source is null) { @@ -582,6 +608,7 @@ public static IObservable> DeferUntilLoaded(this IObservableThe source. /// An observable which emits the change set. public static IObservable> DeferUntilLoaded(this IObservableList source) + where T : notnull { if (source is null) { @@ -602,6 +629,7 @@ public static IObservable> DeferUntilLoaded(this IObservableLis /// A continuation of the original stream. /// source. public static IObservable> DisposeMany(this IObservable> source) + where T : notnull { return source.OnItemRemoved( t => @@ -625,6 +653,7 @@ public static IObservable> DisposeMany(this IObservable public static IObservable> DistinctValues(this IObservable> source, Func valueSelector) + where TObject : notnull where TValue : notnull { if (source is null) @@ -649,6 +678,7 @@ public static IObservable> DistinctValues(th /// The others. /// An observable which emits the change set. public static IObservable> Except(this IObservable> source, params IObservable>[] others) + where T : notnull { return source.Combine(CombineOperator.Except, others); } @@ -661,6 +691,7 @@ public static IObservable> Except(this IObservableThe sources. /// An observable which emits the change set. public static IObservable> Except(this ICollection>> sources) + where T : notnull { return sources.Combine(CombineOperator.Except); } @@ -672,6 +703,7 @@ public static IObservable> Except(this ICollectionThe source. /// An observable which emits the change set. public static IObservable> Except(this IObservableList>> sources) + where T : notnull { return sources.Combine(CombineOperator.Except); } @@ -683,6 +715,7 @@ public static IObservable> Except(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Except(this IObservableList> sources) + where T : notnull { return sources.Combine(CombineOperator.Except); } @@ -694,6 +727,7 @@ public static IObservable> Except(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Except(this IObservableList> sources) + where T : notnull { return sources.Combine(CombineOperator.Except); } @@ -707,6 +741,7 @@ public static IObservable> Except(this IObservableListThe scheduler. /// An observable which emits the enumerable of items. public static IObservable> ExpireAfter(this ISourceList source, Func timeSelector, IScheduler? scheduler = null) + where T : notnull { return source.ExpireAfter(timeSelector, null, scheduler); } @@ -721,6 +756,7 @@ public static IObservable> ExpireAfter(this ISourceList sou /// The scheduler. /// An observable which emits the enumerable of items. public static IObservable> ExpireAfter(this ISourceList source, Func timeSelector, TimeSpan? pollingInterval = null, IScheduler? scheduler = null) + where T : notnull { if (source is null) { @@ -747,6 +783,7 @@ public static IObservable> ExpireAfter(this ISourceList sou /// An observable which emits the change set. /// source. public static IObservable> Filter(this IObservable> source, Func predicate) + where T : notnull { if (source is null) { @@ -773,6 +810,7 @@ public static IObservable> Filter(this IObservable public static IObservable> Filter(this IObservable> source, IObservable> predicate, ListFilterPolicy filterPolicy = ListFilterPolicy.CalculateDiff) + where T : notnull { if (source is null) { @@ -799,6 +837,7 @@ public static IObservable> Filter(this IObservableThe scheduler used when throttling. /// An observable which emits the change set. public static IObservable> FilterOnObservable(this IObservable> source, Func> objectFilterObservable, TimeSpan? propertyChangedThrottle = null, IScheduler? scheduler = null) + where TObject : notnull { if (source is null) { @@ -850,6 +889,7 @@ public static IObservable> FilterOnPropertyThe source. /// An observable which emits the change set. public static IObservable> FlattenBufferResult(this IObservable>> source) + where T : notnull { return source.Where(x => x.Count != 0).Select(updates => new ChangeSet(updates.SelectMany(u => u))); } @@ -862,6 +902,7 @@ public static IObservable> FlattenBufferResult(this IObservable /// The action. /// An observable which emits the change set. public static IObservable> ForEachChange(this IObservable> source, Action> action) + where TObject : notnull { if (source is null) { @@ -886,6 +927,7 @@ public static IObservable> ForEachChange(this IObse /// The action. /// An observable which emits the change set. public static IObservable> ForEachItemChange(this IObservable> source, Action> action) + where TObject : notnull { if (source is null) { @@ -916,6 +958,7 @@ public static IObservable> ForEachItemChange(this I /// groupSelector. /// public static IObservable>> GroupOn(this IObservable> source, Func groupSelector, IObservable? regrouper = null) + where TObject : notnull where TGroup : notnull { if (source is null) @@ -944,8 +987,8 @@ public static IObservable>> GroupOnThe scheduler. /// An observable which emits the change set. public static IObservable>> GroupOnProperty(this IObservable> source, Expression> propertySelector, TimeSpan? propertyChangedThrottle = null, IScheduler? scheduler = null) - where TGroup : notnull where TObject : INotifyPropertyChanged + where TGroup : notnull { if (source is null) { @@ -973,8 +1016,8 @@ public static IObservable>> GroupOnPropertyThe scheduler. /// An observable which emits the change set. public static IObservable>> GroupOnPropertyWithImmutableState(this IObservable> source, Expression> propertySelector, TimeSpan? propertyChangedThrottle = null, IScheduler? scheduler = null) - where TGroup : notnull where TObject : INotifyPropertyChanged + where TGroup : notnull { if (source is null) { @@ -1005,6 +1048,7 @@ public static IObservable>> GroupOnProperty public static IObservable>> GroupWithImmutableState(this IObservable> source, Func groupSelectorKey, IObservable? regrouper = null) + where TObject : notnull where TGroupKey : notnull { if (source is null) @@ -1032,6 +1076,7 @@ public static IObservable>> GroupOnPropertysource. /// sizeLimit cannot be zero. public static IObservable> LimitSizeTo(this ISourceList source, int sizeLimit, IScheduler? scheduler = null) + where T : notnull { if (source is null) { @@ -1062,6 +1107,7 @@ public static IObservable> LimitSizeTo(this ISourceList sou /// or /// observableSelector. public static IObservable MergeMany(this IObservable> source, Func> observableSelector) + where T : notnull { if (source is null) { @@ -1084,6 +1130,7 @@ public static IObservable MergeMany(this IObserva /// An observable which emits the change set. /// source. public static IObservable> NotEmpty(this IObservable> source) + where T : notnull { if (source is null) { @@ -1101,6 +1148,7 @@ public static IObservable> NotEmpty(this IObservableThe add action. /// An observable which emits the change set. public static IObservable> OnItemAdded(this IObservable> source, Action addAction) + where T : notnull { if (source is null) { @@ -1123,6 +1171,7 @@ public static IObservable> OnItemAdded(this IObservableThe refresh action. /// An observable which emits a change set with items being added. public static IObservable> OnItemRefreshed(this IObservable> source, Action refreshAction) + where TObject : notnull { Action refreshAction2 = refreshAction; if (source == null) @@ -1158,6 +1207,7 @@ public static IObservable> OnItemRefreshed(this IOb /// removeAction. /// public static IObservable> OnItemRemoved(this IObservable> source, Action removeAction, bool invokeOnUnsubscribe = true) + where T : notnull { if (source is null) { @@ -1180,6 +1230,7 @@ public static IObservable> OnItemRemoved(this IObservableThe source. /// An observable which emits the change set. public static IObservable> Or(this ICollection>> sources) + where T : notnull { return sources.Combine(CombineOperator.Or); } @@ -1193,6 +1244,7 @@ public static IObservable> Or(this ICollectionThe others. /// An observable which emits the change set. public static IObservable> Or(this IObservable> source, params IObservable>[] others) + where T : notnull { return source.Combine(CombineOperator.Or, others); } @@ -1205,6 +1257,7 @@ public static IObservable> Or(this IObservable> s /// The source. /// An observable which emits the change set. public static IObservable> Or(this IObservableList>> sources) + where T : notnull { return sources.Combine(CombineOperator.Or); } @@ -1217,6 +1270,7 @@ public static IObservable> Or(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Or(this IObservableList> sources) + where T : notnull { return sources.Combine(CombineOperator.Or); } @@ -1229,6 +1283,7 @@ public static IObservable> Or(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Or(this IObservableList> sources) + where T : notnull { return sources.Combine(CombineOperator.Or); } @@ -1241,6 +1296,7 @@ public static IObservable> Or(this IObservableListObservable to control page requests. /// An observable which emits the change set. public static IObservable> Page(this IObservable> source, IObservable requests) + where T : notnull { if (source is null) { @@ -1268,6 +1324,7 @@ public static IObservable> Page(this IObservable public static IDisposable PopulateInto(this IObservable> source, ISourceList destination) + where T : notnull { if (source is null) { @@ -1296,6 +1353,7 @@ public static IDisposable PopulateInto(this IObservable> source /// resultSelector. /// public static IObservable QueryWhenChanged(this IObservable> source, Func, TDestination> resultSelector) + where TObject : notnull { if (source is null) { @@ -1318,6 +1376,7 @@ public static IObservable QueryWhenChanged( /// An observable which emits the read only collection. /// source. public static IObservable> QueryWhenChanged(this IObservable> source) + where T : notnull { if (source is null) { @@ -1334,6 +1393,7 @@ public static IObservable> QueryWhenChanged(this IObse /// The source. /// An observable which emits the change set. public static IObservable> RefCount(this IObservable> source) + where T : notnull { if (source is null) { @@ -1352,6 +1412,7 @@ public static IObservable> RefCount(this IObservableThe source. /// An observable which emits the change set. public static IObservable> RemoveIndex(this IObservable> source) + where T : notnull { if (source is null) { @@ -1373,6 +1434,7 @@ public static IObservable> RemoveIndex(this IObservable public static IObservable> Reverse(this IObservable> source) + where T : notnull { var reverser = new Reverser(); if (source is null) @@ -1391,6 +1453,7 @@ public static IObservable> Reverse(this IObservableAn observable which emits the change set. /// source. public static IObservable> SkipInitial(this IObservable> source) + where T : notnull { if (source is null) { @@ -1415,6 +1478,7 @@ public static IObservable> SkipInitial(this IObservable public static IObservable> Sort(this IObservable> source, IComparer comparer, SortOptions options = SortOptions.None, IObservable? resort = null, IObservable>? comparerChanged = null, int resetThreshold = 50) + where T : notnull { if (source is null) { @@ -1443,6 +1507,7 @@ public static IObservable> Sort(this IObservable> /// or /// comparer. public static IObservable> Sort(this IObservable> source, IObservable> comparerChanged, SortOptions options = SortOptions.None, IObservable? resort = null, int resetThreshold = 50) + where T : notnull { if (source is null) { @@ -1464,6 +1529,7 @@ public static IObservable> Sort(this IObservable> /// The source observable of change set values. /// An observable which emits a change set. public static IObservable> StartWithEmpty(this IObservable> source) + where T : notnull { return source.StartWith(ChangeSet.Empty); } @@ -1482,6 +1548,7 @@ public static IObservable> StartWithEmpty(this IObservable public static IObservable> SubscribeMany(this IObservable> source, Func subscriptionFactory) + where T : notnull { if (source is null) { @@ -1503,6 +1570,7 @@ public static IObservable> SubscribeMany(this IObservableThe source observable change set. /// An observable which emits the change set. public static IObservable> SuppressRefresh(this IObservable> source) + where T : notnull { if (source == null) { @@ -1529,6 +1597,7 @@ public static IObservable> SuppressRefresh(this IObservable /// is null. public static IObservable> Switch(this IObservable> sources) + where T : notnull { if (sources is null) { @@ -1551,6 +1620,7 @@ public static IObservable> Switch(this IObservable /// is null. public static IObservable> Switch(this IObservable>> sources) + where T : notnull { if (sources is null) { @@ -1567,6 +1637,7 @@ public static IObservable> Switch(this IObservableThe source. /// An observable which emits the read only collection. public static IObservable> ToCollection(this IObservable> source) + where TObject : notnull { return source.QueryWhenChanged(items => items); } @@ -1583,6 +1654,7 @@ public static IObservable> ToCollection(th /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable source, IScheduler? scheduler = null) + where T : notnull { if (source is null) { @@ -1605,6 +1677,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable source, Func expireAfter, IScheduler? scheduler = null) + where T : notnull { if (source is null) { @@ -1632,6 +1705,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable source, int limitSizeTo, IScheduler? scheduler = null) + where T : notnull { if (source is null) { @@ -1655,6 +1729,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable source, Func? expireAfter, int limitSizeTo, IScheduler? scheduler = null) + where T : notnull { if (source is null) { @@ -1676,6 +1751,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable> source, IScheduler? scheduler = null) + where T : notnull { return ToObservableChangeSet(source, null, -1, scheduler); } @@ -1693,6 +1769,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable> source, int limitSizeTo, IScheduler? scheduler = null) + where T : notnull { return ToObservableChangeSet(source, null, limitSizeTo, scheduler); } @@ -1710,6 +1787,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable> source, Func expireAfter, IScheduler? scheduler = null) + where T : notnull { return ToObservableChangeSet(source, expireAfter, 0, scheduler); } @@ -1728,6 +1806,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// or /// keySelector. public static IObservable> ToObservableChangeSet(this IObservable> source, Func? expireAfter, int limitSizeTo, IScheduler? scheduler = null) + where T : notnull { if (source is null) { @@ -1745,6 +1824,7 @@ public static IObservable> ToObservableChangeSet(this IObservab /// The number of items. /// An observable which emits the change set. public static IObservable> Top(this IObservable> source, int numberOfItems) + where T : notnull { if (source is null) { @@ -1769,6 +1849,7 @@ public static IObservable> Top(this IObservable> /// The sort order. Defaults to ascending. /// An observable which emits the read only collection. public static IObservable> ToSortedCollection(this IObservable> source, Func sort, SortDirection sortOrder = SortDirection.Ascending) + where TObject : notnull { return source.QueryWhenChanged(query => sortOrder == SortDirection.Ascending ? new ReadOnlyCollectionLight(query.OrderBy(sort)) : new ReadOnlyCollectionLight(query.OrderByDescending(sort))); } @@ -1781,6 +1862,7 @@ public static IObservable> ToSortedCollectionThe sort comparer. /// An observable which emits the read only collection. public static IObservable> ToSortedCollection(this IObservable> source, IComparer comparer) + where TObject : notnull { return source.QueryWhenChanged( query => @@ -1806,6 +1888,8 @@ public static IObservable> ToSortedCollection public static IObservable> Transform(this IObservable> source, Func transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -1835,6 +1919,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -1866,6 +1952,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func, TDestination> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -1897,6 +1985,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func, int, TDestination> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -1928,6 +2018,8 @@ public static IObservable> Transform> TransformAsync( this IObservable> source, Func> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -1959,6 +2051,8 @@ public static IObservable> TransformAsync> TransformAsync( this IObservable> source, Func> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -1990,6 +2084,8 @@ public static IObservable> TransformAsync> TransformAsync( this IObservable> source, Func, Task> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -2021,6 +2117,8 @@ public static IObservable> TransformAsync> TransformAsync( this IObservable> source, Func, int, Task> transformFactory, bool transformOnRefresh = false) + where TSource : notnull + where TDestination : notnull { if (source is null) { @@ -2050,6 +2148,8 @@ public static IObservable> TransformAsync public static IObservable> TransformMany(this IObservable> source, Func> manySelector, IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { if (source is null) { @@ -2074,6 +2174,8 @@ public static IObservable> TransformManyUsed when an item has been replaced to determine whether child items are the same as previous children. /// An observable which emits the change set. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { return new TransformMany(source, manySelector, equalityComparer).Run(); } @@ -2088,6 +2190,8 @@ public static IObservable> TransformManyUsed when an item has been replaced to determine whether child items are the same as previous children. /// An observable which emits the change set. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { return new TransformMany(source, manySelector, equalityComparer).Run(); } @@ -2102,6 +2206,8 @@ public static IObservable> TransformManyUsed when an item has been replaced to determine whether child items are the same as previous children. /// An observable which emits the change set. public static IObservable> TransformMany(this IObservable> source, Func> manySelector, IEqualityComparer? equalityComparer = null) + where TDestination : notnull + where TSource : notnull { return new TransformMany(source, manySelector, equalityComparer).Run(); } @@ -2114,6 +2220,7 @@ public static IObservable> TransformManyThe requests. /// An observable which emits the change set. public static IObservable> Virtualise(this IObservable> source, IObservable requests) + where T : notnull { if (source is null) { @@ -2207,6 +2314,7 @@ public static IObservable> WhenPropertyChangedAn observable which emits the change set. /// Must enter at least 1 reason. public static IObservable> WhereReasonsAre(this IObservable> source, params ListChangeReason[] reasons) + where T : notnull { if (reasons is null) { @@ -2236,6 +2344,7 @@ public static IObservable> WhereReasonsAre(this IObservableAn observable which emits the change set. /// Must enter at least 1 reason. public static IObservable> WhereReasonsAreNot(this IObservable> source, params ListChangeReason[] reasons) + where T : notnull { if (reasons is null) { @@ -2265,6 +2374,7 @@ public static IObservable> WhereReasonsAreNot(this IObservable< /// The others. /// An observable which emits the change set. public static IObservable> Xor(this IObservable> source, params IObservable>[] others) + where T : notnull { return source.Combine(CombineOperator.Xor, others); } @@ -2277,6 +2387,7 @@ public static IObservable> Xor(this IObservable> /// The sources. /// An observable which emits the change set. public static IObservable> Xor(this ICollection>> sources) + where T : notnull { return sources.Combine(CombineOperator.Xor); } @@ -2289,6 +2400,7 @@ public static IObservable> Xor(this ICollectionThe source. /// An observable which emits the change set. public static IObservable> Xor(this IObservableList>> sources) + where T : notnull { return sources.Combine(CombineOperator.Xor); } @@ -2301,6 +2413,7 @@ public static IObservable> Xor(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Xor(this IObservableList> sources) + where T : notnull { return sources.Combine(CombineOperator.Xor); } @@ -2313,11 +2426,13 @@ public static IObservable> Xor(this IObservableListThe source. /// An observable which emits the change set. public static IObservable> Xor(this IObservableList> sources) + where T : notnull { return sources.Combine(CombineOperator.Xor); } private static IObservable> Combine(this ICollection>> sources, CombineOperator type) + where T : notnull { if (sources is null) { @@ -2328,6 +2443,7 @@ private static IObservable> Combine(this ICollection> Combine(this IObservable> source, CombineOperator type, params IObservable>[] others) + where T : notnull { if (source is null) { @@ -2349,6 +2465,7 @@ private static IObservable> Combine(this IObservable> Combine(this IObservableList> sources, CombineOperator type) + where T : notnull { if (sources is null) { @@ -2365,6 +2482,7 @@ private static IObservable> Combine(this IObservableList> Combine(this IObservableList> sources, CombineOperator type) + where T : notnull { if (sources is null) { @@ -2381,6 +2499,7 @@ private static IObservable> Combine(this IObservableList> Combine(this IObservableList>> sources, CombineOperator type) + where T : notnull { if (sources is null) { diff --git a/src/DynamicData/List/PageChangeSet.cs b/src/DynamicData/List/PageChangeSet.cs index 4d67f83e7..2a455293a 100644 --- a/src/DynamicData/List/PageChangeSet.cs +++ b/src/DynamicData/List/PageChangeSet.cs @@ -12,6 +12,7 @@ namespace DynamicData; internal sealed class PageChangeSet : IPageChangeSet + where T : notnull { private readonly IChangeSet _virtualChangeSet; diff --git a/src/DynamicData/List/SourceList.cs b/src/DynamicData/List/SourceList.cs index 26f4c6d38..34dc73e86 100644 --- a/src/DynamicData/List/SourceList.cs +++ b/src/DynamicData/List/SourceList.cs @@ -18,6 +18,7 @@ namespace DynamicData; /// The type of the object. [DebuggerDisplay("SourceList<{typeof(T).Name}> ({Count} Items)")] public sealed class SourceList : ISourceList + where T : notnull { private readonly ISubject> _changes = new Subject>(); diff --git a/src/DynamicData/List/SourceListEditConvenienceEx.cs b/src/DynamicData/List/SourceListEditConvenienceEx.cs index 4687c5b28..458adf33e 100644 --- a/src/DynamicData/List/SourceListEditConvenienceEx.cs +++ b/src/DynamicData/List/SourceListEditConvenienceEx.cs @@ -22,6 +22,7 @@ public static class SourceListEditConvenienceEx /// The source list. /// The item to add. public static void Add(this ISourceList source, T item) + where T : notnull { if (source is null) { @@ -38,6 +39,7 @@ public static void Add(this ISourceList source, T item) /// The source. /// The items. public static void AddRange(this ISourceList source, IEnumerable items) + where T : notnull { if (source is null) { @@ -53,6 +55,7 @@ public static void AddRange(this ISourceList source, IEnumerable items) /// The item type. /// The source to clear. public static void Clear(this ISourceList source) + where T : notnull { if (source is null) { @@ -71,6 +74,7 @@ public static void Clear(this ISourceList source) /// The items to compare against and performing a delta. /// The equality comparer used to determine whether an item has changed. public static void EditDiff(this ISourceList source, IEnumerable allItems, IEqualityComparer? equalityComparer = null) + where T : notnull { if (source is null) { @@ -94,6 +98,7 @@ public static void EditDiff(this ISourceList source, IEnumerable allIte /// The index of the item. /// The item. public static void Insert(this ISourceList source, int index, T item) + where T : notnull { if (source is null) { @@ -111,6 +116,7 @@ public static void Insert(this ISourceList source, int index, T item) /// The items. /// The zero-based index at which the new elements should be inserted. public static void InsertRange(this ISourceList source, IEnumerable items, int index) + where T : notnull { if (source is null) { @@ -128,6 +134,7 @@ public static void InsertRange(this ISourceList source, IEnumerable ite /// The original. /// The destination. public static void Move(this ISourceList source, int original, int destination) + where T : notnull { if (source is null) { @@ -145,6 +152,7 @@ public static void Move(this ISourceList source, int original, int destina /// The item. /// If the item was removed. public static bool Remove(this ISourceList source, T item) + where T : notnull { bool removed = false; if (source is null) @@ -163,6 +171,7 @@ public static bool Remove(this ISourceList source, T item) /// The source. /// The index. public static void RemoveAt(this ISourceList source, int index) + where T : notnull { if (source is null) { @@ -179,6 +188,7 @@ public static void RemoveAt(this ISourceList source, int index) /// The source. /// The items to remove. public static void RemoveMany(this ISourceList source, IEnumerable itemsToRemove) + where T : notnull { if (source is null) { @@ -198,6 +208,7 @@ public static void RemoveMany(this ISourceList source, IEnumerable item /// is less than 0.-or- is less than 0. /// and do not denote a valid range of elements in the . public static void RemoveRange(this ISourceList source, int index, int count) + where T : notnull { if (source is null) { @@ -215,6 +226,7 @@ public static void RemoveRange(this ISourceList source, int index, int cou /// The original. /// The destination. public static void Replace(this ISourceList source, T original, T destination) + where T : notnull { if (source is null) { @@ -232,6 +244,7 @@ public static void Replace(this ISourceList source, T original, T destinat /// The index. /// The item. public static void ReplaceAt(this ISourceList source, int index, T item) + where T : notnull { if (source is null) { diff --git a/src/DynamicData/List/SourceListEx.cs b/src/DynamicData/List/SourceListEx.cs index 0e1e561f8..8f3067702 100644 --- a/src/DynamicData/List/SourceListEx.cs +++ b/src/DynamicData/List/SourceListEx.cs @@ -23,6 +23,8 @@ public static class SourceListEx /// The conversion factory. /// An observable which emits that change set. public static IObservable> Cast(this ISourceList source, Func conversionFactory) + where TSource : notnull + where TDestination : notnull { if (source is null) { diff --git a/src/DynamicData/List/Tests/ChangeSetAggregator.cs b/src/DynamicData/List/Tests/ChangeSetAggregator.cs index 77cf4759c..f88e93b8c 100644 --- a/src/DynamicData/List/Tests/ChangeSetAggregator.cs +++ b/src/DynamicData/List/Tests/ChangeSetAggregator.cs @@ -15,6 +15,7 @@ namespace DynamicData.Tests; /// /// The type of the object. public class ChangeSetAggregator : IDisposable + where TObject : notnull { private readonly IDisposable _disposer; diff --git a/src/DynamicData/List/Tests/ListTextEx.cs b/src/DynamicData/List/Tests/ListTextEx.cs index 34ef5d10f..def8ea346 100644 --- a/src/DynamicData/List/Tests/ListTextEx.cs +++ b/src/DynamicData/List/Tests/ListTextEx.cs @@ -19,6 +19,7 @@ public static class ListTextEx /// The type of the object. /// The change set aggregator. public static ChangeSetAggregator AsAggregator(this IObservable> source) + where T : notnull { return new(source); } diff --git a/src/DynamicData/List/VirtualChangeSet.cs b/src/DynamicData/List/VirtualChangeSet.cs index 3ce486616..ccbfbd902 100644 --- a/src/DynamicData/List/VirtualChangeSet.cs +++ b/src/DynamicData/List/VirtualChangeSet.cs @@ -10,6 +10,7 @@ namespace DynamicData; internal class VirtualChangeSet : IVirtualChangeSet + where T : notnull { private readonly IChangeSet _virtualChangeSet; diff --git a/src/DynamicData/ObservableChangeSet.cs b/src/DynamicData/ObservableChangeSet.cs index 5a6448743..4fe482b10 100644 --- a/src/DynamicData/ObservableChangeSet.cs +++ b/src/DynamicData/ObservableChangeSet.cs @@ -24,6 +24,7 @@ public static class ObservableChangeSet /// The key selector. /// The observable cache with the specified implementation for the Subscribe method. public static IObservable> Create(Func, Action> subscribe, Func keySelector) + where TObject : notnull where TKey : notnull { if (subscribe is null) @@ -54,6 +55,7 @@ public static IObservable> Create(Func< /// The key selector. /// The observable cache with the specified implementation for the Subscribe method. public static IObservable> Create(Func, IDisposable> subscribe, Func keySelector) + where TObject : notnull where TKey : notnull { if (subscribe is null) @@ -94,6 +96,7 @@ public static IObservable> Create(Func< /// The key selector. /// The observable cache with the specified implementation for the Subscribe method. public static IObservable> Create(Func, Task> subscribe, Func keySelector) + where TObject : notnull where TKey : notnull { if (subscribe is null) @@ -118,6 +121,7 @@ public static IObservable> Create(Func< /// The key selector. /// The observable cache with the specified implementation for the Subscribe method. public static IObservable> Create(Func, CancellationToken, Task> subscribe, Func keySelector) + where TObject : notnull where TKey : notnull { if (subscribe is null) @@ -159,6 +163,7 @@ public static IObservable> Create(Func< /// The key selector. /// The observable cache with the specified implementation for the Subscribe method. public static IObservable> Create(Func, Task> subscribe, Func keySelector) + where TObject : notnull where TKey : notnull { if (subscribe is null) @@ -183,6 +188,7 @@ public static IObservable> Create(Func< /// The key selector. /// The observable cache with the specified implementation for the Subscribe method. public static IObservable> Create(Func, CancellationToken, Task> subscribe, Func keySelector) + where TObject : notnull where TKey : notnull { if (subscribe is null) @@ -233,6 +239,7 @@ public static IObservable> Create(Func< /// The key selector. /// The observable cache with the specified implementation for the Subscribe method. public static IObservable> Create(Func, Task> subscribe, Func keySelector) + where TObject : notnull where TKey : notnull { if (subscribe is null) @@ -273,6 +280,7 @@ public static IObservable> Create(Func< /// The key selector. /// The observable cache with the specified implementation for the Subscribe method. public static IObservable> Create(Func, CancellationToken, Task> subscribe, Func keySelector) + where TObject : notnull where TKey : notnull { if (subscribe is null) @@ -311,6 +319,7 @@ public static IObservable> Create(Func< /// Implementation of the resulting observable list's Subscribe method. /// The observable list with the specified implementation for the Subscribe method. public static IObservable> Create(Func, Action> subscribe) + where T : notnull { if (subscribe is null) { @@ -332,6 +341,7 @@ public static IObservable> Create(Func, Action> /// Implementation of the resulting observable list's Subscribe method. /// The observable list with the specified implementation for the Subscribe method. public static IObservable> Create(Func, IDisposable> subscribe) + where T : notnull { if (subscribe is null) { @@ -372,6 +382,7 @@ public static IObservable> Create(Func, IDisposa /// Implementation of the resulting observable list's Subscribe method. /// The observable list with the specified implementation for the Subscribe method. public static IObservable> Create(Func, Task> subscribe) + where T : notnull { if (subscribe is null) { @@ -388,6 +399,7 @@ public static IObservable> Create(Func, Task Implementation of the resulting observable list's Subscribe method. /// The observable list with the specified implementation for the Subscribe method. public static IObservable> Create(Func, CancellationToken, Task> subscribe) + where T : notnull { if (subscribe is null) { @@ -431,6 +443,7 @@ public static IObservable> Create(Func, Cancella /// Implementation of the resulting observable list's Subscribe method. /// The observable list with the specified implementation for the Subscribe method. public static IObservable> Create(Func, Task> subscribe) + where T : notnull { if (subscribe is null) { @@ -447,6 +460,7 @@ public static IObservable> Create(Func, Task Implementation of the resulting observable list's Subscribe method. /// The observable list with the specified implementation for the Subscribe method. public static IObservable> Create(Func, CancellationToken, Task> subscribe) + where T : notnull { if (subscribe is null) { @@ -489,6 +503,7 @@ public static IObservable> Create(Func, Cancella /// Implementation of the resulting observable list's Subscribe method. /// The observable list with the specified implementation for the Subscribe method. public static IObservable> Create(Func, Task> subscribe) + where T : notnull { if (subscribe is null) { @@ -521,6 +536,7 @@ public static IObservable> Create(Func, Task> su /// Implementation of the resulting observable list's Subscribe method. /// The observable list with the specified implementation for the Subscribe method. public static IObservable> Create(Func, CancellationToken, Task> subscribe) + where T : notnull { if (subscribe is null) { diff --git a/src/DynamicData/Platforms/net45/PFilter.cs b/src/DynamicData/Platforms/net45/PFilter.cs index 3d50dd063..fac0f08b9 100644 --- a/src/DynamicData/Platforms/net45/PFilter.cs +++ b/src/DynamicData/Platforms/net45/PFilter.cs @@ -15,6 +15,7 @@ namespace DynamicData.PLinq { internal class PFilter + where TObject : notnull where TKey : notnull { private readonly Func _filter; @@ -70,4 +71,4 @@ protected override IEnumerable> Refresh(IEnumerable + where TObject : notnull where TKey : notnull { private readonly ParallelisationOptions _parallelisationOptions; @@ -40,4 +41,4 @@ public IObservable> Run() } } -#endif \ No newline at end of file +#endif diff --git a/src/DynamicData/Platforms/net45/PTransform.cs b/src/DynamicData/Platforms/net45/PTransform.cs index ec715e2e5..741aec5d6 100644 --- a/src/DynamicData/Platforms/net45/PTransform.cs +++ b/src/DynamicData/Platforms/net45/PTransform.cs @@ -14,6 +14,8 @@ namespace DynamicData.PLinq { internal sealed class PTransform + where TDestination : notnull + where TSource : notnull where TKey : notnull { private readonly IObservable> _source; @@ -151,4 +153,4 @@ public TransformResult(Change change, Exception error) } } -#endif \ No newline at end of file +#endif diff --git a/src/DynamicData/Platforms/net45/ParallelEx.cs b/src/DynamicData/Platforms/net45/ParallelEx.cs index bdb1c3efc..38301bae0 100644 --- a/src/DynamicData/Platforms/net45/ParallelEx.cs +++ b/src/DynamicData/Platforms/net45/ParallelEx.cs @@ -16,6 +16,7 @@ namespace DynamicData.PLinq internal static class ParallelEx { internal static ParallelQuery> Parallelise(this IChangeSet source, ParallelisationOptions option) + where TObject : notnull where TKey : notnull { switch (option.Type) @@ -79,6 +80,7 @@ internal static IEnumerable Parallelise(this IEnumerable source, Parall } internal static bool ShouldParallelise(this IChangeSet source, ParallelisationOptions option) + where TObject : notnull where TKey : notnull { return (option.Type == ParallelType.Parallelise || option.Type == ParallelType.Ordered) && (option.Threshold >= 0 && source.Count >= option.Threshold); @@ -92,4 +94,4 @@ internal static bool ShouldParallelise(this IEnumerableAn observable which emits a change set. /// source. public static IObservable> Filter(this IObservable> source, Func filter, ParallelisationOptions parallelisationOptions) + where TObject : notnull where TKey : notnull { if (source is null) @@ -52,6 +53,7 @@ public static IObservable> Filter(this /// Subscribes to each item when it is added or updates and unsubscribes when it is removed. /// public static IObservable> SubscribeMany(this IObservable> source, Func subscriptionFactory, ParallelisationOptions parallelisationOptions) + where TObject : notnull where TKey : notnull { if (source is null) @@ -88,6 +90,7 @@ public static IObservable> SubscribeMany public static IObservable> SubscribeMany(this IObservable> source, Func subscriptionFactory, ParallelisationOptions parallelisationOptions) + where TObject : notnull where TKey : notnull { if (source is null) @@ -124,6 +127,8 @@ public static IObservable> SubscribeMany public static IObservable> Transform(this IObservable> source, Func transformFactory, ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -160,6 +165,8 @@ public static IObservable> Transform public static IObservable> Transform(this IObservable> source, Func transformFactory, ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull where TKey : notnull { return new PTransform(source, (t, _, _) => transformFactory(t), parallelisationOptions).Run(); @@ -185,6 +192,8 @@ public static IObservable> Transform public static IObservable> TransformSafe(this IObservable> source, Func transformFactory, Action> errorHandler, ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull where TKey : notnull { if (source is null) @@ -230,6 +239,8 @@ public static IObservable> TransformSafe public static IObservable> TransformSafe(this IObservable> source, Func transformFactory, Action> errorHandler, ParallelisationOptions parallelisationOptions) + where TDestination : notnull + where TSource : notnull where TKey : notnull { return new PTransform(source, (t, _, k) => transformFactory(t, k), parallelisationOptions, errorHandler).Run(); @@ -237,4 +248,4 @@ public static IObservable> TransformSafe