From 8624e23d9926e40ba7feae620d14a4cf01d74d3c Mon Sep 17 00:00:00 2001 From: Ian Griffiths Date: Wed, 15 Nov 2023 16:37:49 +0000 Subject: [PATCH 1/3] Intial fast route to 0 diagnostics * disabled several entirely * fixed some easy ones --- Rx.NET/Source/Directory.build.props | 8 +++++++- .../Disposables/SingleAssignmentDisposableValue.cs | 4 ++-- Rx.NET/Source/src/System.Reactive/EventPattern.cs | 2 -- .../CompilerServices/TaskObservableMethodBuilder.cs | 3 ++- .../Tests.System.Reactive.Uwp.DeviceRunner.csproj | 4 ++-- .../Tests/Linq/Observable/CreateAsyncTest.cs | 2 -- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Rx.NET/Source/Directory.build.props b/Rx.NET/Source/Directory.build.props index 5861aeefb..05df03988 100644 --- a/Rx.NET/Source/Directory.build.props +++ b/Rx.NET/Source/Directory.build.props @@ -74,9 +74,15 @@ IDE0056 - Use of index/range syntax - relevant types not available on all targets, so we can't IDE0057 do this. + + Temporarily disabled .NET SDK 8.0 diagnostics: + IDE0290 - primary ctors + IDE0028, IDE0300, IDE301, IDE0305 - Collection expressions + CA1510 - use ArgumentNullException.ThrowIf (not available on all targets) + CA1513 - use ObjectDisposedException.ThrowIf (not available on all targets) --> - $(NoWarn);CA1001;CA2213;IDE0056;IDE0057 + $(NoWarn);CA1001;CA2213;CA1510;CA1513;IDE0056;IDE0057;IDE0290;IDE0028;IDE0300;IDE0301;IDE0305 diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposableValue.cs b/Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposableValue.cs index 8707062a5..b0032584f 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposableValue.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposableValue.cs @@ -50,10 +50,10 @@ public void Dispose() } /// - public override bool Equals(object? obj) => false; + public override readonly bool Equals(object? obj) => false; /// - public override int GetHashCode() => 0; + public override readonly int GetHashCode() => 0; #pragma warning disable IDE0060 // (Remove unused parameter.) Required part of public API public static bool operator ==(SingleAssignmentDisposableValue left, SingleAssignmentDisposableValue right) => false; diff --git a/Rx.NET/Source/src/System.Reactive/EventPattern.cs b/Rx.NET/Source/src/System.Reactive/EventPattern.cs index 00a0b00d8..a61cc4487 100644 --- a/Rx.NET/Source/src/System.Reactive/EventPattern.cs +++ b/Rx.NET/Source/src/System.Reactive/EventPattern.cs @@ -17,9 +17,7 @@ public class EventPattern : EventPattern /// /// The sender object that raised the event. /// The event data that was generated by the event. -#pragma warning disable CA2109 // (Consider making non-public.) This has long been part of the public API so we couldn't change this even if we wanted to. public EventPattern(object? sender, TEventArgs e) -#pragma warning restore CA2109 : base(sender, e) { } diff --git a/Rx.NET/Source/src/System.Reactive/Runtime/CompilerServices/TaskObservableMethodBuilder.cs b/Rx.NET/Source/src/System.Reactive/Runtime/CompilerServices/TaskObservableMethodBuilder.cs index 92b6e324a..477159ca1 100644 --- a/Rx.NET/Source/src/System.Reactive/Runtime/CompilerServices/TaskObservableMethodBuilder.cs +++ b/Rx.NET/Source/src/System.Reactive/Runtime/CompilerServices/TaskObservableMethodBuilder.cs @@ -44,8 +44,9 @@ public struct TaskObservableMethodBuilder /// The state machine instance, passed by reference. /// is null. #pragma warning disable CA1045 // (Avoid ref.) Required because this is an async method builder +#pragma warning disable IDE0251 // (Make readonly.) Not part of the standard method builder pattern. public void Start(ref TStateMachine stateMachine) -#pragma warning restore CA1045 +#pragma warning restore CA1045, IDE0251 where TStateMachine : IAsyncStateMachine { if (stateMachine == null) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj b/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj index 7a025bb0e..fc45ec7c9 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj +++ b/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj @@ -27,7 +27,7 @@ true bin\x86\Debug\ TRACE;DEBUG;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS;NO_EVENTARGS_CONSTRAINT;HAS_EDI;HAS_WINRT;HAS_PROGRESS;PREFER_ASYNC;HAS_AWAIT;HAS_APTCA;HAS_TPL46;NO_REMOTING;WINDOWS;USE_TIMER_SELF_ROOT - ;2008;0618 + ;2008;0618;IDE0003;IDE0016;IDE0017;IDE0018;IDE0019;IDE0020;IDE0028;IDE0031;IDE0032;IDE0034;IDE0037;IDE0038;IDE0039;IDE0040;IDE0044;IDE0051;IDE0052;IDE0056;IDE0057;IDE0059;IDE0060;IDE0062;IDE0063;IDE0071;IDE0074;IDE0075;IDE0076;IDE0077;IDE0079;IDE0083;IDE0090;IDE0180;IDE0290;IDE0300;IDE0305;IDE1006;IDE1056 full x86 false @@ -38,7 +38,7 @@ bin\x86\Release\ TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS;NO_EVENTARGS_CONSTRAINT;HAS_EDI;HAS_WINRT;HAS_PROGRESS;PREFER_ASYNC;HAS_AWAIT;HAS_APTCA;HAS_TPL46;NO_REMOTING;WINDOWS;USE_TIMER_SELF_ROOT true - ;2008;0618 + ;2008;0618;IDE0003;IDE0016;IDE0017;IDE0018;IDE0019;IDE0020;IDE0028;IDE0031;IDE0032;IDE0034;IDE0037;IDE0038;IDE0039;IDE0040;IDE0044;IDE0051;IDE0052;IDE0056;IDE0057;IDE0059;IDE0060;IDE0062;IDE0063;IDE0071;IDE0074;IDE0075;IDE0076;IDE0077;IDE0079;IDE0083;IDE0090;IDE0180;IDE0290;IDE0300;IDE0305;IDE1006;IDE1056 pdbonly x86 false diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/CreateAsyncTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/CreateAsyncTest.cs index a254bd8c4..b96867448 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/CreateAsyncTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/CreateAsyncTest.cs @@ -309,9 +309,7 @@ public void CreateAsync_Error2() }); } -#pragma warning disable IDE0060 // (Remove unused parameter.) This signature is expected by the test private Task Producer6(IObserver results, Exception exception, CancellationToken token) -#pragma warning restore IDE0060 { throw exception; } From da7909308901d774afb326cdbbc33f8ebc78d5d0 Mon Sep 17 00:00:00 2001 From: Ian Griffiths Date: Wed, 15 Nov 2023 18:55:04 +0000 Subject: [PATCH 2/3] Address collection expression diagnostics In most cases, we now just use the new (C# 12.0) collection expression syntax. However, we've disabled IDE0305 because it makes suggestions that aren't an obvious improvement. It wants to rewrite use of ToArray() to be a collection expression. E.g. something.ToArray() would become [.. something]. Perhaps that will seem natural once we've all got used to spreads in collection expressions, but to me (idg10) today that looks odd. --- Rx.NET/Source/Directory.build.props | 10 +++- .../ColdObservable.cs | 2 +- .../HotObservable.cs | 4 +- .../MockObserver.cs | 3 +- .../Concurrency/LocalScheduler.TimerQueue.cs | 2 +- .../Concurrency/Scheduler.Recursive.cs | 3 +- .../Concurrency/Scheduler.Services.cs | 5 +- .../Concurrency/SchedulerWrapper.cs | 8 ++- .../CodeAnalysis/NullableAttributes.cs | 4 +- .../Disposables/CompositeDisposable.cs | 4 +- .../System.Reactive/EventPatternSourceBase.cs | 3 +- .../Source/src/System.Reactive/EventSource.cs | 3 +- .../System.Reactive/Internal/ImmutableList.cs | 2 +- .../src/System.Reactive/Internal/Lookup.cs | 2 +- .../System.Reactive/Internal/SystemClock.cs | 4 +- .../src/System.Reactive/Joins/ActivePlan.cs | 2 +- .../src/System.Reactive/Joins/JoinObserver.cs | 3 +- .../System.Reactive/Linq/Observable/Buffer.cs | 18 +++--- .../System.Reactive/Linq/Observable/Delay.cs | 2 +- .../Linq/Observable/FromEventPattern.cs | 2 +- .../Linq/Observable/GroupByUntil.cs | 2 +- .../Linq/Observable/GroupJoin.cs | 8 +-- .../System.Reactive/Linq/Observable/Join.cs | 6 +- .../System.Reactive/Linq/Observable/MaxBy.cs | 4 +- .../System.Reactive/Linq/Observable/Merge.cs | 4 +- .../System.Reactive/Linq/Observable/MinBy.cs | 4 +- .../Linq/Observable/SelectMany.cs | 8 +-- .../Linq/Observable/ToArray.cs | 3 +- .../System.Reactive/Linq/Observable/ToList.cs | 3 +- .../System.Reactive/Linq/Observable/Zip.cs | 2 +- .../src/System.Reactive/ListObservable.cs | 2 +- .../System.Reactive/Subjects/AsyncSubject.cs | 4 +- .../src/System.Reactive/Subjects/Subject.cs | 4 +- ...ts.System.Reactive.Uwp.DeviceRunner.csproj | 4 +- .../Tests.System.Reactive/MockEnumerable.cs | 2 +- .../Tests/Concurrency/SchedulerTest.cs | 2 +- .../Tests/Internal/HalfSerializerTest.cs | 2 +- .../Tests/LicenseHeaderTest.cs | 5 +- .../Tests/Linq/Observable/AutoConnectTest.cs | 4 +- .../Tests/Linq/Observable/DelayTest.cs | 2 +- .../Tests/Linq/Observable/ForkJoinTest.cs | 2 +- .../Tests/Linq/Observable/MergeTest.cs | 8 +-- .../Tests/Linq/Observable/RepeatWhenTest.cs | 2 +- .../Tests/Linq/Observable/RetryWhenTest.cs | 4 +- .../Tests/Linq/Observable/SelectManyTest.cs | 56 +++++++++---------- .../Tests/Linq/Observable/TimerTest.cs | 11 +--- .../Tests/Linq/Observable/UsingAsyncTest.cs | 2 +- .../Tests/Linq/QbservableTest.cs | 6 +- .../Tests.System.Reactive/Tests/MySubject.cs | 2 +- .../Tests/PrivateTypesTest.cs | 14 ++--- .../Tests/SystemClockTest.cs | 4 +- 51 files changed, 132 insertions(+), 140 deletions(-) diff --git a/Rx.NET/Source/Directory.build.props b/Rx.NET/Source/Directory.build.props index 05df03988..7bbc37a5a 100644 --- a/Rx.NET/Source/Directory.build.props +++ b/Rx.NET/Source/Directory.build.props @@ -75,14 +75,20 @@ IDE0056 - Use of index/range syntax - relevant types not available on all targets, so we can't IDE0057 do this. + IDE0305 - Suggests Collection expressions in place of .ToArray. E.g, wants to change this: + _readyList.ToArray() + to this: + [.. readyList] + This won't improve performance as far as we know (sometimes a reason for using that + syntax), and it's not obviously an improvement in readability. + Temporarily disabled .NET SDK 8.0 diagnostics: IDE0290 - primary ctors - IDE0028, IDE0300, IDE301, IDE0305 - Collection expressions CA1510 - use ArgumentNullException.ThrowIf (not available on all targets) CA1513 - use ObjectDisposedException.ThrowIf (not available on all targets) --> - $(NoWarn);CA1001;CA2213;CA1510;CA1513;IDE0056;IDE0057;IDE0290;IDE0028;IDE0300;IDE0301;IDE0305 + $(NoWarn);CA1001;CA2213;CA1510;CA1513;IDE0056;IDE0057;IDE0290;IDE0305 diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/ColdObservable.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/ColdObservable.cs index fccbb2d0f..1721d3155 100644 --- a/Rx.NET/Source/src/Microsoft.Reactive.Testing/ColdObservable.cs +++ b/Rx.NET/Source/src/Microsoft.Reactive.Testing/ColdObservable.cs @@ -13,7 +13,7 @@ internal class ColdObservable : ITestableObservable { private readonly TestScheduler _scheduler; private readonly Recorded>[] _messages; - private readonly List _subscriptions = new(); + private readonly List _subscriptions = []; public ColdObservable(TestScheduler scheduler, params Recorded>[] messages) { diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/HotObservable.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/HotObservable.cs index 240f2492b..2e9c9190b 100644 --- a/Rx.NET/Source/src/Microsoft.Reactive.Testing/HotObservable.cs +++ b/Rx.NET/Source/src/Microsoft.Reactive.Testing/HotObservable.cs @@ -12,8 +12,8 @@ namespace Microsoft.Reactive.Testing internal class HotObservable : ITestableObservable { private readonly TestScheduler _scheduler; - private readonly List> _observers = new(); - private readonly List _subscriptions = new(); + private readonly List> _observers = []; + private readonly List _subscriptions = []; private readonly Recorded>[] _messages; public HotObservable(TestScheduler scheduler, params Recorded>[] messages) diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs index 78608816f..7b7f442d7 100644 --- a/Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs +++ b/Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs @@ -11,12 +11,11 @@ namespace Microsoft.Reactive.Testing internal class MockObserver : ITestableObserver { private readonly TestScheduler _scheduler; - private readonly List>> _messages; + private readonly List>> _messages = []; public MockObserver(TestScheduler scheduler) { _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); - _messages = new List>>(); } public void OnNext(T value) diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.TimerQueue.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.TimerQueue.cs index fa004fe4f..f900e5f3d 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.TimerQueue.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/LocalScheduler.TimerQueue.cs @@ -55,7 +55,7 @@ public partial class LocalScheduler /// Set of disposable handles to all of the current short term work Schedule calls, /// allowing those to be cancelled upon a system clock change. /// - private readonly HashSet _shortTermWork = new(); + private readonly HashSet _shortTermWork = []; /// /// Threshold where an item is considered to be short term work or gets moved from diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Recursive.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Recursive.cs index 6850bda2e..475f23717 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Recursive.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Recursive.cs @@ -175,12 +175,11 @@ private abstract class InvokeRecBaseState : IDisposable { protected readonly IScheduler Scheduler; - protected readonly CompositeDisposable Group; + protected readonly CompositeDisposable Group = []; protected InvokeRecBaseState(IScheduler scheduler) { Scheduler = scheduler; - Group = new CompositeDisposable(); } public void Dispose() diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.cs index f1bd23991..470a40c5c 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.cs @@ -10,12 +10,13 @@ namespace System.Reactive.Concurrency // public static partial class Scheduler { - internal static Type[] Optimizations = { + internal static Type[] Optimizations = + [ typeof(ISchedulerLongRunning), typeof(IStopwatchProvider), typeof(ISchedulerPeriodic) /* update this list if new interface-based optimizations are added */ - }; + ]; /// /// Returns the implementation of the specified scheduler, or null if no such implementation is available. diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs index 5ab8535f9..b599a63c2 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs @@ -9,12 +9,16 @@ namespace System.Reactive.Concurrency internal abstract class SchedulerWrapper : IScheduler, IServiceProvider { protected readonly IScheduler _scheduler; - private readonly ConditionalWeakTable _cache; + private readonly ConditionalWeakTable _cache = +#if NET472_OR_GREATER || NETSTANDARD2_0_OR_GREATER + new(); +#else + []; +#endif protected SchedulerWrapper(IScheduler scheduler) { _scheduler = scheduler; - _cache = new ConditionalWeakTable(); } protected SchedulerWrapper(IScheduler scheduler, ConditionalWeakTable cache) diff --git a/Rx.NET/Source/src/System.Reactive/Diagnostics/CodeAnalysis/NullableAttributes.cs b/Rx.NET/Source/src/System.Reactive/Diagnostics/CodeAnalysis/NullableAttributes.cs index d721561cc..262bab933 100644 --- a/Rx.NET/Source/src/System.Reactive/Diagnostics/CodeAnalysis/NullableAttributes.cs +++ b/Rx.NET/Source/src/System.Reactive/Diagnostics/CodeAnalysis/NullableAttributes.cs @@ -96,7 +96,7 @@ internal sealed class MemberNotNullAttribute : Attribute /// The field or property member that is promised to be not-null. /// #pragma warning disable CA1019 // Define accessors for attribute arguments - this needs to be identical to the real type - public MemberNotNullAttribute(string member) => Members = new[] { member }; + public MemberNotNullAttribute(string member) => Members = [member]; #pragma warning restore CA1019 /// Initializes the attribute with the list of field and property members. @@ -125,7 +125,7 @@ public MemberNotNullWhenAttribute(bool returnValue, string member) #pragma warning restore CA1019 { ReturnValue = returnValue; - Members = new[] { member }; + Members = [member]; } /// Initializes the attribute with the specified return value condition and list of field and property members. diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs b/Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs index 03d4abee0..a0af531f8 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs @@ -29,7 +29,7 @@ public sealed class CompositeDisposable : ICollection, ICancelable /// public CompositeDisposable() { - _disposables = new List(); + _disposables = []; } /// @@ -387,7 +387,7 @@ public IEnumerator GetEnumerator() /// method to avoid allocation on disposed or empty composites. /// private static readonly CompositeEnumerator EmptyEnumerator = - new(Array.Empty()); + new([]); /// /// An enumerator for an array of disposables. diff --git a/Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs b/Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs index aa3647e05..616742b4c 100644 --- a/Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs +++ b/Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs @@ -76,7 +76,7 @@ public void SetResource(IDisposable resource) } private readonly IObservable> _source; - private readonly Dictionary> _subscriptions; + private readonly Dictionary> _subscriptions = []; private readonly Action, /*object,*/ EventPattern> _invokeHandler; /// @@ -89,7 +89,6 @@ protected EventPatternSourceBase(IObservable> { _source = source ?? throw new ArgumentNullException(nameof(source)); _invokeHandler = invokeHandler ?? throw new ArgumentNullException(nameof(invokeHandler)); - _subscriptions = new Dictionary>(); } /// diff --git a/Rx.NET/Source/src/System.Reactive/EventSource.cs b/Rx.NET/Source/src/System.Reactive/EventSource.cs index 85dc2cf4e..b737bd8b8 100644 --- a/Rx.NET/Source/src/System.Reactive/EventSource.cs +++ b/Rx.NET/Source/src/System.Reactive/EventSource.cs @@ -9,14 +9,13 @@ namespace System.Reactive internal sealed class EventSource : IEventSource { private readonly IObservable _source; - private readonly Dictionary> _subscriptions; + private readonly Dictionary> _subscriptions = []; private readonly Action, /*object,*/ T> _invokeHandler; public EventSource(IObservable source, Action, /*object,*/ T> invokeHandler) { _source = source; _invokeHandler = invokeHandler; - _subscriptions = new Dictionary>(); } public event Action OnNext diff --git a/Rx.NET/Source/src/System.Reactive/Internal/ImmutableList.cs b/Rx.NET/Source/src/System.Reactive/Internal/ImmutableList.cs index f4ad42bb3..32a5062e0 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/ImmutableList.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/ImmutableList.cs @@ -10,7 +10,7 @@ internal sealed class ImmutableList private readonly T[] _data; - private ImmutableList() => _data = Array.Empty(); + private ImmutableList() => _data = []; public ImmutableList(T[] data) => _data = data; diff --git a/Rx.NET/Source/src/System.Reactive/Internal/Lookup.cs b/Rx.NET/Source/src/System.Reactive/Internal/Lookup.cs index 74e8c111d..d34a84d47 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/Lookup.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/Lookup.cs @@ -23,7 +23,7 @@ public void Add(K key, E element) { if (!_dictionary.TryGetValue(key, out var list)) { - _dictionary[key] = list = new List(); + _dictionary[key] = list = []; } list.Add(element); diff --git a/Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs b/Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs index 373e93b33..1555335d2 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs @@ -21,7 +21,7 @@ public static class SystemClock { private static readonly Lazy ServiceSystemClock = new(InitializeSystemClock); private static readonly Lazy ServiceSystemClockChanged = new(InitializeSystemClockChanged); - internal static readonly HashSet> SystemClockChanged = new(); + internal static readonly HashSet> SystemClockChanged = []; private static IDisposable? _systemClockChangedHandlerCollector; private static int _refCount; @@ -123,7 +123,7 @@ private static void CollectHandlers() { if (!handler.TryGetTarget(out _)) { - remove ??= new HashSet>(); + remove ??= []; remove.Add(handler); } diff --git a/Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs b/Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs index aa4f3bb6b..0fd61f530 100644 --- a/Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs +++ b/Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs @@ -8,7 +8,7 @@ namespace System.Reactive.Joins { internal abstract class ActivePlan { - private readonly Dictionary _joinObservers = new(); + private readonly Dictionary _joinObservers = []; protected readonly Action _onCompleted; diff --git a/Rx.NET/Source/src/System.Reactive/Joins/JoinObserver.cs b/Rx.NET/Source/src/System.Reactive/Joins/JoinObserver.cs index 23f92b4d1..da4074aea 100644 --- a/Rx.NET/Source/src/System.Reactive/Joins/JoinObserver.cs +++ b/Rx.NET/Source/src/System.Reactive/Joins/JoinObserver.cs @@ -19,7 +19,7 @@ internal sealed class JoinObserver : ObserverBase>, IJoinObse private object? _gate; private readonly IObservable _source; private readonly Action _onError; - private readonly List _activePlans; + private readonly List _activePlans = []; private SingleAssignmentDisposableValue _subscription; private bool _isDisposed; @@ -28,7 +28,6 @@ public JoinObserver(IObservable source, Action onError) _source = source; _onError = onError; Queue = new Queue>(); - _activePlans = new List(); } public Queue> Queue { get; } diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Buffer.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Buffer.cs index c74db992c..2c484e18f 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Buffer.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Buffer.cs @@ -436,7 +436,7 @@ public TimeHopping(IObservable source, TimeSpan timeSpan, IScheduler sc internal sealed class _ : Sink> { private readonly object _gate = new(); - private List _list = new(); + private List _list = []; public _(IObserver> observer) : base(observer) @@ -465,7 +465,7 @@ private void Tick() lock (_gate) { ForwardOnNext(_list); - _list = new List(); + _list = []; } } @@ -521,7 +521,7 @@ internal sealed class _ : Sink> { private readonly Ferry _parent; private readonly object _gate = new(); - private List _s = new(); + private List _s = []; public _(Ferry parent, IObserver> observer) : base(observer) @@ -574,7 +574,7 @@ private void Tick(int id) var newId = ++_windowId; var res = _s; - _s = new List(); + _s = []; ForwardOnNext(res); CreateTimer(newId); @@ -598,7 +598,7 @@ public override void OnNext(TSource value) newId = ++_windowId; var res = _s; - _s = new List(); + _s = []; ForwardOnNext(res); } @@ -653,7 +653,7 @@ internal sealed class _ : Sink> private readonly AsyncLock _bufferGate = new(); private readonly Func> _bufferClosingSelector; - private List _buffer = new(); + private List _buffer = []; private SerialDisposableValue _bufferClosingSerialDisposable; public _(Selector parent, IObserver> observer) @@ -706,7 +706,7 @@ private void CloseBuffer(IDisposable closingSubscription) lock (_gate) { var res = _buffer; - _buffer = new List(); + _buffer = []; ForwardOnNext(res); } @@ -785,7 +785,7 @@ internal sealed class _ : Sink> { private readonly object _gate = new(); - private List _buffer = new(); + private List _buffer = []; private SingleAssignmentDisposableValue _boundariesDisposable; public _(IObserver> observer) @@ -823,7 +823,7 @@ public void OnNext(TBufferClosing value) lock (_parent._gate) { var res = _parent._buffer; - _parent._buffer = new List(); + _parent._buffer = []; _parent.ForwardOnNext(res); } } diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Delay.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Delay.cs index 1abebc011..8d36ff3de 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Delay.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Delay.cs @@ -597,7 +597,7 @@ protected Base(IObservable source) internal abstract class _ : IdentitySink { - private readonly CompositeDisposable _delays = new(); + private readonly CompositeDisposable _delays = []; private readonly object _gate = new(); private readonly Func> _delaySelector; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/FromEventPattern.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/FromEventPattern.cs index f5b6110ae..716031969 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/FromEventPattern.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/FromEventPattern.cs @@ -142,7 +142,7 @@ private Action AddHandlerCore(Delegate handler) private Action AddHandlerCoreWinRT(Delegate handler) { var token = _addMethod.Invoke(_target, new object[] { handler }); - return () => _removeMethod.Invoke(_target, new[] { token }); + return () => _removeMethod.Invoke(_target, [token]); } } } diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupByUntil.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupByUntil.cs index 0d5521f01..c3495871e 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupByUntil.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupByUntil.cs @@ -35,7 +35,7 @@ internal sealed class _ : Sink> { private readonly object _gate = new(); private readonly object _nullGate = new(); - private readonly CompositeDisposable _groupDisposable = new(); + private readonly CompositeDisposable _groupDisposable = []; private readonly RefCountDisposable _refCountDisposable; private readonly Map> _map; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupJoin.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupJoin.cs index 842dc54f2..a835f4edd 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupJoin.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupJoin.cs @@ -32,10 +32,10 @@ public GroupJoin(IObservable left, IObservable right, Func { private readonly object _gate = new(); - private readonly CompositeDisposable _group = new(); + private readonly CompositeDisposable _group = []; private readonly RefCountDisposable _refCount; - private readonly SortedDictionary> _leftMap; - private readonly SortedDictionary _rightMap; + private readonly SortedDictionary> _leftMap = []; + private readonly SortedDictionary _rightMap = []; private readonly Func> _leftDurationSelector; private readonly Func> _rightDurationSelector; @@ -45,8 +45,6 @@ public _(GroupJoin parent : base(observer) { _refCount = new RefCountDisposable(_group); - _leftMap = new SortedDictionary>(); - _rightMap = new SortedDictionary(); _leftDurationSelector = parent._leftDurationSelector; _rightDurationSelector = parent._rightDurationSelector; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Join.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Join.cs index 3b7db6774..d2304a5a8 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Join.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Join.cs @@ -31,9 +31,9 @@ public Join(IObservable left, IObservable right, Func { private readonly object _gate = new(); - private readonly CompositeDisposable _group = new(); - private readonly SortedDictionary _leftMap = new(); - private readonly SortedDictionary _rightMap = new(); + private readonly CompositeDisposable _group = []; + private readonly SortedDictionary _leftMap = []; + private readonly SortedDictionary _rightMap = []; private readonly Func> _leftDurationSelector; private readonly Func> _rightDurationSelector; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/MaxBy.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/MaxBy.cs index f3f56893c..80d847b35 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/MaxBy.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/MaxBy.cs @@ -29,15 +29,13 @@ internal sealed class _ : Sink> private readonly IComparer _comparer; private bool _hasValue; private TKey? _lastKey; - private List _list; + private List _list = []; public _(MaxBy parent, IObserver> observer) : base(observer) { _keySelector = parent._keySelector; _comparer = parent._comparer; - - _list = new List(); } public override void OnNext(TSource value) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Merge.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Merge.cs index 06e597191..c4ff799eb 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Merge.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Merge.cs @@ -32,7 +32,7 @@ internal sealed class _ : Sink, TSource> private readonly object _gate = new(); private readonly int _maxConcurrent; private readonly Queue> _q = new(); - private readonly CompositeDisposable _group = new(); + private readonly CompositeDisposable _group = []; public _(int maxConcurrent, IObserver observer) : base(observer) @@ -165,7 +165,7 @@ public Observables(IObservable> sources) internal sealed class _ : Sink, TSource> { private readonly object _gate = new(); - private readonly CompositeDisposable _group = new(); + private readonly CompositeDisposable _group = []; public _(IObserver observer) : base(observer) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/MinBy.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/MinBy.cs index 6c87ab801..1ea4dcdd1 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/MinBy.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/MinBy.cs @@ -29,15 +29,13 @@ internal sealed class _ : Sink> private readonly IComparer _comparer; private bool _hasValue; private TKey? _lastKey; - private List _list; + private List _list = []; public _(MinBy parent, IObserver> observer) : base(observer) { _keySelector = parent._keySelector; _comparer = parent._comparer; - - _list = new List(); } public override void OnNext(TSource value) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs index 17c19f80c..229237174 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs @@ -32,7 +32,7 @@ public ObservableSelector(IObservable source, Func { private readonly object _gate = new(); - private readonly CompositeDisposable _group = new(); + private readonly CompositeDisposable _group = []; private readonly Func> _collectionSelector; private readonly Func _resultSelector; @@ -193,7 +193,7 @@ public ObservableSelectorIndexed(IObservable source, Func { private readonly object _gate = new(); - private readonly CompositeDisposable _group = new(); + private readonly CompositeDisposable _group = []; private readonly Func> _collectionSelector; private readonly Func _resultSelector; @@ -850,7 +850,7 @@ internal class _ : Sink { protected readonly object _gate = new(); private readonly Func> _selector; - private readonly CompositeDisposable _group = new(); + private readonly CompositeDisposable _group = []; private volatile bool _isStopped; @@ -1081,7 +1081,7 @@ public ObservableSelectorIndexed(IObservable source, Func { private readonly object _gate = new(); - private readonly CompositeDisposable _group = new(); + private readonly CompositeDisposable _group = []; protected readonly Func> _selector; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToArray.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToArray.cs index 80d408581..1daf92387 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToArray.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToArray.cs @@ -21,12 +21,11 @@ public ToArray(IObservable source) internal sealed class _ : Sink { - private List _list; + private List _list = []; public _(IObserver observer) : base(observer) { - _list = new List(); } public override void OnNext(TSource value) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToList.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToList.cs index 95cac9d32..276338363 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToList.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToList.cs @@ -21,12 +21,11 @@ public ToList(IObservable source) internal sealed class _ : Sink> { - private List _list; + private List _list = []; public _(IObserver> observer) : base(observer) { - _list = new List(); } public override void OnNext(TSource value) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs index 1e1b88b3d..9888ef772 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs @@ -637,7 +637,7 @@ protected override void Dispose(bool disposing) { if (disposing) { - var subscriptions = Interlocked.Exchange(ref _subscriptions, Array.Empty()); + var subscriptions = Interlocked.Exchange(ref _subscriptions, []); if (subscriptions != null && subscriptions != Array.Empty()) { for (var i = 0; i < subscriptions.Length; i++) diff --git a/Rx.NET/Source/src/System.Reactive/ListObservable.cs b/Rx.NET/Source/src/System.Reactive/ListObservable.cs index de19a920f..310922d59 100644 --- a/Rx.NET/Source/src/System.Reactive/ListObservable.cs +++ b/Rx.NET/Source/src/System.Reactive/ListObservable.cs @@ -21,7 +21,7 @@ public class ListObservable : IList, IObservable { private readonly IDisposable _subscription; private readonly AsyncSubject _subject = new(); - private readonly List _results = new(); + private readonly List _results = []; /// /// Constructs an object that retains the values of source and signals the end of the sequence. diff --git a/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs b/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs index 5ac108ee4..4cca1fc1c 100644 --- a/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs +++ b/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs @@ -40,7 +40,7 @@ public sealed class AsyncSubject : SubjectBase, INotifyCompletion /// /// Creates a subject that can only receive one value and that value is cached for all future observations. /// - public AsyncSubject() => _observers = Array.Empty(); + public AsyncSubject() => _observers = []; #endregion @@ -273,7 +273,7 @@ private void Unsubscribe(AsyncSubjectDisposable observer) if (n == 1) { - b = Array.Empty(); + b = []; } else { diff --git a/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs b/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs index 53a464d4e..263527254 100644 --- a/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs +++ b/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs @@ -30,7 +30,7 @@ public sealed class Subject : SubjectBase /// /// Creates a subject. /// - public Subject() => _observers = Array.Empty(); + public Subject() => _observers = []; #endregion @@ -237,7 +237,7 @@ private void Unsubscribe(SubjectDisposable observer) if (n == 1) { - b = Array.Empty(); + b = []; } else { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj b/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj index fc45ec7c9..a9c3a8b09 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj +++ b/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj @@ -27,7 +27,7 @@ true bin\x86\Debug\ TRACE;DEBUG;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS;NO_EVENTARGS_CONSTRAINT;HAS_EDI;HAS_WINRT;HAS_PROGRESS;PREFER_ASYNC;HAS_AWAIT;HAS_APTCA;HAS_TPL46;NO_REMOTING;WINDOWS;USE_TIMER_SELF_ROOT - ;2008;0618;IDE0003;IDE0016;IDE0017;IDE0018;IDE0019;IDE0020;IDE0028;IDE0031;IDE0032;IDE0034;IDE0037;IDE0038;IDE0039;IDE0040;IDE0044;IDE0051;IDE0052;IDE0056;IDE0057;IDE0059;IDE0060;IDE0062;IDE0063;IDE0071;IDE0074;IDE0075;IDE0076;IDE0077;IDE0079;IDE0083;IDE0090;IDE0180;IDE0290;IDE0300;IDE0305;IDE1006;IDE1056 + ;2008;0618;IDE0003;IDE0016;IDE0017;IDE0018;IDE0019;IDE0020;IDE0028;IDE0031;IDE0032;IDE0034;IDE0037;IDE0038;IDE0039;IDE0040;IDE0044;IDE0051;IDE0052;IDE0056;IDE0057;IDE0059;IDE0060;IDE0062;IDE0063;IDE0071;IDE0074;IDE0075;IDE0076;IDE0077;IDE0079;IDE0083;IDE0090;IDE0180;IDE0290;IDE0305;IDE1006;IDE1056 full x86 false @@ -38,7 +38,7 @@ bin\x86\Release\ TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS;NO_EVENTARGS_CONSTRAINT;HAS_EDI;HAS_WINRT;HAS_PROGRESS;PREFER_ASYNC;HAS_AWAIT;HAS_APTCA;HAS_TPL46;NO_REMOTING;WINDOWS;USE_TIMER_SELF_ROOT true - ;2008;0618;IDE0003;IDE0016;IDE0017;IDE0018;IDE0019;IDE0020;IDE0028;IDE0031;IDE0032;IDE0034;IDE0037;IDE0038;IDE0039;IDE0040;IDE0044;IDE0051;IDE0052;IDE0056;IDE0057;IDE0059;IDE0060;IDE0062;IDE0063;IDE0071;IDE0074;IDE0075;IDE0076;IDE0077;IDE0079;IDE0083;IDE0090;IDE0180;IDE0290;IDE0300;IDE0305;IDE1006;IDE1056 + ;2008;0618;IDE0003;IDE0016;IDE0017;IDE0018;IDE0019;IDE0020;IDE0028;IDE0031;IDE0032;IDE0034;IDE0037;IDE0038;IDE0039;IDE0040;IDE0044;IDE0051;IDE0052;IDE0056;IDE0057;IDE0059;IDE0060;IDE0062;IDE0063;IDE0071;IDE0074;IDE0075;IDE0076;IDE0077;IDE0079;IDE0083;IDE0090;IDE0180;IDE0290;IDE0305;IDE1006;IDE1056 pdbonly x86 false diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs b/Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs index cf34f30b5..0e5bbbbed 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs @@ -11,7 +11,7 @@ namespace ReactiveTests public class MockEnumerable : IEnumerable { public readonly TestScheduler Scheduler; - public readonly List Subscriptions = new(); + public readonly List Subscriptions = []; private readonly IEnumerable _underlyingEnumerable; public MockEnumerable(TestScheduler scheduler, IEnumerable underlyingEnumerable) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SchedulerTest.cs index 1eb859243..008d3c1f8 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SchedulerTest.cs @@ -1033,7 +1033,7 @@ public IDisposable Schedule(TState state, DateTimeOffset dueTime, Func()); + var s = new MyDumbScheduler2([]); Assert.Null(Scheduler.AsLongRunning(s)); Assert.Null(Scheduler.AsPeriodic(s)); Assert.Null(Scheduler.AsStopwatchProvider(s)); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Internal/HalfSerializerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Internal/HalfSerializerTest.cs index 0585be981..a468268a4 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Internal/HalfSerializerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Internal/HalfSerializerTest.cs @@ -138,7 +138,7 @@ public void HalfSerializer_OnNext_Reentrant_OnCompleted() private sealed class Consumer : ISink { - internal List Items = new(); + internal List Items = []; internal int Done; internal Exception Exc; diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs index 46364ea0e..71778d452 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs @@ -18,12 +18,13 @@ namespace Tests.System.Reactive.Tests public class LicenseHeaderTest { private static readonly bool FixHeaders = true; - private static readonly string[] Lines = { + private static readonly string[] Lines = + [ "// Licensed to the .NET Foundation under one or more agreements.", "// The .NET Foundation licenses this file to you under the MIT License.", "// See the LICENSE file in the project root for more information.", "" - }; + ]; [TestMethod] public void ScanFiles() diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/AutoConnectTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/AutoConnectTest.cs index 7fa6c2535..daab682f7 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/AutoConnectTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/AutoConnectTest.cs @@ -96,7 +96,7 @@ public void AutoConnect_TwoConsumers() Assert.Equal(1, called); Assert.Equal(new List() { 1, 2, 3, 4, 5 }, list); - Assert.Equal(new List() { 1, 2, 3, 4, 5 }, list0); + Assert.Equal([1, 2, 3, 4, 5], list0); list = source.ToList().First(); @@ -132,7 +132,7 @@ public void AutoConnect_Dispose() subject.OnNext(4); subject.OnNext(5); - Assert.Equal(new List() { 1, 2, 3 }, list); + Assert.Equal([1, 2, 3], list); } } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/DelayTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/DelayTest.cs index 13b0aa30a..e0736f4a6 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/DelayTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/DelayTest.cs @@ -1409,7 +1409,7 @@ public void Delay_Duration_Selector_Immediately() .Delay(_ => Observable.Return(1)) .Subscribe(list.Add); - Assert.Equal(new List() { 1, 2, 3, 4, 5 }, list); + Assert.Equal([1, 2, 3, 4, 5], list); } [TestMethod] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ForkJoinTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ForkJoinTest.cs index 4e2a3fa11..0971242c5 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ForkJoinTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ForkJoinTest.cs @@ -388,7 +388,7 @@ public void ForkJoin_NaryParamsEmptyBeforeEnd() [TestMethod] public void ForkJoin_Nary_Immediate() { - ObservableEx.ForkJoin(Observable.Return(1), Observable.Return(2)).First().AssertEqual(new[] { 1, 2 }); + ObservableEx.ForkJoin(Observable.Return(1), Observable.Return(2)).First().AssertEqual([1, 2]); } [TestMethod] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MergeTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MergeTest.cs index da906a92a..6df81113a 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MergeTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MergeTest.cs @@ -1739,7 +1739,7 @@ public void Merge_TaskWithCompletionSource_RanToCompletion_Async() done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43 }); + lst.OrderBy(x => x).AssertEqual([42, 43]); } [TestMethod] @@ -1761,7 +1761,7 @@ public void Merge_TaskWithCompletionSource_RanToCompletion_Sync() done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43 }); + lst.OrderBy(x => x).AssertEqual([42, 43]); } [TestMethod] @@ -1892,7 +1892,7 @@ public void Merge_TaskWithCompletionSource_InnerCompleteBeforeOuter() done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43, 44 }); + lst.OrderBy(x => x).AssertEqual([42, 43, 44]); } [TestMethod] @@ -1924,7 +1924,7 @@ public void Merge_TaskWithCompletionSource_OuterCompleteBeforeInner() done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43, 44 }); + lst.OrderBy(x => x).AssertEqual([42, 43, 44]); } [TestMethod] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RepeatWhenTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RepeatWhenTest.cs index 670119433..9d078149e 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RepeatWhenTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RepeatWhenTest.cs @@ -502,7 +502,7 @@ public void RepeatWhen_Observable_Repeat_Delayed() var res = scheduler.Start(() => xs.RepeatWhen(v => { - int[] count = { 0 }; + int[] count = [0]; return v.SelectMany(w => { var c = ++count[0]; diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RetryWhenTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RetryWhenTest.cs index f373842ab..c48185512 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RetryWhenTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RetryWhenTest.cs @@ -145,7 +145,7 @@ public void RetryWhen_Observable_RetryCount_Basic() var res = scheduler.Start(() => xs.RetryWhen(v => { - int[] count = { 0 }; + int[] count = [0]; return v.SelectMany(w => { var c = ++count[0]; @@ -195,7 +195,7 @@ public void RetryWhen_Observable_RetryCount_Delayed() var res = scheduler.Start(() => xs.RetryWhen(v => { - int[] count = { 0 }; + int[] count = [0]; return v.SelectMany(w => { var c = ++count[0]; diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/SelectManyTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/SelectManyTest.cs index f65c9c2fc..92e5be993 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/SelectManyTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/SelectManyTest.cs @@ -5193,7 +5193,7 @@ public void SelectMany_TaskWithCompletionSource_Simple_RanToCompletion_Async() done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43 }); + lst.OrderBy(x => x).AssertEqual([42, 43]); } [TestMethod] @@ -5215,7 +5215,7 @@ public void SelectMany_TaskWithCompletionSource_Simple_RanToCompletion_Sync() done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43 }); + lst.OrderBy(x => x).AssertEqual([42, 43]); } [TestMethod] @@ -5346,7 +5346,7 @@ public void SelectMany_TaskWithCompletionSource_Simple_InnerCompleteBeforeOuter( done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43, 44 }); + lst.OrderBy(x => x).AssertEqual([42, 43, 44]); } [TestMethod] @@ -5378,7 +5378,7 @@ public void SelectMany_TaskWithCompletionSource_Simple_OuterCompleteBeforeInner( done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43, 44 }); + lst.OrderBy(x => x).AssertEqual([42, 43, 44]); } [TestMethod] @@ -5417,7 +5417,7 @@ public void SelectMany_TaskWithCompletionSource_Simple_Cancellation_NeverInvoked done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43, 44 }); + lst.OrderBy(x => x).AssertEqual([42, 43, 44]); } [TestMethod] @@ -5460,7 +5460,7 @@ public void SelectMany_TaskWithCompletionSource_Simple_Cancellation_Invoked() Assert.False(tcss[0].TrySetResult(43)); tcss[2].SetResult(44); // never observed because xs.OnNext(2) happened after dispose - lst.AssertEqual(new[] { 42 }); + lst.AssertEqual([42]); Assert.False(done); Assert.Equal(2, n); Assert.Equal(1, m); // tcss[1] was already finished @@ -5505,7 +5505,7 @@ public void SelectMany_TaskWithCompletionSource_Simple_Cancellation_AfterOuterEr Assert.False(tcss[0].TrySetResult(43)); tcss[2].SetResult(44); // no-op - lst.AssertEqual(new[] { 42 }); + lst.AssertEqual([42]); Assert.Same(ex, err); Assert.False(done); Assert.Equal(2, n); @@ -5586,7 +5586,7 @@ public void SelectMany_TaskWithCompletionSource_WithResultSelector_RanToCompleti done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 0, 43 + 1 }); + lst.OrderBy(x => x).AssertEqual([42 + 0, 43 + 1]); } [TestMethod] @@ -5608,7 +5608,7 @@ public void SelectMany_TaskWithCompletionSource_WithResultSelector_RanToCompleti done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 0, 43 + 1 }); + lst.OrderBy(x => x).AssertEqual([42 + 0, 43 + 1]); } [TestMethod] @@ -5739,7 +5739,7 @@ public void SelectMany_TaskWithCompletionSource_WithResultSelector_InnerComplete done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 1, 43 + 0, 44 + 2 }); + lst.OrderBy(x => x).AssertEqual([42 + 1, 43 + 0, 44 + 2]); } [TestMethod] @@ -5771,7 +5771,7 @@ public void SelectMany_TaskWithCompletionSource_WithResultSelector_OuterComplete done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 1, 43 + 0, 44 + 2 }); + lst.OrderBy(x => x).AssertEqual([42 + 1, 43 + 0, 44 + 2]); } [TestMethod] @@ -5810,7 +5810,7 @@ public void SelectMany_TaskWithCompletionSource_WithResultSelector_Cancellation_ done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 1, 43 + 0, 44 + 2 }); + lst.OrderBy(x => x).AssertEqual([42 + 1, 43 + 0, 44 + 2]); } [TestMethod] @@ -5853,7 +5853,7 @@ public void SelectMany_TaskWithCompletionSource_WithResultSelector_Cancellation_ Assert.False(tcss[0].TrySetResult(43)); tcss[2].SetResult(44); // never observed because xs.OnNext(2) happened after dispose - lst.AssertEqual(new[] { 42 + 1 }); + lst.AssertEqual([42 + 1]); Assert.False(done); Assert.Equal(2, n); Assert.Equal(1, m); // tcss[1] was already finished @@ -5898,7 +5898,7 @@ public void SelectMany_TaskWithCompletionSource_WithResultSelector_Cancellation_ Assert.False(tcss[0].TrySetResult(43)); tcss[2].SetResult(44); // no-op - lst.AssertEqual(new[] { 42 + 1 }); + lst.AssertEqual([42 + 1]); Assert.Same(ex, err); Assert.False(done); Assert.Equal(2, n); @@ -6125,7 +6125,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_Simple_RanToCompletion_ done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43 }); + lst.OrderBy(x => x).AssertEqual([42, 43]); } [TestMethod] @@ -6147,7 +6147,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_Simple_RanToCompletion_ done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43 }); + lst.OrderBy(x => x).AssertEqual([42, 43]); } [TestMethod] @@ -6278,7 +6278,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_Simple_InnerCompleteBef done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43, 44 }); + lst.OrderBy(x => x).AssertEqual([42, 43, 44]); } [TestMethod] @@ -6310,7 +6310,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_Simple_OuterCompleteBef done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43, 44 }); + lst.OrderBy(x => x).AssertEqual([42, 43, 44]); } [TestMethod] @@ -6349,7 +6349,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_Simple_Cancellation_Nev done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42, 43, 44 }); + lst.OrderBy(x => x).AssertEqual([42, 43, 44]); } [TestMethod] @@ -6392,7 +6392,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_Simple_Cancellation_Inv Assert.False(tcss[0].TrySetResult(43)); tcss[2].SetResult(44); // never observed because xs.OnNext(2) happened after dispose - lst.AssertEqual(new[] { 42 }); + lst.AssertEqual([42]); Assert.False(done); Assert.Equal(2, n); Assert.Equal(1, m); // tcss[1] was already finished @@ -6437,7 +6437,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_Simple_Cancellation_Aft Assert.False(tcss[0].TrySetResult(43)); tcss[2].SetResult(44); // no-op - lst.AssertEqual(new[] { 42 }); + lst.AssertEqual([42]); Assert.Same(ex, err); Assert.False(done); Assert.Equal(2, n); @@ -6518,7 +6518,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_WithResultSelector_RanT done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 0, 43 + 1 }); + lst.OrderBy(x => x).AssertEqual([42 + 0, 43 + 1]); } [TestMethod] @@ -6540,7 +6540,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_WithResultSelector_RanT done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 0, 43 + 1 }); + lst.OrderBy(x => x).AssertEqual([42 + 0, 43 + 1]); } [TestMethod] @@ -6671,7 +6671,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_WithResultSelector_Inne done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 1, 43 + 0, 44 + 2 }); + lst.OrderBy(x => x).AssertEqual([42 + 1, 43 + 0, 44 + 2]); } [TestMethod] @@ -6703,7 +6703,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_WithResultSelector_Oute done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 1, 43 + 0, 44 + 2 }); + lst.OrderBy(x => x).AssertEqual([42 + 1, 43 + 0, 44 + 2]); } [TestMethod] @@ -6742,7 +6742,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_WithResultSelector_Canc done.WaitOne(); - lst.OrderBy(x => x).AssertEqual(new[] { 42 + 1, 43 + 0, 44 + 2 }); + lst.OrderBy(x => x).AssertEqual([42 + 1, 43 + 0, 44 + 2]); } [TestMethod] @@ -6785,7 +6785,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_WithResultSelector_Canc Assert.False(tcss[0].TrySetResult(43)); tcss[2].SetResult(44); // never observed because xs.OnNext(2) happened after dispose - lst.AssertEqual(new[] { 42 + 1 }); + lst.AssertEqual([42 + 1]); Assert.False(done); Assert.Equal(2, n); Assert.Equal(1, m); // tcss[1] was already finished @@ -6830,7 +6830,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_WithResultSelector_Canc Assert.False(tcss[0].TrySetResult(43)); tcss[2].SetResult(44); // no-op - lst.AssertEqual(new[] { 42 + 1 }); + lst.AssertEqual([42 + 1]); Assert.Same(ex, err); Assert.False(done); Assert.Equal(2, n); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/TimerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/TimerTest.cs index 202893b96..30de2b4b0 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/TimerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/TimerTest.cs @@ -789,12 +789,7 @@ private Func GetCatch(Func _timers; - - public PeriodicTestScheduler() - { - _timers = new List(); - } + private readonly List _timers = []; public IDisposable SchedulePeriodic(TState state, TimeSpan period, Func action) { @@ -838,12 +833,11 @@ internal class TimerRun : IEnumerable private readonly long _started; private long _stopped; private bool _hasStopped; - private readonly List _ticks; + private readonly List _ticks = []; public TimerRun(long started) { _started = started; - _ticks = new List(); } public TimerRun(long started, long stopped) @@ -851,7 +845,6 @@ public TimerRun(long started, long stopped) _started = started; _stopped = stopped; _hasStopped = true; - _ticks = new List(); } public override int GetHashCode() diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/UsingAsyncTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/UsingAsyncTest.cs index ce30eaf7f..1640bcdd9 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/UsingAsyncTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/UsingAsyncTest.cs @@ -39,7 +39,7 @@ public void UsingAsync_Simple() var res = xs.ToEnumerable().ToList(); - Assert.Equal(new List { 42 }, res); + Assert.Equal([42], res); Assert.True(done.Wait(5000), "done.Wait(5000)"); } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableTest.cs index f65a8a32f..7a8249f37 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableTest.cs @@ -1133,10 +1133,10 @@ public void SkipWhile() [TestMethod] public void StartWith_ArgumentNullChecks() { - ReactiveAssert.Throws(() => Qbservable.StartWith(_qbNull, new[] { 1 })); + ReactiveAssert.Throws(() => Qbservable.StartWith(_qbNull, [1])); ReactiveAssert.Throws(() => Qbservable.StartWith(_qbMy, default(int[]))); - ReactiveAssert.Throws(() => Qbservable.StartWith(_qbNull, Scheduler.Immediate, new[] { 1 })); - ReactiveAssert.Throws(() => Qbservable.StartWith(_qbMy, default, new[] { 1 })); + ReactiveAssert.Throws(() => Qbservable.StartWith(_qbNull, Scheduler.Immediate, [1])); + ReactiveAssert.Throws(() => Qbservable.StartWith(_qbMy, default, [1])); ReactiveAssert.Throws(() => Qbservable.StartWith(_qbMy, Scheduler.Immediate, default)); } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/MySubject.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/MySubject.cs index affd58585..38d881570 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/MySubject.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/MySubject.cs @@ -11,7 +11,7 @@ namespace ReactiveTests.Tests { internal class MySubject : ISubject { - private readonly Dictionary _disposeOn = new(); + private readonly Dictionary _disposeOn = []; public void DisposeOn(int value, IDisposable disposable) { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/PrivateTypesTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/PrivateTypesTest.cs index 5fcf70233..2e7779e7a 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/PrivateTypesTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/PrivateTypesTest.cs @@ -151,7 +151,7 @@ internal class EitherBase public override bool Equals(object obj) { var equ = _value.GetType().GetMethods().Where(m => m.Name == "Equals" && m.GetParameters()[0].ParameterType == typeof(object)).Single(); - return (bool)equ.Invoke(_value, new object[] { obj is EitherBase eitherBase ? eitherBase._value : obj }); + return (bool)equ.Invoke(_value, [obj is EitherBase eitherBase ? eitherBase._value : obj]); } public override int GetHashCode() @@ -171,7 +171,7 @@ public static Either CreateLeft(TLeft value) { var tpe = typeof(Observable).GetTypeInfo().Assembly.GetTypes().Single(t => t.Name == "Either`2").MakeGenericType(typeof(TLeft), typeof(TRight)); var mth = tpe.GetMethod(nameof(CreateLeft)); - var res = mth.Invoke(null, new object[] { value }); + var res = mth.Invoke(null, [value]); return new Left(res); } @@ -179,20 +179,20 @@ public static Either CreateRight(TRight value) { var tpe = typeof(Observable).GetTypeInfo().Assembly.GetTypes().Single(t => t.Name == "Either`2").MakeGenericType(typeof(TLeft), typeof(TRight)); var mth = tpe.GetMethod(nameof(CreateRight)); - var res = mth.Invoke(null, new object[] { value }); + var res = mth.Invoke(null, [value]); return new Right(res); } public TResult Switch(Func caseLeft, Func caseRight) { var mth = _value.GetType().GetMethods().Where(m => m.Name == nameof(Switch) && m.ReturnType != typeof(void)).Single().MakeGenericMethod(typeof(TResult)); - return (TResult)mth.Invoke(_value, new object[] { caseLeft, caseRight }); + return (TResult)mth.Invoke(_value, [caseLeft, caseRight]); } public void Switch(Action caseLeft, Action caseRight) { var mth = _value.GetType().GetMethods().Where(m => m.Name == nameof(Switch) && m.ReturnType == typeof(void)).Single(); - mth.Invoke(_value, new object[] { caseLeft, caseRight }); + mth.Invoke(_value, [caseLeft, caseRight]); } #pragma warning disable CA1067 // (Override Object.Equals(object) when implementing IEquatable) - not required in the tests that use this type @@ -214,7 +214,7 @@ public Left(object value) public bool Equals(Left other) { var equ = _value.GetType().GetMethods().Where(m => m.Name == nameof(Equals) && m.GetParameters()[0].ParameterType != typeof(object)).Single(); - return (bool)equ.Invoke(_value, new object[] { other?._value }); + return (bool)equ.Invoke(_value, [other?._value]); } } @@ -236,7 +236,7 @@ public Right(object value) public bool Equals(Right other) { var equ = _value.GetType().GetMethods().Where(m => m.Name == nameof(Equals) && m.GetParameters()[0].ParameterType != typeof(object)).Single(); - return (bool)equ.Invoke(_value, new object[] { other?._value }); + return (bool)equ.Invoke(_value, [other?._value]); } } #pragma warning restore CA1067 diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/SystemClockTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/SystemClockTest.cs index 938616501..0f3f86917 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/SystemClockTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/SystemClockTest.cs @@ -940,7 +940,7 @@ internal override void SystemClockChanged(object sender, SystemClockChangedEvent private class MyScheduler : LocalScheduler { - internal List> _queue = new(); + internal List> _queue = []; private DateTimeOffset _now; @@ -1026,7 +1026,7 @@ public Work(Action action, object state) private class MyCAL : IConcurrencyAbstractionLayer { - internal List> _queue = new(); + internal List> _queue = []; public IDisposable StartTimer(Action action, object state, TimeSpan dueTime) { From 2837ecd9c49d9dfda6c787eb47f49ae5e7a8fd4c Mon Sep 17 00:00:00 2001 From: Ian Griffiths Date: Tue, 21 Nov 2023 16:31:09 +0000 Subject: [PATCH 3/3] Add comment explainin why we've disable IDE0290 Make UWP test runner use the same warning settings as everything else, except for CS0618, which a large number of tests appear to depend on. --- Rx.NET/Source/Directory.build.props | 8 ++++---- .../Tests.System.Reactive.Uwp.DeviceRunner.csproj | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Rx.NET/Source/Directory.build.props b/Rx.NET/Source/Directory.build.props index 7bbc37a5a..c0956a2aa 100644 --- a/Rx.NET/Source/Directory.build.props +++ b/Rx.NET/Source/Directory.build.props @@ -61,7 +61,7 @@ true - $(NoWarn);CA1001;CA2213;CA1510;CA1513;IDE0056;IDE0057;IDE0290;IDE0305 diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj b/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj index a9c3a8b09..f04fcad31 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj +++ b/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj @@ -27,7 +27,7 @@ true bin\x86\Debug\ TRACE;DEBUG;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS;NO_EVENTARGS_CONSTRAINT;HAS_EDI;HAS_WINRT;HAS_PROGRESS;PREFER_ASYNC;HAS_AWAIT;HAS_APTCA;HAS_TPL46;NO_REMOTING;WINDOWS;USE_TIMER_SELF_ROOT - ;2008;0618;IDE0003;IDE0016;IDE0017;IDE0018;IDE0019;IDE0020;IDE0028;IDE0031;IDE0032;IDE0034;IDE0037;IDE0038;IDE0039;IDE0040;IDE0044;IDE0051;IDE0052;IDE0056;IDE0057;IDE0059;IDE0060;IDE0062;IDE0063;IDE0071;IDE0074;IDE0075;IDE0076;IDE0077;IDE0079;IDE0083;IDE0090;IDE0180;IDE0290;IDE0305;IDE1006;IDE1056 + $(NoWarn);CA1001;CA2213;CA1510;CA1513;CS0618;IDE0056;IDE0057;IDE0290;IDE0305 full x86 false @@ -38,7 +38,7 @@ bin\x86\Release\ TRACE;NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS;NO_EVENTARGS_CONSTRAINT;HAS_EDI;HAS_WINRT;HAS_PROGRESS;PREFER_ASYNC;HAS_AWAIT;HAS_APTCA;HAS_TPL46;NO_REMOTING;WINDOWS;USE_TIMER_SELF_ROOT true - ;2008;0618;IDE0003;IDE0016;IDE0017;IDE0018;IDE0019;IDE0020;IDE0028;IDE0031;IDE0032;IDE0034;IDE0037;IDE0038;IDE0039;IDE0040;IDE0044;IDE0051;IDE0052;IDE0056;IDE0057;IDE0059;IDE0060;IDE0062;IDE0063;IDE0071;IDE0074;IDE0075;IDE0076;IDE0077;IDE0079;IDE0083;IDE0090;IDE0180;IDE0290;IDE0305;IDE1006;IDE1056 + $(NoWarn);CA1001;CA2213;CA1510;CA1513;CS0618;IDE0056;IDE0057;IDE0290;IDE0305 pdbonly x86 false