diff --git a/.editorconfig b/.editorconfig index aff572efae..ea4c9aff7e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -64,7 +64,7 @@ dotnet_style_predefined_type_for_member_access = true:suggestion dotnet_style_readonly_field = true:warning # Suggest more modern language features when available -dotnet_style_object_initializer = true:suggestion +dotnet_style_object_initializer = true:silent dotnet_style_collection_initializer = true:suggestion dotnet_style_coalesce_expression = true:suggestion dotnet_style_null_propagation = true:suggestion @@ -74,7 +74,7 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion dotnet_style_prefer_conditional_expression_over_return = false dotnet_style_prefer_conditional_expression_over_assignment = false -dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_auto_properties = true:silent # Parentheses dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent diff --git a/Rx.NET/Source/Directory.build.props b/Rx.NET/Source/Directory.build.props index 7af7edb43d..16593d58e9 100644 --- a/Rx.NET/Source/Directory.build.props +++ b/Rx.NET/Source/Directory.build.props @@ -13,16 +13,11 @@ en-US false $(MSBuildProjectName.Contains('Tests')) - $(MSBuildThisFileDirectory)Rx.ruleset true $(MSBuildThisFileDirectory)artifacts true true latest - - - 5-Default - $(NoWarn);CS8600;CS8602;CS8603;CS8604;CS8632;CA1000;CA1003;CA1014;CA1019;CA1033;CA1045;CA1051;CA1052;CA1063;CA1067;CA1068;CA1507;CA1707;CA1711;CA1716;CA1720;CA1806;CA1815;CA1816;CA1822;CA1825;CA1840;CA1845;CA2016;CA2109;CA2201;CA2211;CA2213;CA2249;IDE0003;IDE0016;IDE0017;IDE0018;IDE0019;IDE0020;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;IDE0270;IDE0280;IDE1006;IDE1056 @@ -43,4 +38,35 @@ + + 7.0-default + 7.0-all + 7.0-all + + + true + + + + $(NoWarn);CA1001;CA2213;IDE0056;IDE0057 + + + + + + diff --git a/Rx.NET/Source/Rx.ruleset b/Rx.NET/Source/Rx.ruleset deleted file mode 100644 index 2dc9042e8b..0000000000 --- a/Rx.NET/Source/Rx.ruleset +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Rx.NET/Source/System.Reactive.sln b/Rx.NET/Source/System.Reactive.sln index 2632264b16..6b821dc17f 100644 --- a/Rx.NET/Source/System.Reactive.sln +++ b/Rx.NET/Source/System.Reactive.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28407.52 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33627.172 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Reactive", "src\System.Reactive\System.Reactive.csproj", "{01706A0F-8A63-4FD6-AF45-0BC0BED3C0D9}" EndProject @@ -15,6 +15,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.System.Reactive.Uwp.D EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{870348D0-C0A0-4352-8A02-E00AB0CCB919}" ProjectSection(SolutionItems) = preProject + ..\..\.editorconfig = ..\..\.editorconfig + src\.editorconfig = src\.editorconfig + analyzers.globalconfig = analyzers.globalconfig ..\..\azure-pipelines.rx.yml = ..\..\azure-pipelines.rx.yml Directory.build.props = Directory.build.props Directory.build.targets = Directory.build.targets @@ -25,6 +28,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{D324579D-CBE6-4867-8980-D7842C7C45A2}" + ProjectSection(SolutionItems) = preProject + tests\.editorconfig = tests\.editorconfig + tests\Directory.build.props = tests\Directory.build.props + tests\Directory.build.targets = tests\Directory.build.targets + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Facades", "Facades", "{A0F39260-B8F8-4FCB-9679-0ED917A22BDF}" ProjectSection(SolutionItems) = preProject diff --git a/Rx.NET/Source/analyzers.globalconfig b/Rx.NET/Source/analyzers.globalconfig new file mode 100644 index 0000000000..3880062c13 --- /dev/null +++ b/Rx.NET/Source/analyzers.globalconfig @@ -0,0 +1,230 @@ +is_global = true + +# In .NET SDK 7, these are off by default in .NET Standard but on for everything else +dotnet_diagnostic.CS0659.severity = warning +dotnet_diagnostic.CS0661.severity = warning +# This is off by default in .NET FX but on for everything else +dotnet_diagnostic.CS1718.severity = warning + +dotnet_diagnostic.CA1000.severity = warning +dotnet_diagnostic.CA1002.severity = warning +dotnet_diagnostic.CA1003.severity = warning +dotnet_diagnostic.CA1004.severity = warning +dotnet_diagnostic.CA1007.severity = warning +dotnet_diagnostic.CA1008.severity = warning +dotnet_diagnostic.CA1009.severity = warning +dotnet_diagnostic.CA1010.severity = warning +dotnet_diagnostic.CA1012.severity = warning +dotnet_diagnostic.CA1013.severity = warning +dotnet_diagnostic.CA1016.severity = warning +dotnet_diagnostic.CA1017.severity = warning +dotnet_diagnostic.CA1018.severity = warning +dotnet_diagnostic.CA1019.severity = warning +dotnet_diagnostic.CA1020.severity = warning +dotnet_diagnostic.CA1021.severity = warning +dotnet_diagnostic.CA1023.severity = warning +dotnet_diagnostic.CA1024.severity = warning +dotnet_diagnostic.CA1025.severity = warning +dotnet_diagnostic.CA1026.severity = warning +dotnet_diagnostic.CA1027.severity = warning +dotnet_diagnostic.CA1028.severity = warning +dotnet_diagnostic.CA1030.severity = warning +dotnet_diagnostic.CA1032.severity = warning +dotnet_diagnostic.CA1033.severity = warning +dotnet_diagnostic.CA1034.severity = warning +dotnet_diagnostic.CA1035.severity = warning +dotnet_diagnostic.CA1036.severity = warning +dotnet_diagnostic.CA1038.severity = warning +dotnet_diagnostic.CA1039.severity = warning +dotnet_diagnostic.CA1040.severity = warning +dotnet_diagnostic.CA1041.severity = warning +dotnet_diagnostic.CA1043.severity = warning +dotnet_diagnostic.CA1044.severity = warning +dotnet_diagnostic.CA1045.severity = warning +dotnet_diagnostic.CA1046.severity = warning +dotnet_diagnostic.CA1047.severity = warning +dotnet_diagnostic.CA1048.severity = warning +dotnet_diagnostic.CA1049.severity = warning +dotnet_diagnostic.CA1050.severity = warning +dotnet_diagnostic.CA1051.severity = warning +dotnet_diagnostic.CA1052.severity = warning +dotnet_diagnostic.CA1053.severity = warning +dotnet_diagnostic.CA1054.severity = warning +dotnet_diagnostic.CA1055.severity = warning +dotnet_diagnostic.CA1056.severity = warning +dotnet_diagnostic.CA1057.severity = warning +dotnet_diagnostic.CA1058.severity = warning +dotnet_diagnostic.CA1059.severity = warning +dotnet_diagnostic.CA1060.severity = warning +dotnet_diagnostic.CA1061.severity = warning +dotnet_diagnostic.CA1062.severity = warning +dotnet_diagnostic.CA1063.severity = warning +dotnet_diagnostic.CA1064.severity = warning +dotnet_diagnostic.CA1065.severity = warning + + +dotnet_diagnostic.CA1300.severity = warning +dotnet_diagnostic.CA1301.severity = warning +dotnet_diagnostic.CA1302.severity = warning +dotnet_diagnostic.CA1303.severity = warning +dotnet_diagnostic.CA1304.severity = warning +dotnet_diagnostic.CA1305.severity = warning +dotnet_diagnostic.CA1306.severity = warning +dotnet_diagnostic.CA1307.severity = warning +dotnet_diagnostic.CA1308.severity = warning +dotnet_diagnostic.CA1309.severity = warning + +dotnet_diagnostic.CA1400.severity = warning +dotnet_diagnostic.CA1401.severity = warning +dotnet_diagnostic.CA1402.severity = warning +dotnet_diagnostic.CA1403.severity = warning +dotnet_diagnostic.CA1404.severity = warning +dotnet_diagnostic.CA1405.severity = warning +dotnet_diagnostic.CA1406.severity = warning +dotnet_diagnostic.CA1407.severity = warning +dotnet_diagnostic.CA1408.severity = warning +dotnet_diagnostic.CA1409.severity = warning +dotnet_diagnostic.CA1410.severity = warning +dotnet_diagnostic.CA1411.severity = warning +dotnet_diagnostic.CA1412.severity = warning +dotnet_diagnostic.CA1413.severity = warning +dotnet_diagnostic.CA1414.severity = warning +dotnet_diagnostic.CA1415.severity = warning + +dotnet_diagnostic.CA1600.severity = warning +dotnet_diagnostic.CA1601.severity = warning +dotnet_diagnostic.CA1700.severity = warning +dotnet_diagnostic.CA1701.severity = warning +dotnet_diagnostic.CA1702.severity = warning +dotnet_diagnostic.CA1703.severity = warning +dotnet_diagnostic.CA1704.severity = warning +dotnet_diagnostic.CA1707.severity = warning +dotnet_diagnostic.CA1708.severity = warning +dotnet_diagnostic.CA1709.severity = warning +dotnet_diagnostic.CA1710.severity = warning +dotnet_diagnostic.CA1711.severity = warning +dotnet_diagnostic.CA1712.severity = warning +dotnet_diagnostic.CA1713.severity = warning +dotnet_diagnostic.CA1714.severity = warning +dotnet_diagnostic.CA1715.severity = warning +dotnet_diagnostic.CA1716.severity = warning +dotnet_diagnostic.CA1717.severity = warning +dotnet_diagnostic.CA1719.severity = warning +dotnet_diagnostic.CA1720.severity = warning +dotnet_diagnostic.CA1721.severity = warning +dotnet_diagnostic.CA1722.severity = warning +dotnet_diagnostic.CA1724.severity = warning +dotnet_diagnostic.CA1725.severity = warning +dotnet_diagnostic.CA1726.severity = warning + +dotnet_diagnostic.CA1800.severity = warning +dotnet_diagnostic.CA1802.severity = warning +dotnet_diagnostic.CA1804.severity = warning +dotnet_diagnostic.CA1806.severity = warning +dotnet_diagnostic.CA1809.severity = warning +dotnet_diagnostic.CA1810.severity = warning +dotnet_diagnostic.CA1811.severity = warning +dotnet_diagnostic.CA1812.severity = warning +dotnet_diagnostic.CA1813.severity = warning +dotnet_diagnostic.CA1814.severity = warning +dotnet_diagnostic.CA1815.severity = warning +dotnet_diagnostic.CA1816.severity = warning +dotnet_diagnostic.CA1819.severity = warning +dotnet_diagnostic.CA1820.severity = warning +dotnet_diagnostic.CA1821.severity = warning +dotnet_diagnostic.CA1822.severity = warning +dotnet_diagnostic.CA1823.severity = warning +dotnet_diagnostic.CA1824.severity = warning + +dotnet_diagnostic.CA1900.severity = warning +dotnet_diagnostic.CA1901.severity = warning +dotnet_diagnostic.CA1903.severity = warning + +dotnet_diagnostic.CA2001.severity = warning +dotnet_diagnostic.CA2002.severity = warning +dotnet_diagnostic.CA2003.severity = warning +dotnet_diagnostic.CA2004.severity = warning +dotnet_diagnostic.CA2006.severity = warning +dotnet_diagnostic.CA2100.severity = warning +dotnet_diagnostic.CA2101.severity = warning +dotnet_diagnostic.CA2102.severity = warning +dotnet_diagnostic.CA2103.severity = warning +dotnet_diagnostic.CA2104.severity = warning +dotnet_diagnostic.CA2105.severity = warning +dotnet_diagnostic.CA2106.severity = warning +dotnet_diagnostic.CA2107.severity = warning +dotnet_diagnostic.CA2108.severity = warning +dotnet_diagnostic.CA2109.severity = warning +dotnet_diagnostic.CA2111.severity = warning +dotnet_diagnostic.CA2112.severity = warning +dotnet_diagnostic.CA2114.severity = warning +dotnet_diagnostic.CA2115.severity = warning +dotnet_diagnostic.CA2116.severity = warning +dotnet_diagnostic.CA2117.severity = warning +dotnet_diagnostic.CA2118.severity = warning +dotnet_diagnostic.CA2119.severity = warning +dotnet_diagnostic.CA2120.severity = warning +dotnet_diagnostic.CA2121.severity = warning +dotnet_diagnostic.CA2122.severity = warning +dotnet_diagnostic.CA2123.severity = warning +dotnet_diagnostic.CA2124.severity = warning +dotnet_diagnostic.CA2126.severity = warning +dotnet_diagnostic.CA2130.severity = warning +dotnet_diagnostic.CA2131.severity = warning +dotnet_diagnostic.CA2132.severity = warning +dotnet_diagnostic.CA2133.severity = warning +dotnet_diagnostic.CA2134.severity = warning +dotnet_diagnostic.CA2135.severity = warning +dotnet_diagnostic.CA2136.severity = warning +dotnet_diagnostic.CA2137.severity = warning +dotnet_diagnostic.CA2138.severity = warning +dotnet_diagnostic.CA2139.severity = warning +dotnet_diagnostic.CA2140.severity = warning +dotnet_diagnostic.CA2141.severity = warning +dotnet_diagnostic.CA2142.severity = warning +dotnet_diagnostic.CA2143.severity = warning +dotnet_diagnostic.CA2144.severity = warning +dotnet_diagnostic.CA2145.severity = warning +dotnet_diagnostic.CA2146.severity = warning +dotnet_diagnostic.CA2147.severity = warning +dotnet_diagnostic.CA2149.severity = warning + +dotnet_diagnostic.CA2201.severity = warning +dotnet_diagnostic.CA2202.severity = warning +dotnet_diagnostic.CA2204.severity = warning +dotnet_diagnostic.CA2205.severity = warning +dotnet_diagnostic.CA2207.severity = warning +dotnet_diagnostic.CA2208.severity = warning +dotnet_diagnostic.CA2210.severity = warning +dotnet_diagnostic.CA2211.severity = warning +dotnet_diagnostic.CA2212.severity = warning +dotnet_diagnostic.CA2213.severity = warning +dotnet_diagnostic.CA2214.severity = warning +dotnet_diagnostic.CA2215.severity = warning +dotnet_diagnostic.CA2216.severity = warning +dotnet_diagnostic.CA2217.severity = warning +dotnet_diagnostic.CA2219.severity = warning +dotnet_diagnostic.CA2220.severity = warning +dotnet_diagnostic.CA2221.severity = warning +dotnet_diagnostic.CA2222.severity = warning +dotnet_diagnostic.CA2223.severity = warning +dotnet_diagnostic.CA2224.severity = warning +dotnet_diagnostic.CA2225.severity = warning +dotnet_diagnostic.CA2226.severity = warning +dotnet_diagnostic.CA2227.severity = warning +dotnet_diagnostic.CA2228.severity = warning +dotnet_diagnostic.CA2229.severity = warning +dotnet_diagnostic.CA2230.severity = warning +dotnet_diagnostic.CA2231.severity = warning +dotnet_diagnostic.CA2232.severity = warning +dotnet_diagnostic.CA2233.severity = warning +dotnet_diagnostic.CA2234.severity = warning +dotnet_diagnostic.CA2235.severity = warning +dotnet_diagnostic.CA2236.severity = warning +dotnet_diagnostic.CA2237.severity = warning +dotnet_diagnostic.CA2238.severity = warning +dotnet_diagnostic.CA2239.severity = warning +dotnet_diagnostic.CA2240.severity = warning +dotnet_diagnostic.CA2241.severity = warning +dotnet_diagnostic.CA2242.severity = warning +dotnet_diagnostic.CA2243.severity = warning diff --git a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/Benchmarks.System.Reactive.csproj b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/Benchmarks.System.Reactive.csproj index 2c660aaed4..05964d76a1 100644 --- a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/Benchmarks.System.Reactive.csproj +++ b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/Benchmarks.System.Reactive.csproj @@ -8,6 +8,22 @@ Current Sources;Rx.net 3.1.1;Rx.net 4.0 + + + + 7.0-none + 7.0-none + $(NoWarn);IDE1006 + + + + + + + $(DefineConstants);RX3_1_1 diff --git a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/CombineLatestBenchmark.cs b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/CombineLatestBenchmark.cs index abd96e4d90..2babf600fd 100644 --- a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/CombineLatestBenchmark.cs +++ b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/CombineLatestBenchmark.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// 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. @@ -10,7 +10,7 @@ namespace Benchmarks.System.Reactive [MemoryDiagnoser] public class CombineLatestBenchmark { - private CombineLatestTest _zipTest = new CombineLatestTest(); + private readonly CombineLatestTest _zipTest = new(); [Benchmark] public void CombineLatest_Typical2() diff --git a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ComparisonAsyncBenchmark.cs b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ComparisonAsyncBenchmark.cs index ddf8967131..24fb752f29 100644 --- a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ComparisonAsyncBenchmark.cs +++ b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ComparisonAsyncBenchmark.cs @@ -18,8 +18,8 @@ public class ComparisonAsyncBenchmark public int N; private int _store; - IScheduler _scheduler1; - IScheduler _scheduler2; + private IScheduler _scheduler1; + private IScheduler _scheduler2; [GlobalSetup] public void Setup() diff --git a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ComparisonBenchmark.cs b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ComparisonBenchmark.cs index ee65c871c0..7080c8e6ef 100644 --- a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ComparisonBenchmark.cs +++ b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ComparisonBenchmark.cs @@ -25,7 +25,7 @@ public class ComparisonBenchmark public void ForLoopBaseLine() { var n = N; - for (var i = 0; i < N; i++) + for (var i = 0; i < n; i++) { Volatile.Write(ref _store, i); } diff --git a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/PrependVsStartWtihBenchmark.cs b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/PrependVsStartWtihBenchmark.cs index 2bafdeff8f..6d1cc93605 100644 --- a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/PrependVsStartWtihBenchmark.cs +++ b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/PrependVsStartWtihBenchmark.cs @@ -15,7 +15,9 @@ namespace Benchmarks.System.Reactive public class PrependVsStartWtihBenchmark { private int _store; +#pragma warning disable IDE0052 // (Remove unread private members.) We want to store results to prevent the benchmarked code from being optimized out of existence. private IObservable _obsStore; +#pragma warning restore IDE0052 [Benchmark(Baseline = true)] public void Prepend() @@ -35,7 +37,7 @@ public void Prepend_Create() } - static readonly IObservable _prependObservable = Observable.Empty().Prepend(0); + private static readonly IObservable _prependObservable = Observable.Empty().Prepend(0); [Benchmark] public void Prepend_Subscribe() { @@ -60,7 +62,7 @@ public void StartWith_Create() .StartWith(0); } - static readonly IObservable _startWithObservable = Observable.Empty().StartWith(0); + private static readonly IObservable _startWithObservable = Observable.Empty().StartWith(0); [Benchmark] public void StartWith_Subscribe() { diff --git a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ZipBenchmark.cs b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ZipBenchmark.cs index 2ff793c1b6..a551b5b4af 100644 --- a/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ZipBenchmark.cs +++ b/Rx.NET/Source/benchmarks/Benchmarks.System.Reactive/ZipBenchmark.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// 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. @@ -10,7 +10,7 @@ namespace Benchmarks.System.Reactive [MemoryDiagnoser] public class ZipBenchmark { - private ZipTest _zipTest = new ZipTest(); + private readonly ZipTest _zipTest = new(); [Benchmark] public void Zip_NAry_Asymmetric() diff --git a/Rx.NET/Source/src/.editorconfig b/Rx.NET/Source/src/.editorconfig new file mode 100644 index 0000000000..95ec69576e --- /dev/null +++ b/Rx.NET/Source/src/.editorconfig @@ -0,0 +1,70 @@ +[*.cs] +# Suppress spurious 'unnecessary suppression' reports. +# +# A load of these come from CA1704. We currently can't use this, but want to reinstate it at some +# point, so we don't want to delete all of the suppression attributes that used to suppress the +# spurious reports the old StyleCop-era CA1704 analyzer produced. We expect to need most of those +# attributes if we manage to re-instate CA1704. But since CA1704 is currently not enabled, these +# suppression attributes would produce an IDE0079 (Remove unnecessary suppression) message. We +# disable IDE0079 for CA1704 so that we can leave these suppressions in place, ready for when +# CA1704 might be restored. +# So why aren't we using CA1704? The CA1704 current analyzer is essentially broken. Microsoft +# never ported this analyzer into the new world of Roslyn-based code analyzers. This is not +# obvious because the source for a new CA1704 analyzer does in fact exist, and it's in the same +# repo as all the supported ones. However, it's deemed to be an unsupported community effort, +# it lives in its own NuGet package (with the surprisingly generic name of Text.Analyzers). +# It has two serious flaws: +# https://github.com/dotnet/roslyn-analyzers/issues/6024 - it can't be configured to ignore +# private symbols +# https://github.com/dotnet/roslyn-analyzers/issues/5183 - its definition of 'unmeaningful' is +# too broad, and can't be disabled +# The first issue could perhaps be circumvented by adding a few entries to a custom dictionary, but +# the second is impossible to work around. The analyzer describes type arguments of the form `T1`, +# `T2` etc as 'meaningless' # and there's no way to stop that. This is a significant problem for Rx, +# because we have quite a lot of methods with large numbers of generic type arguments in which the +# meaning of those type arguments is entirely up to application code, so there's simply no way for +# us to give them meaningful names. As with .NET runtime library types like Action we +# just use names like T1, T2, T3. The names are deliberately meaningless, because they represent +# placeholders for application types that will signify whatever the application wants to signify. +# So there are no better names, and in any case it would technically be a breaking change to +# rename them. We might be able to deal with this by adding enormous numbers of suppressions, but +# it would be better for the CA1704 analyzer to be fixed - we aren't the only users for which this +# is a major issue. +# We also disable suppression warnings for CA1711. It's currently a mystery why that's being +# reported as unnecessary on ObservableEx, but it is, so we've squelched it. +# IL2060 is considered unnecessary on targets that don't support trimming, but we don't want to wrap every +# single one in a conditional, so we also suppress warnings about unnecessary suppressions on those. +dotnet_remove_unnecessary_suppression_exclusions = CA1704,CA1711,IL2060 + + +# Prevent IDE1006 (Naming rule violation) errors for non-public fields. +# +# Unfortunately, the codebase has not historically been entirely consistent with internal naming +# conventions. Apparently this wasn't noticed by older analyzer tooling, but as of the .NET 7 +# era, the naming rules analyzers are a bit more particular, and cannot be configured in a way +# that makes them happy with the code as it stands. We could rename all the relevant symbols, +# but that doesn't seem like an especially good use of time, so for now, we're suppressing +# diagnostics in certain cases. +# +# Static readonly fields +dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.severity = none + +# Internal fields +dotnet_naming_symbols.internal_field_symbols.applicable_kinds = field +dotnet_naming_symbols.internal_field_symbols.applicable_accessibilities = internal + +dotnet_naming_rule.internal_instance_fields_must_be_camel_cased_underscore_prefix.symbols = internal_field_symbols +dotnet_naming_rule.internal_instance_fields_must_be_camel_cased_underscore_prefix.style = camel_case_and_prefix_with_underscore_style +dotnet_naming_rule.internal_instance_fields_must_be_camel_cased_underscore_prefix.severity = none + +# Protected fields +# Annoyingly, a protected field in an internal class cannot be distinguished from a protected field in a public +# class. That's unfortunate, because the latter are publicly visible, but the former are not, so we don't really +# want to enforce public naming conventions on them. We generally avoid publicly visible fields, so the majority +# of protected fields are in fact in internal types, so we use naming conventions appropriate to those. +dotnet_naming_symbols.protected_field_symbols.applicable_kinds = field +dotnet_naming_symbols.protected_field_symbols.applicable_accessibilities = protected + +dotnet_naming_rule.protected_instance_fields_must_be_camel_cased_underscore_prefix.symbols = protected_field_symbols +dotnet_naming_rule.protected_instance_fields_must_be_camel_cased_underscore_prefix.style = camel_case_and_prefix_with_underscore_style +dotnet_naming_rule.protected_instance_fields_must_be_camel_cased_underscore_prefix.severity = none diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/ColdObservable.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/ColdObservable.cs index 818fd03691..fccbb2d0fc 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 List(); + private readonly List _subscriptions = new(); public ColdObservable(TestScheduler scheduler, params Recorded>[] messages) { diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/GlobalSuppressions.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/GlobalSuppressions.cs index 3941fe680e..11d269bffd 100644 --- a/Rx.NET/Source/src/Microsoft.Reactive.Testing/GlobalSuppressions.cs +++ b/Rx.NET/Source/src/Microsoft.Reactive.Testing/GlobalSuppressions.cs @@ -13,8 +13,8 @@ // You do not need to add suppressions to this file manually. [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1053:StaticHolderTypesShouldNotHaveConstructors", Scope = "type", Target = "Microsoft.Reactive.Testing.ReactiveTest")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1053:StaticHolderTypesShouldNotHaveConstructors", Scope = "type", Target = "~T:Microsoft.Reactive.Testing.ReactiveTest")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1014:MarkAssembliesWithClsCompliant")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Scope = "member", Target = "Microsoft.Reactive.Testing.ReactiveAssert.#Throws`1(System.Action,System.String)")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Scope = "member", Target = "Microsoft.Reactive.Testing.ReactiveAssert.#Throws`1(System.Action)")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Scope = "member", Target = "~M:Microsoft.Reactive.Testing.ReactiveAssert.Throws``1(System.Action,System.String)")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Scope = "member", Target = "~M:Microsoft.Reactive.Testing.ReactiveAssert.Throws``1(System.Action)")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1016:MarkAssembliesWithAssemblyVersion")] diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/HotObservable.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/HotObservable.cs index 02ff033b1d..240f2492be 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 List>(); - private readonly List _subscriptions = new List(); + private readonly List> _observers = new(); + private readonly List _subscriptions = new(); private readonly Recorded>[] _messages; public HotObservable(TestScheduler scheduler, params Recorded>[] messages) diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/Microsoft.Reactive.Testing.csproj b/Rx.NET/Source/src/Microsoft.Reactive.Testing/Microsoft.Reactive.Testing.csproj index 8a7ad6507e..9b04d2acb7 100644 --- a/Rx.NET/Source/src/Microsoft.Reactive.Testing/Microsoft.Reactive.Testing.csproj +++ b/Rx.NET/Source/src/Microsoft.Reactive.Testing/Microsoft.Reactive.Testing.csproj @@ -7,8 +7,12 @@ $(DefineConstants);PLATFORM_DOTNET;XUNIT_VISIBILITY_INTERNAL Rx;Reactive;Extensions;Observable;LINQ;Events Reactive Extensions (Rx) for .NET - Testing Library - - $(NoWarn);IDE0054;IDE0066;CA1305;CA1307;CA1032;CA1064;CA1822;CA1812;CA1820;CA1823 + + $(NoWarn);IDE0054;IDE0066;CA1305;CA1307;CA1032;CA1064;CA1704;CA1822;CA1812;CA1820;CA1823;CA1825;CA1845;CA2249;IDE0016;IDE0018;IDE0019;IDE0020;IDE0031;IDE0039;IDE0044;IDE0059;IDE0074;IDE0270 + + + + 7.0-None diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs index 2ec72f8afe..78608816f5 100644 --- a/Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs +++ b/Rx.NET/Source/src/Microsoft.Reactive.Testing/MockObserver.cs @@ -10,12 +10,12 @@ namespace Microsoft.Reactive.Testing { internal class MockObserver : ITestableObserver { - private TestScheduler _scheduler; - private List>> _messages; + private readonly TestScheduler _scheduler; + private readonly List>> _messages; public MockObserver(TestScheduler scheduler) { - this._scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); + _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); _messages = new List>>(); } diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/ReactiveTest.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/ReactiveTest.cs index 836b8c3e7d..a33ebb10d1 100644 --- a/Rx.NET/Source/src/Microsoft.Reactive.Testing/ReactiveTest.cs +++ b/Rx.NET/Source/src/Microsoft.Reactive.Testing/ReactiveTest.cs @@ -10,7 +10,9 @@ namespace Microsoft.Reactive.Testing /// /// Base class to write unit tests for applications and libraries built using Reactive Extensions. /// +#pragma warning disable CA1052 // (Static holder types should be Static or NotInheritable). Tests inherit from this to bring static members into scope public class ReactiveTest +#pragma warning restore CA1052 { /// /// Default virtual time used for creation of observable sequences in -based unit tests. @@ -75,7 +77,9 @@ public static Recorded> OnCompleted(long ticks) /// Recorded virtual time the OnCompleted notification occurs. /// Object solely used to infer the type of the type parameter. This parameter is typically used when creating a sequence of anonymously typed elements. /// Recorded OnCompleted notification. +#pragma warning disable IDE0060 // (Remove unused parameter.) Required for type inference public static Recorded> OnCompleted(long ticks, T witness) +#pragma warning restore IDE0060 { return new Recorded>(ticks, Notification.CreateOnCompleted()); } @@ -125,7 +129,9 @@ public static Recorded> OnError(long ticks, FuncObject solely used to infer the type of the type parameter. This parameter is typically used when creating a sequence of anonymously typed elements. /// Recorded OnError notification. /// is null. +#pragma warning disable IDE0060 // (Remove unused parameter.) Required for type inference public static Recorded> OnError(long ticks, Exception exception, T witness) +#pragma warning restore IDE0060 { if (exception == null) { @@ -144,7 +150,9 @@ public static Recorded> OnError(long ticks, Exception excepti /// Object solely used to infer the type of the type parameter. This parameter is typically used when creating a sequence of anonymously typed elements. /// Recorded OnError notification with a predicate to assert a given exception. /// is null. +#pragma warning disable IDE0060 // (Remove unused parameter.) Required for type inference public static Recorded> OnError(long ticks, Func predicate, T witness) +#pragma warning restore IDE0060 { if (predicate == null) { diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/Recorded.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/Recorded.cs index a4bc9d8413..aaebf8822e 100644 --- a/Rx.NET/Source/src/Microsoft.Reactive.Testing/Recorded.cs +++ b/Rx.NET/Source/src/Microsoft.Reactive.Testing/Recorded.cs @@ -70,7 +70,7 @@ public Recorded(long time, T value) /// /// The System.Object to compare with the current value. /// true if the specified System.Object is equal to the current value; otherwise, false. - public override bool Equals(object obj) => obj is Recorded && Equals((Recorded)obj); + public override bool Equals(object obj) => obj is Recorded recorded && Equals(recorded); /// /// Returns the hash code for the current value. diff --git a/Rx.NET/Source/src/Microsoft.Reactive.Testing/Subscription.cs b/Rx.NET/Source/src/Microsoft.Reactive.Testing/Subscription.cs index 4c0bb0f5b9..ee7e170c79 100644 --- a/Rx.NET/Source/src/Microsoft.Reactive.Testing/Subscription.cs +++ b/Rx.NET/Source/src/Microsoft.Reactive.Testing/Subscription.cs @@ -83,7 +83,7 @@ public Subscription(long subscribe, long unsubscribe) /// /// The System.Object to compare with the current Subscription value. /// true if the specified System.Object is equal to the current Subscription value; otherwise, false. - public override bool Equals(object obj) => obj is Subscription && Equals((Subscription)obj); + public override bool Equals(object obj) => obj is Subscription subscription && Equals(subscription); /// /// Returns the hash code for the current Subscription value. diff --git a/Rx.NET/Source/src/System.Reactive.Observable.Aliases/Observable.Aliases.cs b/Rx.NET/Source/src/System.Reactive.Observable.Aliases/Observable.Aliases.cs index 5a827826b9..65504c126a 100644 --- a/Rx.NET/Source/src/System.Reactive.Observable.Aliases/Observable.Aliases.cs +++ b/Rx.NET/Source/src/System.Reactive.Observable.Aliases/Observable.Aliases.cs @@ -1,9 +1,7 @@ -// Licensed to the .NET Foundation under one or more agreements. +// 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. -#pragma warning disable 1591 - using System.Collections.Generic; using System.Reactive.Linq; using System.Reactive.Threading.Tasks; // needed for doc comments @@ -411,5 +409,3 @@ public static IObservable Filter(this IObservable sou } } - -#pragma warning restore 1591 diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/AsyncLock.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/AsyncLock.cs index 5af400b680..9bfce6eaa8 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/AsyncLock.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/AsyncLock.cs @@ -13,7 +13,7 @@ public sealed class AsyncLock : IDisposable { private bool _isAcquired; private bool _hasFaulted; - private readonly object _guard = new object(); + private readonly object _guard = new(); private Queue<(Action action, Delegate @delegate, object? state)>? _queue; /// diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayer.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayer.cs index 8622defc74..8ddd786daf 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayer.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayer.cs @@ -19,14 +19,12 @@ internal static class ConcurrencyAbstractionLayer private static IConcurrencyAbstractionLayer Initialize() { -#pragma warning disable CS0618 // Type or member is obsolete // // NB: For compat reasons, we allow null to leak here. Bad things will happen but we don't want // to trigger an exception earlier than we did before. The only case where this can happen // is when a custom PEP is installed, which is very rare (e.g. debugger, service hosting). // return PlatformEnlightenmentProvider.Current.GetService()!; -#pragma warning restore CS0618 // Type or member is obsolete } } diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayerImpl.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayerImpl.cs index beb52f0735..d260909283 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayerImpl.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/ConcurrencyAbstractionLayerImpl.cs @@ -155,7 +155,7 @@ private sealed class Timer : IDisposable private Action _action; private SingleAssignmentDisposableValue _timer; - private static readonly object DisposedState = new object(); + private static readonly object DisposedState = new(); public Timer(Action action, object? state, TimeSpan dueTime) { diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/CurrentThreadScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/CurrentThreadScheduler.cs index a108dd4a3c..aa3bb7ef1d 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/CurrentThreadScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/CurrentThreadScheduler.cs @@ -12,7 +12,7 @@ namespace System.Reactive.Concurrency /// Singleton instance of this type exposed through this static property. public sealed class CurrentThreadScheduler : LocalScheduler { - private static readonly Lazy StaticInstance = new Lazy(() => new CurrentThreadScheduler()); + private static readonly Lazy StaticInstance = new(() => new CurrentThreadScheduler()); private CurrentThreadScheduler() { @@ -43,10 +43,7 @@ private static TimeSpan Time { get { - if (_clock == null) - { - _clock = ConcurrencyAbstractionLayer.Current.StartStopwatch(); - } + _clock ??= ConcurrencyAbstractionLayer.Current.StartStopwatch(); return _clock.Elapsed; } @@ -55,7 +52,6 @@ private static TimeSpan Time /// /// Gets a value that indicates whether the caller must call a Schedule method. /// - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Now marked as obsolete.")] [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete(Constants_Core.ObsoleteSchedulerequired)] // Preferring static method call over instance method call. public bool ScheduleRequired => IsScheduleRequired; diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/DefaultScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/DefaultScheduler.cs index 7e670a899f..a3220ec4ac 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/DefaultScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/DefaultScheduler.cs @@ -12,7 +12,7 @@ namespace System.Reactive.Concurrency /// Singleton instance of this type exposed through this static property. public sealed class DefaultScheduler : LocalScheduler, ISchedulerPeriodic { - private static readonly Lazy DefaultInstance = new Lazy(() => new DefaultScheduler()); + private static readonly Lazy DefaultInstance = new(() => new DefaultScheduler()); private static readonly IConcurrencyAbstractionLayer Cal = ConcurrencyAbstractionLayer.Current; /// @@ -110,7 +110,7 @@ private sealed class PeriodicallyScheduledWorkItem : IDisposable private TState _state; private Func _action; private readonly IDisposable _cancel; - private readonly AsyncLock _gate = new AsyncLock(); + private readonly AsyncLock _gate = new(); public PeriodicallyScheduledWorkItem(TState state, TimeSpan period, Func action) { diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs index 30c287767a..8a13936d25 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/EventLoopScheduler.cs @@ -199,7 +199,7 @@ private sealed class PeriodicallyScheduledWorkItem : IDisposable private readonly TimeSpan _period; private readonly Func _action; private readonly EventLoopScheduler _scheduler; - private readonly AsyncLock _gate = new AsyncLock(); + private readonly AsyncLock _gate = new(); private TState _state; private TimeSpan _next; diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/HistoricalScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/HistoricalScheduler.cs index e56b7ae82a..0ba493a069 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/HistoricalScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/HistoricalScheduler.cs @@ -74,7 +74,7 @@ protected override DateTimeOffset Add(DateTimeOffset absolute, TimeSpan relative "\\}")] public class HistoricalScheduler : HistoricalSchedulerBase { - private readonly SchedulerQueue _queue = new SchedulerQueue(); + private readonly SchedulerQueue _queue = new(); /// /// Creates a new historical scheduler with the minimum value of as the initial clock value. diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/ImmediateScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/ImmediateScheduler.cs index d5b3df8ca9..0e792cbcb0 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/ImmediateScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/ImmediateScheduler.cs @@ -12,7 +12,7 @@ namespace System.Reactive.Concurrency /// Singleton instance of this type exposed through this static property. public sealed class ImmediateScheduler : LocalScheduler { - private static readonly Lazy StaticInstance = new Lazy(static () => new ImmediateScheduler()); + private static readonly Lazy StaticInstance = new(static () => new ImmediateScheduler()); private ImmediateScheduler() { @@ -79,10 +79,7 @@ public override IDisposable Schedule(TState state, Func(TState state, TimeSpan dueTime, Func /// Gate to protect local scheduler queues. /// - private static readonly object Gate = new object(); + private static readonly object Gate = new(); /// /// Gate to protect queues and to synchronize scheduling decisions and system clock /// change management. /// - private static readonly object StaticGate = new object(); + private static readonly object StaticGate = new(); /// /// Long term work queue. Contains work that's due beyond SHORTTERM, computed at the /// time of enqueueing. /// - private static readonly PriorityQueue LongTerm = new PriorityQueue(); + private static readonly PriorityQueue LongTerm = new(); /// /// Disposable resource for the long term timer that will reevaluate and dispatch the /// first item in the long term queue. A serial disposable is used to make "dispose /// current and assign new" logic easier. The disposable itself is never disposed. /// - private static readonly SerialDisposable NextLongTermTimer = new SerialDisposable(); + private static readonly SerialDisposable NextLongTermTimer = new(); /// /// Item at the head of the long term queue for which the current long term timer is @@ -49,13 +49,13 @@ public partial class LocalScheduler /// items. This queue is kept in order to be able to relocate short term items back /// to the long term queue in case a system clock change occurs. /// - private readonly PriorityQueue _shortTerm = new PriorityQueue(); + private readonly PriorityQueue _shortTerm = new(); /// /// 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 HashSet(); + private readonly HashSet _shortTermWork = new(); /// /// Threshold where an item is considered to be short term work or gets moved from @@ -104,7 +104,6 @@ public partial class LocalScheduler /// /// Creates a new local scheduler. /// - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline", Justification = "We can't really lift this into a field initializer, and would end up checking for an initialization flag in every static method anyway (which is roughly what the JIT does in a thread-safe manner).")] protected LocalScheduler() { // diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/NewThreadScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/NewThreadScheduler.cs index 6262ac4fca..b58908509f 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/NewThreadScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/NewThreadScheduler.cs @@ -12,7 +12,7 @@ namespace System.Reactive.Concurrency /// public sealed class NewThreadScheduler : LocalScheduler, ISchedulerLongRunning, ISchedulerPeriodic { - private static readonly Lazy Instance = new Lazy(static () => new NewThreadScheduler()); + private static readonly Lazy Instance = new(static () => new NewThreadScheduler()); private readonly Func _threadFactory; @@ -130,7 +130,7 @@ private sealed class Periodic : IDisposable private readonly TimeSpan _period; private readonly Func _action; - private readonly object _cancel = new object(); + private readonly object _cancel = new(); private volatile bool _done; private TState _state; diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/ScheduledItem.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/ScheduledItem.cs index 44563c6bba..50291f178b 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/ScheduledItem.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/ScheduledItem.cs @@ -11,6 +11,7 @@ namespace System.Reactive.Concurrency /// Abstract base class for scheduled work items. /// /// Absolute time representation type. +#pragma warning disable CA1033, CA1063, CA1816 // (Overridable IDisposable.) This is a specialized base type, and it would be inappropriate to encourage anyone to build derived types that do more in Dispose. public abstract class ScheduledItem : IScheduledItem, IComparable>, IDisposable where TAbsolute : IComparable { @@ -155,6 +156,7 @@ public int CompareTo(ScheduledItem? other) void IDisposable.Dispose() => Cancel(); } +#pragma warning restore CA1033, CA1063, CA1816 /// /// Represents a scheduled work item based on the materialization of an IScheduler.Schedule method call. diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Async.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Async.cs index 2c80285d57..bc07404ce2 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Async.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Async.cs @@ -12,7 +12,7 @@ public static partial class Scheduler { private sealed class AsyncInvocation : IDisposable { - private readonly CancellationTokenSource _cts = new CancellationTokenSource(); + private readonly CancellationTokenSource _cts = new(); private SingleAssignmentDisposableValue _run; public IDisposable Run(IScheduler self, TState s, Func> action) diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.Emulation.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.Emulation.cs index e785ab0682..582f45cdba 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.Emulation.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Services.Emulation.cs @@ -335,8 +335,8 @@ public SchedulePeriodicStopwatch(IScheduler scheduler, TState state, TimeSpan pe private TState _state; - private readonly object _gate = new object(); - private readonly AutoResetEvent _resumeEvent = new AutoResetEvent(false); + private readonly object _gate = new(); + private readonly AutoResetEvent _resumeEvent = new(false); private volatile int _runState; private IStopwatch? _stopwatch; private TimeSpan _nextDue; diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.cs index ac350991b5..d101b3ea88 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.cs @@ -60,7 +60,7 @@ public static partial class Scheduler // - private static readonly Lazy _threadPool = new Lazy(static () => Initialize("ThreadPool")); + private static readonly Lazy _threadPool = new(static () => Initialize("ThreadPool")); /// /// Gets a scheduler that schedules work on the thread pool. @@ -68,7 +68,7 @@ public static partial class Scheduler [Obsolete(Constants_Core.ObsoleteSchedulerThreadpool)] public static IScheduler ThreadPool => _threadPool.Value; - private static readonly Lazy _newThread = new Lazy(static () => Initialize("NewThread")); + private static readonly Lazy _newThread = new(static () => Initialize("NewThread")); /// /// Gets a scheduler that schedules work on a new thread using default thread creation options. @@ -76,7 +76,7 @@ public static partial class Scheduler [Obsolete(Constants_Core.ObsoleteSchedulerNewthread)] public static IScheduler NewThread => _newThread.Value; - private static readonly Lazy _taskPool = new Lazy(static () => Initialize("TaskPool")); + private static readonly Lazy _taskPool = new(static () => Initialize("TaskPool")); /// /// Gets a scheduler that schedules work on Task Parallel Library (TPL) task pool using the default TaskScheduler. @@ -86,15 +86,8 @@ public static partial class Scheduler private static IScheduler Initialize(string name) { -#pragma warning disable CS0618 // Type or member is obsolete - var res = PlatformEnlightenmentProvider.Current.GetService(name); -#pragma warning restore CS0618 // Type or member is obsolete - if (res == null) - { - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings_Core.CANT_OBTAIN_SCHEDULER, name)); - } - - return res; + return PlatformEnlightenmentProvider.Current.GetService(name) + ?? throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Strings_Core.CANT_OBTAIN_SCHEDULER, name)); } } } diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerOperation.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerOperation.cs index 8107e40a25..77e86c2818 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerOperation.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerOperation.cs @@ -18,11 +18,11 @@ public sealed class SchedulerOperation private readonly bool _postBackToOriginalContext; internal SchedulerOperation(Func schedule, CancellationToken cancellationToken) - : this(schedule, cancellationToken, false) + : this(schedule, false, cancellationToken) { } - internal SchedulerOperation(Func schedule, CancellationToken cancellationToken, bool postBackToOriginalContext) + internal SchedulerOperation(Func schedule, bool postBackToOriginalContext, CancellationToken cancellationToken) { _schedule = schedule; _cancellationToken = cancellationToken; @@ -36,7 +36,7 @@ internal SchedulerOperation(Func schedule, CancellationToke /// Scheduler operation object with configured await behavior. public SchedulerOperation ConfigureAwait(bool continueOnCapturedContext) { - return new SchedulerOperation(_schedule, _cancellationToken, continueOnCapturedContext); + return new SchedulerOperation(_schedule, continueOnCapturedContext, _cancellationToken); } /// @@ -45,7 +45,7 @@ public SchedulerOperation ConfigureAwait(bool continueOnCapturedContext) /// Awaiter for the scheduler operation. public SchedulerOperationAwaiter GetAwaiter() { - return new SchedulerOperationAwaiter(_schedule, _cancellationToken, _postBackToOriginalContext); + return new SchedulerOperationAwaiter(_schedule, _postBackToOriginalContext, _cancellationToken); } } @@ -60,7 +60,7 @@ public sealed class SchedulerOperationAwaiter : INotifyCompletion private readonly bool _postBackToOriginalContext; private readonly CancellationTokenRegistration _ctr; - internal SchedulerOperationAwaiter(Func schedule, CancellationToken cancellationToken, bool postBackToOriginalContext) + internal SchedulerOperationAwaiter(Func schedule, bool postBackToOriginalContext, CancellationToken cancellationToken) { _schedule = schedule; _cancellationToken = cancellationToken; diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs index 23ee3faf3d..5ab8535f9c 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerWrapper.cs @@ -69,7 +69,7 @@ protected IScheduler GetRecursiveWrapper(IScheduler scheduler) public object? GetService(Type serviceType) { - if (!(_scheduler is IServiceProvider serviceProvider)) + if (_scheduler is not IServiceProvider serviceProvider) { return null; } diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.ObserveOn.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.ObserveOn.cs index 1f8bd4f7e8..864acf9340 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.ObserveOn.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.ObserveOn.cs @@ -22,9 +22,8 @@ public Scheduler(IObservable source, IScheduler scheduler) _scheduler = scheduler; } - protected override ObserveOnObserverNew CreateSink(IObserver observer) => new ObserveOnObserverNew(_scheduler, observer); + protected override ObserveOnObserverNew CreateSink(IObserver observer) => new(_scheduler, observer); - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Justification = "Visibility restricted to friend assemblies. Those should be correct by inspection.")] protected override void Run(ObserveOnObserverNew sink) => sink.Run(_source); } @@ -42,9 +41,8 @@ public SchedulerLongRunning(IObservable source, ISchedulerLongRunning s _scheduler = scheduler; } - protected override ObserveOnObserverLongRunning CreateSink(IObserver observer) => new ObserveOnObserverLongRunning(_scheduler, observer); + protected override ObserveOnObserverLongRunning CreateSink(IObserver observer) => new(_scheduler, observer); - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Justification = "Visibility restricted to friend assemblies. Those should be correct by inspection.")] protected override void Run(ObserveOnObserverLongRunning sink) => sink.Run(_source); } @@ -59,9 +57,8 @@ public Context(IObservable source, SynchronizationContext context) _context = context; } - protected override _ CreateSink(IObserver observer) => new _(_context, observer); + protected override _ CreateSink(IObserver observer) => new(_context, observer); - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Justification = "Visibility restricted to friend assemblies. Those should be correct by inspection.")] protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : IdentitySink diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.Synchronize.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.Synchronize.cs index bbfdeb3979..b8579e72ac 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.Synchronize.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/Synchronization.Synchronize.cs @@ -20,9 +20,8 @@ public Synchronize(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Justification = "Visibility restricted to friend assemblies. Those should be correct by inspection.")] protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : IdentitySink diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/TaskObservationOptions.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/TaskObservationOptions.cs index 46e090430c..74fa071a19 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/TaskObservationOptions.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/TaskObservationOptions.cs @@ -85,7 +85,7 @@ public TaskObservationOptions( /// public bool IgnoreExceptionsAfterUnsubscribe { get; } - internal Value ToValue() => new Value(this.Scheduler, this.IgnoreExceptionsAfterUnsubscribe); + internal Value ToValue() => new(Scheduler, IgnoreExceptionsAfterUnsubscribe); /// /// Value-type representation. diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/TaskPoolScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/TaskPoolScheduler.cs index 7a6e8e6618..ee3af96936 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/TaskPoolScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/TaskPoolScheduler.cs @@ -147,7 +147,7 @@ public void Dispose() public bool IsDisposed => _cancel.IsDisposed; } - private static readonly Lazy LazyInstance = new Lazy(static () => new TaskPoolScheduler(new TaskFactory(TaskScheduler.Default))); + private static readonly Lazy LazyInstance = new(static () => new TaskPoolScheduler(new TaskFactory(TaskScheduler.Default))); private readonly TaskFactory _taskFactory; /// @@ -272,8 +272,8 @@ private sealed class PeriodicallyScheduledWorkItem : IDisposable private readonly TimeSpan _period; private readonly TaskFactory _taskFactory; private readonly Func _action; - private readonly AsyncLock _gate = new AsyncLock(); - private readonly CancellationTokenSource _cts = new CancellationTokenSource(); + private readonly AsyncLock _gate = new(); + private readonly CancellationTokenSource _cts = new(); public PeriodicallyScheduledWorkItem(TState state, TimeSpan period, Func action, TaskFactory taskFactory) { diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.Windows.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.Windows.cs index b1387c81b3..c7bd55fc48 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.Windows.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.Windows.cs @@ -15,7 +15,7 @@ namespace System.Reactive.Concurrency [CLSCompliant(false)] public sealed class ThreadPoolScheduler : LocalScheduler, ISchedulerPeriodic { - private static readonly Lazy LazyDefault = new Lazy(static () => new ThreadPoolScheduler()); + private static readonly Lazy LazyDefault = new(static () => new ThreadPoolScheduler()); /// /// Constructs a ThreadPoolScheduler that schedules units of work on the Windows ThreadPool. @@ -161,7 +161,7 @@ private sealed class PeriodicallyScheduledWorkItem : IDisposable private Func _action; private readonly ThreadPoolTimer _timer; - private readonly AsyncLock _gate = new AsyncLock(); + private readonly AsyncLock _gate = new(); public PeriodicallyScheduledWorkItem(TState state, TimeSpan period, Func action) { diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.cs index 5696a922c5..d9163ece90 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/ThreadPoolScheduler.cs @@ -14,8 +14,8 @@ namespace System.Reactive.Concurrency /// Singleton instance of this type exposed through this static property. public sealed class ThreadPoolScheduler : LocalScheduler, ISchedulerLongRunning, ISchedulerPeriodic { - private static readonly Lazy LazyInstance = new Lazy(static () => new ThreadPoolScheduler()); - private static readonly Lazy LazyNewBackgroundThread = new Lazy(static () => new NewThreadScheduler(action => new Thread(action) { IsBackground = true })); + private static readonly Lazy LazyInstance = new(static () => new ThreadPoolScheduler()); + private static readonly Lazy LazyNewBackgroundThread = new(static () => new NewThreadScheduler(action => new Thread(action) { IsBackground = true })); /// /// Gets the singleton instance of the CLR thread pool scheduler. diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/VirtualTimeScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/VirtualTimeScheduler.cs index 7ec28430ec..a5fa0d7528 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/VirtualTimeScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/VirtualTimeScheduler.cs @@ -309,7 +309,6 @@ public TAbsolute Clock /// Gets the next scheduled item to be executed. /// /// The next scheduled item. - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "By design. Side-effecting operation to retrieve the next element.")] protected abstract IScheduledItem? GetNext(); object? IServiceProvider.GetService(Type serviceType) => GetService(serviceType); @@ -366,7 +365,7 @@ public VirtualTimeStopwatch(VirtualTimeSchedulerBase paren public abstract class VirtualTimeScheduler : VirtualTimeSchedulerBase where TAbsolute : IComparable { - private readonly SchedulerQueue _queue = new SchedulerQueue(); + private readonly SchedulerQueue _queue = new(); /// /// Creates a new virtual time scheduler with the default value of TAbsolute as the initial clock value. 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 de5f4fb4ce..d721561cce 100644 --- a/Rx.NET/Source/src/System.Reactive/Diagnostics/CodeAnalysis/NullableAttributes.cs +++ b/Rx.NET/Source/src/System.Reactive/Diagnostics/CodeAnalysis/NullableAttributes.cs @@ -95,7 +95,9 @@ 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 }; +#pragma warning restore CA1019 /// Initializes the attribute with the list of field and property members. /// @@ -118,7 +120,9 @@ internal sealed class MemberNotNullWhenAttribute : 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 MemberNotNullWhenAttribute(bool returnValue, string member) +#pragma warning restore CA1019 { ReturnValue = returnValue; Members = new[] { member }; diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/BooleanDisposable.cs b/Rx.NET/Source/src/System.Reactive/Disposables/BooleanDisposable.cs index 29981c7c80..097f973554 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/BooleanDisposable.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/BooleanDisposable.cs @@ -12,7 +12,7 @@ public sealed class BooleanDisposable : ICancelable // Keep internal! This is used as sentinel in other IDisposable implementations to detect disposal and // should never be exposed to user code in order to prevent users from swapping in the sentinel. Have // a look at the code in e.g. SingleAssignmentDisposable for usage patterns. - internal static readonly BooleanDisposable True = new BooleanDisposable(true); + internal static readonly BooleanDisposable True = new(true); private volatile bool _isDisposed; diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs b/Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs index b3271d858e..03d4abee00 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/CompositeDisposable.cs @@ -14,7 +14,7 @@ namespace System.Reactive.Disposables [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "Backward compat + ideally want to get rid of the ICollection nature of the type.")] public sealed class CompositeDisposable : ICollection, ICancelable { - private readonly object _gate = new object(); + private readonly object _gate = new(); private bool _disposed; private List _disposables; private int _count; @@ -387,7 +387,7 @@ public IEnumerator GetEnumerator() /// method to avoid allocation on disposed or empty composites. /// private static readonly CompositeEnumerator EmptyEnumerator = - new CompositeEnumerator(Array.Empty()); + new(Array.Empty()); /// /// An enumerator for an array of disposables. diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/Disposable.Utils.cs b/Rx.NET/Source/src/System.Reactive/Disposables/Disposable.Utils.cs index 8c0b8dca39..296cc82f98 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/Disposable.Utils.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/Disposable.Utils.cs @@ -20,7 +20,7 @@ public static partial class Disposable /// Gets the value stored in or a null if /// was already disposed. /// - internal static IDisposable? GetValue([NotNullIfNotNull("fieldRef")] /*in*/ ref IDisposable? fieldRef) + internal static IDisposable? GetValue([NotNullIfNotNull(nameof(fieldRef))] /*in*/ ref IDisposable? fieldRef) { var current = Volatile.Read(ref fieldRef); @@ -33,8 +33,8 @@ public static partial class Disposable /// Gets the value stored in or a no-op-Disposable if /// was already disposed. /// - [return: NotNullIfNotNull("fieldRef")] - internal static IDisposable? GetValueOrDefault([NotNullIfNotNull("fieldRef")] /*in*/ ref IDisposable? fieldRef) + [return: NotNullIfNotNull(nameof(fieldRef))] + internal static IDisposable? GetValueOrDefault([NotNullIfNotNull(nameof(fieldRef))] /*in*/ ref IDisposable? fieldRef) { var current = Volatile.Read(ref fieldRef); @@ -47,7 +47,7 @@ public static partial class Disposable /// Tries to assign to . /// /// A value indicating the outcome of the operation. - internal static TrySetSingleResult TrySetSingle([NotNullIfNotNull("value")] ref IDisposable? fieldRef, IDisposable? value) + internal static TrySetSingleResult TrySetSingle([NotNullIfNotNull(nameof(value))] ref IDisposable? fieldRef, IDisposable? value) { var old = Interlocked.CompareExchange(ref fieldRef, value, null); if (old == null) @@ -70,7 +70,7 @@ internal static TrySetSingleResult TrySetSingle([NotNullIfNotNull("value")] ref /// /// true if was successfully assigned to . /// false has been disposed. - internal static bool TrySetMultiple([NotNullIfNotNull("value")] ref IDisposable? fieldRef, IDisposable? value) + internal static bool TrySetMultiple([NotNullIfNotNull(nameof(value))] ref IDisposable? fieldRef, IDisposable? value) { // Let's read the current value atomically (also prevents reordering). var old = Volatile.Read(ref fieldRef); @@ -104,7 +104,7 @@ internal static bool TrySetMultiple([NotNullIfNotNull("value")] ref IDisposable? /// /// true if was successfully assigned to . /// false has been disposed. - internal static bool TrySetSerial([NotNullIfNotNull("value")] ref IDisposable? fieldRef, IDisposable? value) + internal static bool TrySetSerial([NotNullIfNotNull(nameof(value))] ref IDisposable? fieldRef, IDisposable? value) { var copy = Volatile.Read(ref fieldRef); for (; ; ) @@ -129,7 +129,7 @@ internal static bool TrySetSerial([NotNullIfNotNull("value")] ref IDisposable? f /// /// Disposes . /// - internal static void Dispose([NotNullIfNotNull("fieldRef")] ref IDisposable? fieldRef) + internal static void Dispose([NotNullIfNotNull(nameof(fieldRef))] ref IDisposable? fieldRef) { var old = Interlocked.Exchange(ref fieldRef, BooleanDisposable.True); diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/Disposable.cs b/Rx.NET/Source/src/System.Reactive/Disposables/Disposable.cs index d8c67d1327..db554fe961 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/Disposable.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/Disposable.cs @@ -19,7 +19,7 @@ private sealed class EmptyDisposable : IDisposable /// /// Singleton default disposable. /// - public static readonly EmptyDisposable Instance = new EmptyDisposable(); + public static readonly EmptyDisposable Instance = new(); private EmptyDisposable() { diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/RefCountDisposable.cs b/Rx.NET/Source/src/System.Reactive/Disposables/RefCountDisposable.cs index 3ed932267d..839e17e99c 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/RefCountDisposable.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/RefCountDisposable.cs @@ -54,7 +54,6 @@ public RefCountDisposable(IDisposable disposable, bool throwWhenDisposed) /// /// A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime. /// This instance has been disposed and is configured to throw in this case by . - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Backward compat + non-trivial work for a property getter.")] public IDisposable GetDisposable() { // the current state diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/ScheduledDisposable.cs b/Rx.NET/Source/src/System.Reactive/Disposables/ScheduledDisposable.cs index fe2e46dd01..f6bde3c0fe 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/ScheduledDisposable.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/ScheduledDisposable.cs @@ -21,13 +21,8 @@ public sealed class ScheduledDisposable : ICancelable /// or is null. public ScheduledDisposable(IScheduler scheduler, IDisposable disposable) { - if (disposable == null) - { - throw new ArgumentNullException(nameof(disposable)); - } - Scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); - _disposable.Disposable = disposable; + _disposable.Disposable = disposable ?? throw new ArgumentNullException(nameof(disposable)); } /// diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposableValue.cs b/Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposableValue.cs index be834e3cfa..8707062a5e 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposableValue.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/SingleAssignmentDisposableValue.cs @@ -48,5 +48,17 @@ public void Dispose() { Disposables.Disposable.Dispose(ref _current); } + + /// + public override bool Equals(object? obj) => false; + + /// + public override int GetHashCode() => 0; + +#pragma warning disable IDE0060 // (Remove unused parameter.) Required part of public API + public static bool operator ==(SingleAssignmentDisposableValue left, SingleAssignmentDisposableValue right) => false; + + public static bool operator !=(SingleAssignmentDisposableValue left, SingleAssignmentDisposableValue right) => true; +#pragma warning restore IDE0060 } } diff --git a/Rx.NET/Source/src/System.Reactive/Disposables/StableCompositeDisposable.cs b/Rx.NET/Source/src/System.Reactive/Disposables/StableCompositeDisposable.cs index 731a9d92cf..637aae9633 100644 --- a/Rx.NET/Source/src/System.Reactive/Disposables/StableCompositeDisposable.cs +++ b/Rx.NET/Source/src/System.Reactive/Disposables/StableCompositeDisposable.cs @@ -10,6 +10,7 @@ namespace System.Reactive.Disposables /// /// Represents a group of disposable resources that are disposed together. /// +#pragma warning disable CA1063 // (Overridable IDisposable.) This analyzer wants us to make breaking changes to its public API, which we can't do. public abstract class StableCompositeDisposable : ICancelable { /// @@ -202,4 +203,5 @@ public override void Dispose() } } } +#pragma warning restore CA1063 } diff --git a/Rx.NET/Source/src/System.Reactive/EnlightenmentProvider.cs b/Rx.NET/Source/src/System.Reactive/EnlightenmentProvider.cs index 8fc71b9343..4e6a1d9d59 100644 --- a/Rx.NET/Source/src/System.Reactive/EnlightenmentProvider.cs +++ b/Rx.NET/Source/src/System.Reactive/EnlightenmentProvider.cs @@ -23,9 +23,7 @@ public static class EnlightenmentProvider /// public static bool EnsureLoaded() { -#pragma warning disable CS0618 return PlatformEnlightenmentProvider.Current is CurrentPlatformEnlightenmentProvider; -#pragma warning restore CS0618 } } } diff --git a/Rx.NET/Source/src/System.Reactive/EventPattern.cs b/Rx.NET/Source/src/System.Reactive/EventPattern.cs index 36df5807e0..00a0b00d8d 100644 --- a/Rx.NET/Source/src/System.Reactive/EventPattern.cs +++ b/Rx.NET/Source/src/System.Reactive/EventPattern.cs @@ -17,7 +17,9 @@ 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) { } @@ -56,7 +58,7 @@ public EventPattern(TSender? sender, TEventArgs e) /// /// The sender object that raised the event. /// The event data that was generated by the event. - public void Deconstruct(out TSender sender, out TEventArgs e) => (sender, e) = (Sender, EventArgs); + public void Deconstruct(out TSender? sender, out TEventArgs e) => (sender, e) = (Sender, EventArgs); /// /// Determines whether the current object represents the same event as a specified object. diff --git a/Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs b/Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs index 13cfda2638..aa3647e052 100644 --- a/Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs +++ b/Rx.NET/Source/src/System.Reactive/EventPatternSourceBase.cs @@ -20,7 +20,7 @@ private sealed class Observer : ObserverBase>, private bool _isDone; private bool _isAdded; private readonly Delegate _handler; - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly Action _invoke; private readonly EventPatternSourceBase _sourceBase; diff --git a/Rx.NET/Source/src/System.Reactive/GlobalSuppressions.cs b/Rx.NET/Source/src/System.Reactive/GlobalSuppressions.cs index 45cf02e7d9..98740075ff 100644 --- a/Rx.NET/Source/src/System.Reactive/GlobalSuppressions.cs +++ b/Rx.NET/Source/src/System.Reactive/GlobalSuppressions.cs @@ -12,203 +12,43 @@ // "In Project Suppression File". // You do not need to add suppressions to this file manually. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System", Justification = "By design.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames", Justification = "Taken care of by lab build.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1016:MarkAssembliesWithAssemblyVersion", Justification = "Taken care of by lab build.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "System.Reactive.Concurrency.LocalScheduler+WorkItem.#CompareTo(System.Reactive.Concurrency.LocalScheduler+WorkItem)", Justification = "Checked all enqueue operations against null reference insertions.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive", Justification = "By design.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive.Disposables", Justification = "By design.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive.Linq", Justification = "By design.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive.Subjects", Justification = "By design.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive.Concurrency", Justification = "By design.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive.Linq", Justification = "By design.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive.Threading.Tasks", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "~M:System.Reactive.Concurrency.LocalScheduler.WorkItem.CompareTo(System.Reactive.Concurrency.LocalScheduler.WorkItem)~System.Int32", Justification = "Checked all enqueue operations against null reference insertions.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive.Disposables", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive.Linq", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive.Subjects", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive.Concurrency", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive.Linq", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive.Threading.Tasks", Justification = "By design.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames", Justification = "Taken care of by lab build.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1016:MarkAssembliesWithAssemblyVersion", Justification = "Taken care of by lab build.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AddRef`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Aggregate`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Aggregate`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.All`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Amb`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Any`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AsObservable`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageDecimal.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageDecimalNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageDouble.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageDoubleNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageInt32.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageInt32Nullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageInt64.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageInt64Nullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageSingle.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.AverageSingleNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Buffer`2.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Buffer`1.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Cast`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Catch`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Catch`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`17.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`16.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`15.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`14.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`13.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`12.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`11.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`10.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`9.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`8.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`7.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`6.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`5.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`4.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`3.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.CombineLatest`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Concat`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Contains`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Count`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.DefaultIfEmpty`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Defer`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Delay`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Delay`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.DelaySubscription`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Dematerialize`1+_.#OnNext(System.Reactive.Notification`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Dematerialize`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Distinct`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.DistinctUntilChanged`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Do`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "System.Reactive.Either`2+Left.#Switch(System.Action`1,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "System.Reactive.Either`2+Left.#Switch`1(System.Func`2,System.Func`2)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Scope = "member", Target = "System.Reactive.Either`2+Right.#Switch(System.Action`1,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Scope = "member", Target = "System.Reactive.Either`2+Right.#Switch`1(System.Func`2,System.Func`2)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.ElementAt`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Empty`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Finally`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.FirstAsync`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Generate`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.GroupBy`3.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.GroupByUntil`4.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.GroupJoin`5.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.IgnoreElements`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.IsEmpty`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Join`5.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "System.Reactive.Joins.JoinObserver`1.#OnNextCore(System.Reactive.Notification`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.LastAsync`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.LongCount`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Materialize`1.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Max`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxBy`2.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxDecimal.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxDecimalNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxDouble.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxDoubleNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxInt32.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxInt32Nullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxInt64.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxInt64Nullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxSingle.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MaxSingleNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Merge`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Min`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinBy`2.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinDecimal.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinDecimalNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinDouble.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinDoubleNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinInt32.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinInt32Nullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinInt64.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinInt64Nullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinSingle.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.MinSingleNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Multicast`3.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.OfType`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.OnErrorResumeNext`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Range.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.RefCount`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Repeat`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Return`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Sample`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Sample`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Scan`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Scan`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Select`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SelectMany`3.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SelectMany`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SequenceEqual`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SingleAsync`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Skip`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SkipLast`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SkipUntil`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SkipUntil`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SkipWhile`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumDecimal.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumDecimalNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumDouble.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumDoubleNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumInt32.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumInt32Nullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumInt64.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumInt64Nullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumSingle.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.SumSingleNullable.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Switch`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Take`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.TakeLast`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.TakeUntil`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.TakeUntil`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.TakeWhile`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Throttle`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Throttle`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Throw`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.TimeInterval`1.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Timeout`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Timeout`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Timer.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Timestamp`1.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.ToArray`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.ToDictionary`3.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.ToList`1.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.ToLookup`3.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.ToObservable`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Using`2.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Where`1.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Window`2.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Window`1.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`17.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`16.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`15.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`14.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`13.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`12.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`11.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`10.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`9.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`8.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`7.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`6.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`4.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`3.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`1.#Run(System.IObserver`1>,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.Zip`5.#Run(System.IObserver`1,System.IDisposable,System.Action`1)", Justification = "Producer cannot pass null to setSink parameter.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "System.Reactive.Linq.ObservableImpl.ElementAt`1+_.#OnCompleted()", Justification = "Asynchronous behavior; no more index parameter in scope.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive.Concurrency", Justification = "By design.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive.PlatformServices", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "~M:System.Reactive.Linq.ObservableImpl.Dematerialize`1._.OnNext(System.Reactive.Notification{`0})", Justification = "Producer cannot pass null to setSink parameter.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "~M:System.Reactive.Either`2.Left.Switch(System.Action{`0},System.Action{`1})", Justification = "Producer cannot pass null to setSink parameter.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "~M:System.Reactive.Either`2.Left.Switch``1(System.Func{`0,``0},System.Func{`1,``0})~``0", Justification = "Producer cannot pass null to setSink parameter.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Scope = "member", Target = "~M:System.Reactive.Either`2.Right.Switch(System.Action{`0},System.Action{`1})", Justification = "Producer cannot pass null to setSink parameter.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Scope = "member", Target = "~M:System.Reactive.Either`2.Right.Switch``1(System.Func{`0,``0},System.Func{`1,``0})~``0", Justification = "Producer cannot pass null to setSink parameter.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "~M:System.Reactive.Joins.JoinObserver`1.OnNextCore(System.Reactive.Notification{`0})", Justification = "Producer cannot pass null to setSink parameter.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "~M:System.Reactive.Linq.ObservableImpl.ElementAt`1._.OnCompleted", Justification = "Asynchronous behavior; no more index parameter in scope.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive.Concurrency", Justification = "By design.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive.PlatformServices", Justification = "By design.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames", Justification = "Taken care of by lab build.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1016:MarkAssembliesWithAssemblyVersion", Justification = "Taken care of by lab build.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Reactive.Linq", Justification = "By design")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "type", Target = "System.Reactive.Linq.IQbservable", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "type", Target = "System.Reactive.Linq.IQbservable`1", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "type", Target = "System.Reactive.Linq.IQbservableProvider", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "type", Target = "System.Reactive.Linq.Qbservable", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Amb", Scope = "member", Target = "System.Reactive.Linq.Qbservable.#Amb`1(System.Reactive.Linq.IQbservable`1,System.IObservable`1)", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Amb", Scope = "member", Target = "System.Reactive.Linq.Qbservable.#Amb`1(System.Reactive.Linq.IQbservableProvider,System.Collections.Generic.IEnumerable`1>)", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Amb", Scope = "member", Target = "System.Reactive.Linq.Qbservable.#Amb`1(System.Reactive.Linq.IQbservableProvider,System.IObservable`1[])", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "member", Target = "System.Reactive.Linq.Qbservable.#AsQbservable`1(System.IObservable`1)", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Remotable", Scope = "member", Target = "System.Reactive.Linq.Qbservable.#Remotable`1(System.Reactive.Linq.IQbservable`1)", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "member", Target = "System.Reactive.Linq.Qbservable.#ToQbservable`1(System.Linq.IQueryable`1)", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "~N:System.Reactive.Linq", Justification = "By design")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "type", Target = "~T:System.Reactive.Linq.IQbservable", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "type", Target = "~T:System.Reactive.Linq.IQbservable`1", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "type", Target = "~T:System.Reactive.Linq.IQbservableProvider", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "type", Target = "~T:System.Reactive.Linq.Qbservable", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Amb", Scope = "member", Target = "~M:System.Reactive.Linq.Qbservable.Amb``1(System.Reactive.Linq.IQbservable{``0},System.IObservable{``0})~System.Reactive.Linq.IQbservable{``0}", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Amb", Scope = "member", Target = "~M:System.Reactive.Linq.Qbservable.Amb``1(System.Reactive.Linq.IQbservableProvider,System.Collections.Generic.IEnumerable{System.IObservable{``0}})~System.Reactive.Linq.IQbservable{``0}", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Amb", Scope = "member", Target = "~M:System.Reactive.Linq.Qbservable.Amb``1(System.Reactive.Linq.IQbservableProvider,System.IObservable{``0}[])~System.Reactive.Linq.IQbservable{``0}", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "member", Target = "~M:System.Reactive.Linq.Qbservable.AsQbservable``1(System.IObservable{``0})~System.Reactive.Linq.IQbservable{``0}", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "member", Target = "~M:System.Reactive.Linq.Qbservable.ToQbservable``1(System.Linq.IQueryable{``0})~System.Reactive.Linq.IQbservable{``0}", Justification = "It's homoiconic, dude!")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "resource", Target = "System.Reactive.Strings_Providers.resources", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "member", Target = "System.Reactive.Linq.Qbservable.#ToQbservable`1(System.Linq.IQueryable`1,System.Reactive.Concurrency.IScheduler)", Justification = "It's homoiconic, dude!")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "System.Reactive.ObservableQuery`1+ObservableRewriter.#VisitConstant(System.Linq.Expressions.ConstantExpression)", Justification = "Expression visitor should not pass in null references.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "System.Reactive.ObservableQuery`1+ObservableRewriter.#VisitMethodCall(System.Linq.Expressions.MethodCallExpression)", Justification = "Expression visitor should not pass in null references.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Qbservable", Scope = "member", Target = "~M:System.Reactive.Linq.Qbservable.ToQbservable``1(System.Linq.IQueryable{``0},System.Reactive.Concurrency.IScheduler)~System.Reactive.Linq.IQbservable{``0}", Justification = "It's homoiconic, dude!")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "~M:System.Reactive.ObservableQuery`1.ObservableRewriter.VisitConstant(System.Linq.Expressions.ConstantExpression)~System.Linq.Expressions.Expression", Justification = "Expression visitor should not pass in null references.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "~M:System.Reactive.ObservableQuery`1.ObservableRewriter.VisitMethodCall(System.Linq.Expressions.MethodCallExpression)~System.Linq.Expressions.Expression", Justification = "Expression visitor should not pass in null references.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames", Justification = "Taken care of by lab build.")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1016:MarkAssembliesWithAssemblyVersion", Justification = "Taken care of by lab build.")] diff --git a/Rx.NET/Source/src/System.Reactive/IEventSource.cs b/Rx.NET/Source/src/System.Reactive/IEventSource.cs index 2c8e9dd2f3..ec8920c849 100644 --- a/Rx.NET/Source/src/System.Reactive/IEventSource.cs +++ b/Rx.NET/Source/src/System.Reactive/IEventSource.cs @@ -16,8 +16,7 @@ public interface IEventSource /// /// Event signaling the next element in the data stream. /// - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "By design.")] - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1009:DeclareEventHandlersCorrectly", Justification = "Can't do this for Action.")] + [Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1003:Use generic event handler instances", Justification = "Can't do this for Action.")] event Action OnNext; } } diff --git a/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.Default.cs b/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.Default.cs index 9f4df08fed..838cad2bec 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.Default.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.Default.cs @@ -14,9 +14,13 @@ namespace System.Reactive.PlatformServices // internal sealed class DefaultExceptionServices/*Impl*/ : IExceptionServices { +#if NO_NULLABLE_ATTRIBUTES #pragma warning disable CS8763 // NB: On down-level platforms, Throw is not marked as DoesNotReturn. +#endif [DoesNotReturn] public void Rethrow(Exception exception) => ExceptionDispatchInfo.Capture(exception).Throw(); +#if NO_NULLABLE_ATTRIBUTES #pragma warning restore CS8763 +#endif } } diff --git a/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.cs b/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.cs index 202c78ed9e..bb3f8483eb 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServices.cs @@ -10,16 +10,14 @@ namespace System.Reactive { internal static class ExceptionHelpers { - private static readonly Lazy Services = new Lazy(Initialize); + private static readonly Lazy Services = new(Initialize); [DoesNotReturn] public static void Throw(this Exception exception) => Services.Value.Rethrow(exception); private static IExceptionServices Initialize() { -#pragma warning disable CS0618 // Type or member is obsolete return PlatformEnlightenmentProvider.Current.GetService() ?? new DefaultExceptionServices(); -#pragma warning restore CS0618 // Type or member is obsolete } } } diff --git a/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServicesImpl.cs b/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServicesImpl.cs index bb46baaef3..304f106b69 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServicesImpl.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/ExceptionServicesImpl.cs @@ -14,9 +14,13 @@ namespace System.Reactive.PlatformServices // internal sealed class /*Default*/ExceptionServicesImpl : IExceptionServices { +#if NO_NULLABLE_ATTRIBUTES #pragma warning disable CS8763 // NB: On down-level platforms, Throw is not marked as DoesNotReturn. +#endif [DoesNotReturn] public void Rethrow(Exception exception) => ExceptionDispatchInfo.Capture(exception).Throw(); +#if NO_NULLABLE_ATTRIBUTES #pragma warning restore CS8763 +#endif } } diff --git a/Rx.NET/Source/src/System.Reactive/Internal/HostLifecycleService.cs b/Rx.NET/Source/src/System.Reactive/Internal/HostLifecycleService.cs index f4e59b9631..bd30233c41 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/HostLifecycleService.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/HostLifecycleService.cs @@ -13,7 +13,7 @@ namespace System.Reactive.PlatformServices [EditorBrowsable(EditorBrowsableState.Never)] public static class HostLifecycleService { - private static readonly Lazy Notifications = new Lazy(InitializeNotifications); + private static readonly Lazy Notifications = new(InitializeNotifications); private static int _refCount; @@ -72,9 +72,7 @@ private static void OnResuming(object? sender, HostResumingEventArgs e) private static IHostLifecycleNotifications? InitializeNotifications() { -#pragma warning disable CS0618 // Type or member is obsolete return PlatformEnlightenmentProvider.Current.GetService(); -#pragma warning restore CS0618 // Type or member is obsolete } } diff --git a/Rx.NET/Source/src/System.Reactive/Internal/ImmutableList.cs b/Rx.NET/Source/src/System.Reactive/Internal/ImmutableList.cs index dd57be0f42..f4ad42bb38 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/ImmutableList.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/ImmutableList.cs @@ -6,7 +6,7 @@ namespace System.Reactive { internal sealed class ImmutableList { - public static readonly ImmutableList Empty = new ImmutableList(); + public static readonly ImmutableList Empty = new(); private readonly T[] _data; diff --git a/Rx.NET/Source/src/System.Reactive/Internal/PriorityQueue.cs b/Rx.NET/Source/src/System.Reactive/Internal/PriorityQueue.cs index f6b026a1eb..70cc8756dd 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/PriorityQueue.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/PriorityQueue.cs @@ -37,12 +37,9 @@ private int Percolate(int index) var parent = (index - 1) / 2; while (parent >= 0 && parent != index && IsHigherPriority(index, parent)) - { + { // swap index and parent - var temp = _items[index]; - _items[index] = _items[parent]; - _items[parent] = temp; - + (_items[parent], _items[index]) = (_items[index], _items[parent]); index = parent; parent = (index - 1) / 2; } @@ -79,10 +76,7 @@ private void Heapify(int index) } // swap index and first - var temp = _items[index]; - _items[index] = _items[first]; - _items[first] = temp; - + (_items[first], _items[index]) = (_items[index], _items[first]); index = first; } } diff --git a/Rx.NET/Source/src/System.Reactive/Internal/QueryServices.cs b/Rx.NET/Source/src/System.Reactive/Internal/QueryServices.cs index 8884d9c118..608fb90c6c 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/QueryServices.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/QueryServices.cs @@ -14,9 +14,7 @@ internal static class QueryServices private static IQueryServices Initialize() { -#pragma warning disable CS0618 // Type or member is obsolete return PlatformEnlightenmentProvider.Current.GetService() ?? new DefaultQueryServices(); -#pragma warning restore CS0618 // Type or member is obsolete } } diff --git a/Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs b/Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs index 8d98f203ad..75986a18e4 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/ReflectionUtils.cs @@ -44,23 +44,8 @@ public static void GetEventMethods(Type targetType, object? } } - var add = e.GetAddMethod(); - - if (add == null) - { - throw new InvalidOperationException(Strings_Linq.EVENT_MISSING_ADD_METHOD); - } - - addMethod = add; - - var remove = e.GetRemoveMethod(); - - if (remove == null) - { - throw new InvalidOperationException(Strings_Linq.EVENT_MISSING_REMOVE_METHOD); - } - - removeMethod = remove; + addMethod = e.GetAddMethod() ?? throw new InvalidOperationException(Strings_Linq.EVENT_MISSING_ADD_METHOD); + removeMethod = e.GetRemoveMethod() ?? throw new InvalidOperationException(Strings_Linq.EVENT_MISSING_REMOVE_METHOD); var psa = addMethod.GetParameters(); if (psa.Length != 1) diff --git a/Rx.NET/Source/src/System.Reactive/Internal/ScheduledObserver.cs b/Rx.NET/Source/src/System.Reactive/Internal/ScheduledObserver.cs index 356787f566..eb08ae46b5 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/ScheduledObserver.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/ScheduledObserver.cs @@ -18,7 +18,7 @@ internal class ScheduledObserver : ObserverBase, IScheduledObserver private const int Running = 1; private const int Pending = 2; private const int Faulted = 9; - private readonly ConcurrentQueue _queue = new ConcurrentQueue(); + private readonly ConcurrentQueue _queue = new(); private bool _failed; private Exception? _error; private bool _completed; @@ -55,7 +55,7 @@ public void Dispose() } } - private readonly object _dispatcherInitGate = new object(); + private readonly object _dispatcherInitGate = new(); private readonly SemaphoreSlim? _dispatcherEvent; private readonly IDisposable? _dispatcherEventRelease; private IDisposable? _dispatcherJob; @@ -204,7 +204,7 @@ private void EnsureActiveSlow() private void Run(object? state, Action recurse) { - T next; + T? next; while (!_queue.TryDequeue(out next)) { diff --git a/Rx.NET/Source/src/System.Reactive/Internal/Stubs.cs b/Rx.NET/Source/src/System.Reactive/Internal/Stubs.cs index 1048c80e7e..344f5f7382 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/Stubs.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/Stubs.cs @@ -18,7 +18,7 @@ internal static class Stubs internal static class TimerStubs { - public static readonly System.Threading.Timer Never = new System.Threading.Timer(static _ => { }); + public static readonly System.Threading.Timer Never = new(static _ => { }); } } diff --git a/Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs b/Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs index 9a4d62be22..373e93b335 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs @@ -19,9 +19,9 @@ namespace System.Reactive.PlatformServices [EditorBrowsable(EditorBrowsableState.Never)] public static class SystemClock { - private static readonly Lazy ServiceSystemClock = new Lazy(InitializeSystemClock); - private static readonly Lazy ServiceSystemClockChanged = new Lazy(InitializeSystemClockChanged); - internal static readonly HashSet> SystemClockChanged = new HashSet>(); + private static readonly Lazy ServiceSystemClock = new(InitializeSystemClock); + private static readonly Lazy ServiceSystemClockChanged = new(InitializeSystemClockChanged); + internal static readonly HashSet> SystemClockChanged = new(); private static IDisposable? _systemClockChangedHandlerCollector; private static int _refCount; @@ -73,16 +73,12 @@ internal static void OnSystemClockChanged(object? sender, SystemClockChangedEven private static ISystemClock InitializeSystemClock() { -#pragma warning disable CS0618 // Type or member is obsolete return PlatformEnlightenmentProvider.Current.GetService() ?? new DefaultSystemClock(); -#pragma warning restore CS0618 // Type or member is obsolete } private static INotifySystemClockChanged InitializeSystemClockChanged() { -#pragma warning disable CS0618 // Type or member is obsolete return PlatformEnlightenmentProvider.Current.GetService() ?? new DefaultSystemClockMonitor(); -#pragma warning restore CS0618 // Type or member is obsolete } internal static void Register(LocalScheduler scheduler) @@ -127,10 +123,7 @@ private static void CollectHandlers() { if (!handler.TryGetTarget(out _)) { - if (remove == null) - { - remove = new HashSet>(); - } + remove ??= new HashSet>(); remove.Add(handler); } diff --git a/Rx.NET/Source/src/System.Reactive/Internal/TailRecursiveSink.cs b/Rx.NET/Source/src/System.Reactive/Internal/TailRecursiveSink.cs index b258207c6e..0a97f08a64 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/TailRecursiveSink.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/TailRecursiveSink.cs @@ -11,7 +11,7 @@ namespace System.Reactive { internal abstract class TailRecursiveSink : IdentitySink { - private readonly Stack>> _stack = new Stack>>(); + private readonly Stack>> _stack = new(); private bool _isDisposed; private int _trampoline; diff --git a/Rx.NET/Source/src/System.Reactive/Internal/TaskExtensions.cs b/Rx.NET/Source/src/System.Reactive/Internal/TaskExtensions.cs index 2f9f1b2ffa..eb32c1b5cf 100644 --- a/Rx.NET/Source/src/System.Reactive/Internal/TaskExtensions.cs +++ b/Rx.NET/Source/src/System.Reactive/Internal/TaskExtensions.cs @@ -6,7 +6,7 @@ namespace System.Threading.Tasks { internal static class TaskExtensions { - public static Task ContinueWithState(this Task task, Action continuationAction, TState state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions) + public static Task ContinueWithState(this Task task, Action continuationAction, TState state, TaskContinuationOptions continuationOptions, CancellationToken cancellationToken) { return task.ContinueWith( (t, tupleObject) => @@ -34,7 +34,7 @@ public static Task ContinueWithState(this Task task, A cancellationToken); } - public static Task ContinueWithState(this Task task, Action, TState> continuationAction, TState state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions) + public static Task ContinueWithState(this Task task, Action, TState> continuationAction, TState state, TaskContinuationOptions continuationOptions, CancellationToken cancellationToken) { return task.ContinueWith( (t, tupleObject) => diff --git a/Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs b/Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs index 41ef260ad2..aa4f3bb6be 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 Dictionary(); + private readonly Dictionary _joinObservers = new(); protected readonly Action _onCompleted; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.NAry.cs b/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.NAry.cs index 00a4f7505d..af0ed6c297 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.NAry.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.NAry.cs @@ -2,11 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. -// This code was generated by a T4 template at 10/05/2020 14:25:54. +// This code was generated by a T4 template at 05/04/2023 16:16:14. namespace System.Reactive.Linq { - partial interface IQueryLanguage + internal partial interface IQueryLanguage { IObservable CombineLatest(IObservable source1, IObservable source2, Func resultSelector); IObservable CombineLatest(IObservable source1, IObservable source2, IObservable source3, Func resultSelector); @@ -41,7 +41,7 @@ partial interface IQueryLanguage IObservable Zip(IObservable source1, IObservable source2, IObservable source3, IObservable source4, IObservable source5, IObservable source6, IObservable source7, IObservable source8, IObservable source9, IObservable source10, IObservable source11, IObservable source12, IObservable source13, IObservable source14, IObservable source15, IObservable source16, Func resultSelector); } - partial interface IQueryLanguageEx + internal partial interface IQueryLanguageEx { IObservable<(T1, T2)> CombineLatest(IObservable source1, IObservable source2); IObservable<(T1, T2, T3)> CombineLatest(IObservable source1, IObservable source2, IObservable source3); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.NAry.tt b/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.NAry.tt index 2891214cd4..e3da85f496 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.NAry.tt +++ b/Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.NAry.tt @@ -12,7 +12,7 @@ namespace System.Reactive.Linq { - partial interface IQueryLanguage + internal partial interface IQueryLanguage { <# for (int i = 2; i <= 16; i++) @@ -39,7 +39,7 @@ for (int i = 2; i <= 16; i++) #> } - partial interface IQueryLanguageEx + internal partial interface IQueryLanguageEx { <# for (int i = 2; i <= 8; i++) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Binding.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Binding.cs index 3f9082c354..8248f31bd4 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Binding.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Binding.cs @@ -251,12 +251,12 @@ public static IObservable RefCount(this IConnectableObservable { if (source == null) { - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); } if (disconnectDelay < TimeSpan.Zero) { - throw new ArgumentException("Delay cannot be less than zero", "disconnectDelay"); + throw new ArgumentException("Delay cannot be less than zero", nameof(disconnectDelay)); } return s_impl.RefCount(source, disconnectDelay); @@ -275,17 +275,17 @@ public static IObservable RefCount(this IConnectableObservable { if (source == null) { - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); } if (scheduler == null) { - throw new ArgumentNullException("scheduler"); + throw new ArgumentNullException(nameof(scheduler)); } if (disconnectDelay < TimeSpan.Zero) { - throw new ArgumentException("Delay cannot be less than zero", "disconnectDelay"); + throw new ArgumentException("Delay cannot be less than zero", nameof(disconnectDelay)); } return s_impl.RefCount(source, disconnectDelay, scheduler); @@ -328,12 +328,12 @@ public static IObservable RefCount(this IConnectableObservable { if (source == null) { - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); } if (disconnectDelay < TimeSpan.Zero) { - throw new ArgumentException("Delay cannot be less than zero", "disconnectDelay"); + throw new ArgumentException("Delay cannot be less than zero", nameof(disconnectDelay)); } if (minObservers <= 0) { @@ -358,17 +358,17 @@ public static IObservable RefCount(this IConnectableObservable { if (source == null) { - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); } if (scheduler == null) { - throw new ArgumentNullException("scheduler"); + throw new ArgumentNullException(nameof(scheduler)); } if (disconnectDelay < TimeSpan.Zero) { - throw new ArgumentException("Delay cannot be less than zero", "disconnectDelay"); + throw new ArgumentException("Delay cannot be less than zero", nameof(disconnectDelay)); } if (minObservers <= 0) { diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Blocking.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Blocking.cs index 4ba1309879..ceb368228d 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Blocking.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Blocking.cs @@ -451,7 +451,9 @@ public static IEnumerable Next(this IObservable sourc /// The source sequence contains more than one element. -or- The source sequence is empty. /// [Obsolete(Constants_Linq.UseAsync)] +#pragma warning disable CA1720 // (Identifier contains type name.) Single is long-established as a LINQ method name. public static TSource Single(this IObservable source) +#pragma warning restore CA1720 { if (source == null) { @@ -472,7 +474,9 @@ public static TSource Single(this IObservable source) /// No element satisfies the condition in the predicate. -or- More than one element satisfies the condition in the predicate. -or- The source sequence is empty. /// [Obsolete(Constants_Linq.UseAsync)] +#pragma warning disable CA1720 // (Identifier contains type name.) Single is long-established as a LINQ method name. public static TSource Single(this IObservable source, Func predicate) +#pragma warning restore CA1720 { if (source == null) { diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Creation.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Creation.cs index 7380d09a61..af64b0cd2e 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Creation.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Creation.cs @@ -295,7 +295,9 @@ public static IObservable Empty() /// The type used for the type parameter of the resulting sequence. /// Object solely used to infer the type of the type parameter. This parameter is typically used when creating a sequence of anonymously typed elements. /// An observable sequence with no elements. +#pragma warning disable IDE0060 // (Remove unused parameter.) Required for type inference public static IObservable Empty(TResult witness) +#pragma warning restore IDE0060 { return s_impl.Empty(); // Pure inference - no specialized target method. } @@ -325,7 +327,9 @@ public static IObservable Empty(IScheduler scheduler) /// Object solely used to infer the type of the type parameter. This parameter is typically used when creating a sequence of anonymously typed elements. /// An observable sequence with no elements. /// is null. +#pragma warning disable IDE0060 // (Remove unused parameter.) Required for type inference public static IObservable Empty(IScheduler scheduler, TResult witness) +#pragma warning restore IDE0060 { if (scheduler == null) { @@ -427,7 +431,9 @@ public static IObservable Never() /// The type used for the type parameter of the resulting sequence. /// Object solely used to infer the type of the type parameter. This parameter is typically used when creating a sequence of anonymously typed elements. /// An observable sequence whose observers will never get called. +#pragma warning disable IDE0060 // (Remove unused parameter.) Required for type inference public static IObservable Never(TResult witness) +#pragma warning restore IDE0060 { return s_impl.Never(); // Pure inference - no specialized target method. } @@ -617,7 +623,9 @@ public static IObservable Throw(Exception exception) /// Object solely used to infer the type of the type parameter. This parameter is typically used when creating a sequence of anonymously typed elements. /// The observable sequence that terminates exceptionally with the specified exception object. /// is null. +#pragma warning disable IDE0060 // (Remove unused parameter.) Required for type inference public static IObservable Throw(Exception exception, TResult witness) +#pragma warning restore IDE0060 { if (exception == null) { @@ -659,7 +667,9 @@ public static IObservable Throw(Exception exception, ISchedule /// Object solely used to infer the type of the type parameter. This parameter is typically used when creating a sequence of anonymously typed elements. /// The observable sequence that terminates exceptionally with the specified exception object. /// or is null. +#pragma warning disable IDE0060 // (Remove unused parameter.) Required for type inference public static IObservable Throw(Exception exception, IScheduler scheduler, TResult witness) +#pragma warning restore IDE0060 { if (exception == null) { diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs index 3945ffbdf4..e1ae7a011e 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs @@ -1193,7 +1193,9 @@ public static IObservable CombineLatest /// Merges the specified observable sequences into one observable sequence of tuple values whenever any of the observable sequences produces an element. diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs index e3309a3d08..046d00ef16 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs @@ -1179,7 +1179,9 @@ public static IObservable Zip /// Merges the specified observable sequences into one observable sequence of tuple values whenever all of the observable sequences have produced an element at a corresponding index. diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs index b0cbb3642b..865f791dd1 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs @@ -1128,7 +1128,9 @@ public static IObservable Zip(this IObserv #endregion } +#pragma warning disable CA1711 // (Don't use Ex suffix.) This has been a public type for many years, so we can't rename it now. public static partial class ObservableEx +#pragma warning restore CA1711 { /// /// Merges two observable sequences into one observable sequence by combining each element from the first source with the latest element from the second source, if any. diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs index 8834b6ff2e..c2ff1a9c2d 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable.Queryable.cs @@ -2,9 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. -#pragma warning disable 1591 - +#if HAS_TRIMMABILITY_ATTRIBUTES using System.Diagnostics.CodeAnalysis; +#endif namespace System.Reactive.Linq { @@ -24,10 +24,7 @@ public static IQbservableProvider Provider { get { - if (s_provider == null) - { - s_provider = new ObservableQueryProvider(); - } + s_provider ??= new ObservableQueryProvider(); return s_provider; } @@ -51,5 +48,3 @@ public static IQbservable AsQbservable(this IObservable source, RefCountDisposable refCount) _refCount = refCount; } - protected override _ CreateSink(IObserver observer) => new _(observer, _refCount.GetDisposable()); + protected override _ CreateSink(IObserver observer) => new(observer, _refCount.GetDisposable()); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Aggregate.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Aggregate.cs index 537533bc73..140921df40 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Aggregate.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Aggregate.cs @@ -15,7 +15,7 @@ public Aggregate(IObservable source, Func ac _accumulator = accumulator; } - protected override _ CreateSink(IObserver observer) => new _(_accumulator, observer); + protected override _ CreateSink(IObserver observer) => new(_accumulator, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -95,7 +95,7 @@ public Aggregate(IObservable source, TAccumulate seed, Func observer) => new _(_seed, _accumulator, observer); + protected override _ CreateSink(IObserver observer) => new(_seed, _accumulator, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -155,7 +155,7 @@ public Aggregate(IObservable source, TAccumulate seed, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/All.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/All.cs index 27fd212e1f..f00ac5760e 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/All.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/All.cs @@ -15,7 +15,7 @@ public All(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Amb.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Amb.cs index 3b93a9432c..b91ac71c42 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Amb.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Amb.cs @@ -17,7 +17,7 @@ public Amb(IObservable left, IObservable right) _right = right; } - protected override AmbCoordinator CreateSink(IObserver observer) => new AmbCoordinator(observer); + protected override AmbCoordinator CreateSink(IObserver observer) => new(observer); protected override void Run(AmbCoordinator sink) => sink.Run(_left, _right); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Any.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Any.cs index 3bd01f6c73..7384972873 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Any.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Any.cs @@ -15,7 +15,7 @@ public Count(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -51,7 +51,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/AppendPrepend.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/AppendPrepend.cs index 3def205f65..c0de3a1d0b 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/AppendPrepend.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/AppendPrepend.cs @@ -95,7 +95,7 @@ public SingleValue(IObservable source, TSource value, IScheduler schedu Scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(); @@ -189,7 +189,7 @@ public IAppendPrepend Prepend(TSource value) new Node(_prepends, value), _appends, Scheduler); } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(); @@ -352,7 +352,7 @@ public IAppendPrepend Prepend(TSource value) new Node(_prepends, value), _appends, Scheduler, _longRunningScheduler); } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(); @@ -508,7 +508,7 @@ public SingleImmediate(IObservable source, TSource value, bool append) { } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/AsObservable.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/AsObservable.cs index bd5f73d38a..75c6bff7a7 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/AsObservable.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/AsObservable.cs @@ -15,7 +15,7 @@ public AsObservable(IObservable source) public IObservable Eval() => _source; - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Average.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Average.cs index 76f63782ca..9767f36209 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Average.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Average.cs @@ -13,7 +13,7 @@ public AverageDouble(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -76,7 +76,7 @@ public AverageSingle(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -139,7 +139,7 @@ public AverageDecimal(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -202,7 +202,7 @@ public AverageInt32(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -265,7 +265,7 @@ public AverageInt64(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -328,7 +328,7 @@ public AverageDoubleNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -388,7 +388,7 @@ public AverageSingleNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -448,7 +448,7 @@ public AverageDecimalNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -508,7 +508,7 @@ public AverageInt32Nullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -568,7 +568,7 @@ public AverageInt64Nullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); 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 1f0a083d9a..c74db992cb 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Buffer.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Buffer.cs @@ -21,7 +21,7 @@ public CountExact(IObservable source, int count) _count = count; } - protected override ExactSink CreateSink(IObserver> observer) => new ExactSink(observer, _count); + protected override ExactSink CreateSink(IObserver> observer) => new(observer, _count); protected override void Run(ExactSink sink) => sink.Run(_source); @@ -93,7 +93,7 @@ public CountSkip(IObservable source, int count, int skip) _skip = skip; } - protected override SkipSink CreateSink(IObserver> observer) => new SkipSink(observer, _count, _skip); + protected override SkipSink CreateSink(IObserver> observer) => new(observer, _count, _skip); protected override void Run(SkipSink sink) => sink.Run(_source); @@ -171,7 +171,7 @@ public CountOverlap(IObservable source, int count, int skip) _skip = skip; } - protected override OverlapSink CreateSink(IObserver> observer) => new OverlapSink(observer, _count, _skip); + protected override OverlapSink CreateSink(IObserver> observer) => new(observer, _count, _skip); protected override void Run(OverlapSink sink) => sink.Run(_source); @@ -260,7 +260,7 @@ public TimeSliding(IObservable source, TimeSpan timeSpan, TimeSpan time _scheduler = scheduler; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(this); @@ -268,8 +268,8 @@ internal sealed class _ : Sink> { private readonly TimeSpan _timeShift; private readonly IScheduler _scheduler; - private readonly object _gate = new object(); - private readonly Queue> _q = new Queue>(); + private readonly object _gate = new(); + private readonly Queue> _q = new(); private SerialDisposableValue _timerSerial; public _(TimeSliding parent, IObserver> observer) @@ -429,14 +429,14 @@ public TimeHopping(IObservable source, TimeSpan timeSpan, IScheduler sc _scheduler = scheduler; } - protected override _ CreateSink(IObserver> observer) => new _(observer); + protected override _ CreateSink(IObserver> observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : Sink> { - private readonly object _gate = new object(); - private List _list = new List(); + private readonly object _gate = new(); + private List _list = new(); public _(IObserver> observer) : base(observer) @@ -513,15 +513,15 @@ public Ferry(IObservable source, TimeSpan timeSpan, int count, ISchedul _scheduler = scheduler; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(); internal sealed class _ : Sink> { private readonly Ferry _parent; - private readonly object _gate = new object(); - private List _s = new List(); + private readonly object _gate = new(); + private List _s = new(); public _(Ferry parent, IObserver> observer) : base(observer) @@ -643,17 +643,17 @@ public Selector(IObservable source, Func> b _bufferClosingSelector = bufferClosingSelector; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink> { - private readonly object _gate = new object(); - private readonly AsyncLock _bufferGate = new AsyncLock(); + private readonly object _gate = new(); + private readonly AsyncLock _bufferGate = new(); private readonly Func> _bufferClosingSelector; - private List _buffer = new List(); + private List _buffer = new(); private SerialDisposableValue _bufferClosingSerialDisposable; public _(Selector parent, IObserver> observer) @@ -777,15 +777,15 @@ public Boundaries(IObservable source, IObservable buffe _bufferBoundaries = bufferBoundaries; } - protected override _ CreateSink(IObserver> observer) => new _(observer); + protected override _ CreateSink(IObserver> observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : Sink> { - private readonly object _gate = new object(); + private readonly object _gate = new(); - private List _buffer = new List(); + private List _buffer = new(); private SingleAssignmentDisposableValue _boundariesDisposable; public _(IObserver> observer) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Case.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Case.cs index 2db59495b8..431e8e74d3 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Case.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Case.cs @@ -30,7 +30,7 @@ public IObservable Eval() return _defaultSource; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Cast.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Cast.cs index 652efc1f67..f15a0ab1ef 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Cast.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Cast.cs @@ -13,7 +13,7 @@ public Cast(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -26,10 +26,10 @@ public _(IObserver observer) public override void OnNext(TSource value) { - TResult result; + TResult? result; try { - result = (TResult)(object?)value; + result = (TResult?)(object?)value; } catch (Exception exception) { diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Catch.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Catch.cs index 6dc6fae70a..492fe8aa14 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Catch.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Catch.cs @@ -17,7 +17,7 @@ public Catch(IEnumerable> sources) _sources = sources; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_sources); @@ -82,7 +82,7 @@ public Catch(IObservable source, Func> _handler = handler; } - protected override _ CreateSink(IObserver observer) => new _(_handler, observer); + protected override _ CreateSink(IObserver observer) => new(_handler, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.NAry.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.NAry.cs index d70a8a75fe..7ae6940396 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.NAry.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.NAry.cs @@ -27,7 +27,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3); @@ -85,7 +85,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4); @@ -149,7 +149,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5); @@ -219,7 +219,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6); @@ -295,7 +295,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7); @@ -377,7 +377,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8); @@ -465,7 +465,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9); @@ -559,7 +559,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10); @@ -659,7 +659,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11); @@ -765,7 +765,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12); @@ -877,7 +877,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13); @@ -995,7 +995,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13, _source14); @@ -1119,7 +1119,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13, _source14, _source15); @@ -1249,7 +1249,7 @@ public CombineLatest(IObservable source1, IObservable source2, IObservab _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13, _source14, _source15, _source16); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.cs index ccb72de94e..bfca05a428 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/CombineLatest.cs @@ -24,14 +24,14 @@ public CombineLatest(IObservable first, IObservable second, Fun _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_first, _second); internal sealed class _ : IdentitySink { private readonly Func _resultSelector; - private readonly object _gate = new object(); + private readonly object _gate = new(); public _(Func resultSelector, IObserver observer) : base(observer) @@ -385,13 +385,13 @@ public CombineLatest(IEnumerable> sources, Func observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_sources); internal sealed class _ : IdentitySink { - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly Func, TResult> _resultSelector; public _(Func, TResult> resultSelector, IObserver observer) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Concat.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Concat.cs index bf7ceb2495..f596f54124 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Concat.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Concat.cs @@ -15,7 +15,7 @@ public Concat(IEnumerable> sources) _sources = sources; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_sources); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Contains.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Contains.cs index 3c972bbdc4..009eca3926 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Contains.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Contains.cs @@ -19,7 +19,7 @@ public Contains(IObservable source, TSource value, IEqualityComparer observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Count.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Count.cs index dec75947a7..40dfe0dc71 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Count.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Count.cs @@ -15,7 +15,7 @@ public All(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -62,7 +62,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/DefaultIfEmpty.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/DefaultIfEmpty.cs index 918f6e9aa6..6ec037197c 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/DefaultIfEmpty.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/DefaultIfEmpty.cs @@ -15,7 +15,7 @@ public DefaultIfEmpty(IObservable source, TSource defaultValue) _defaultValue = defaultValue; } - protected override _ CreateSink(IObserver observer) => new _(_defaultValue, observer); + protected override _ CreateSink(IObserver observer) => new(_defaultValue, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Defer.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Defer.cs index e2c4f40730..1516562eb1 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Defer.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Defer.cs @@ -13,7 +13,7 @@ public Defer(Func> observableFactory) _observableFactory = observableFactory; } - protected override _ CreateSink(IObserver observer) => new _(_observableFactory, observer); + protected override _ CreateSink(IObserver observer) => new(_observableFactory, observer); protected override void Run(_ sink) => sink.Run(); 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 c534791b24..1abebc011a 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Delay.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Delay.cs @@ -50,7 +50,7 @@ public void Run(TParent parent) internal abstract class S : _ { - protected readonly object _gate = new object(); + protected readonly object _gate = new(); protected SerialDisposableValue _cancelable; protected S(TParent parent, IObserver observer) @@ -62,7 +62,7 @@ protected S(TParent parent, IObserver observer) protected bool _ready; protected bool _active; protected bool _running; - protected Queue> _queue = new Queue>(); + protected Queue> _queue = new(); private bool _hasCompleted; private TimeSpan _completeAt; @@ -261,15 +261,15 @@ private void DrainQueue(Action recurse) protected abstract class L : _ { - protected readonly object _gate = new object(); - private readonly SemaphoreSlim _evt = new SemaphoreSlim(0); + protected readonly object _gate = new(); + private readonly SemaphoreSlim _evt = new(0); protected L(TParent parent, IObserver observer) : base(parent, observer) { } - protected Queue> _queue = new Queue>(); + protected Queue> _queue = new(); protected SerialDisposableValue _cancelable; protected TimeSpan _delay; @@ -338,7 +338,9 @@ public override void OnCompleted() } } +#pragma warning disable CA1068 // (CancellationToken parameters must come last.) Method signature determined by ISchedulerLongRunning, so we can't comply with the analyzer rule here. private void DrainQueue(CancellationToken token, ICancelable cancel) +#pragma warning restore CA1068 { while (true) { @@ -595,8 +597,8 @@ protected Base(IObservable source) internal abstract class _ : IdentitySink { - private readonly CompositeDisposable _delays = new CompositeDisposable(); - private readonly object _gate = new object(); + private readonly CompositeDisposable _delays = new(); + private readonly object _gate = new(); private readonly Func> _delaySelector; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/DelaySubscription.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/DelaySubscription.cs index a5d0a05a50..63c021d9c3 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/DelaySubscription.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/DelaySubscription.cs @@ -27,7 +27,7 @@ public Relative(IObservable source, TimeSpan dueTime, IScheduler schedu _dueTime = dueTime; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source, _scheduler, _dueTime); } @@ -42,7 +42,7 @@ public Absolute(IObservable source, DateTimeOffset dueTime, IScheduler _dueTime = dueTime; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source, _scheduler, _dueTime); } diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Dematerialize.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Dematerialize.cs index 63e655f110..e082e28184 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Dematerialize.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Dematerialize.cs @@ -13,7 +13,7 @@ public Dematerialize(IObservable> source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Distinct.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Distinct.cs index 3d87e8b12a..b1f7a1ca6f 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Distinct.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Distinct.cs @@ -19,7 +19,7 @@ public Distinct(IObservable source, Func keySelector, IE _comparer = comparer; } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/DistinctUntilChanged.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/DistinctUntilChanged.cs index 92d43d04fe..9541a6ab28 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/DistinctUntilChanged.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/DistinctUntilChanged.cs @@ -19,7 +19,7 @@ public DistinctUntilChanged(IObservable source, Func key _comparer = comparer; } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Do.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Do.cs index bc8214f2c3..45fcb89c75 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Do.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Do.cs @@ -17,7 +17,7 @@ public OnNext(IObservable source, Action onNext) _onNext = onNext; } - protected override _ CreateSink(IObserver observer) => new _(_onNext, observer); + protected override _ CreateSink(IObserver observer) => new(_onNext, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -59,7 +59,7 @@ public Observer(IObservable source, IObserver observer) _observer = observer; } - protected override _ CreateSink(IObserver observer) => new _(_observer, observer); + protected override _ CreateSink(IObserver observer) => new(_observer, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -135,7 +135,7 @@ public Actions(IObservable source, Action onNext, Action observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/DoWhile.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/DoWhile.cs index 7dbbb7331c..c6ff70800f 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/DoWhile.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/DoWhile.cs @@ -17,7 +17,7 @@ public DoWhile(IObservable source, Func condition) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(GetSources()); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAt.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAt.cs index badf13ec92..e3cbf51dd9 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAt.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAt.cs @@ -15,7 +15,7 @@ public ElementAt(IObservable source, int index) _index = index; } - protected override _ CreateSink(IObserver observer) => new _(_index, observer); + protected override _ CreateSink(IObserver observer) => new(_index, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAtOrDefault.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAtOrDefault.cs index a17d89787c..5050f8a77a 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAtOrDefault.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ElementAtOrDefault.cs @@ -15,7 +15,7 @@ public ElementAtOrDefault(IObservable source, int index) _index = index; } - protected override _ CreateSink(IObserver observer) => new _(_index, observer); + protected override _ CreateSink(IObserver observer) => new(_index, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Empty.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Empty.cs index 941b4211bb..3a8233ae3c 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Empty.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Empty.cs @@ -16,7 +16,7 @@ public Empty(IScheduler scheduler) _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_scheduler); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Finally.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Finally.cs index 6d03721f70..c41a732cf2 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Finally.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Finally.cs @@ -18,7 +18,7 @@ public Finally(IObservable source, Action finallyAction) _finallyAction = finallyAction; } - protected override _ CreateSink(IObserver observer) => new _(_finallyAction, observer); + protected override _ CreateSink(IObserver observer) => new(_finallyAction, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/FirstAsync.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/FirstAsync.cs index 86c227c2fa..e54118043e 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/FirstAsync.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/FirstAsync.cs @@ -15,7 +15,7 @@ public Sequence(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -63,7 +63,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/FirstOrDefaultAsync.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/FirstOrDefaultAsync.cs index 4f076680f2..ec51b09963 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/FirstOrDefaultAsync.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/FirstOrDefaultAsync.cs @@ -15,7 +15,7 @@ public Sequence(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -51,7 +51,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/For.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/For.cs index ad739478c8..6449cc8e9e 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/For.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/For.cs @@ -17,7 +17,7 @@ public For(IEnumerable source, Func> resu _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(GetSources()); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/FromEvent.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/FromEvent.cs index 5bb32a7eb4..4d7ad285d8 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/FromEvent.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/FromEvent.cs @@ -219,10 +219,7 @@ protected override IDisposable Run(IObserver observer) // the session will reach out to reset the _session field to null under the _gate // lock. Future subscriptions will cause a new session to be created. // - if (_session == null) - { - _session = new Session(this); - } + _session ??= new Session(this); connection = _session.Connect(observer); } @@ -234,7 +231,7 @@ private sealed class Session { private readonly EventProducer _parent; private readonly Subject _subject; - private readonly SingleAssignmentDisposable _removeHandler = new SingleAssignmentDisposable(); + private readonly SingleAssignmentDisposable _removeHandler = new(); private int _count; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Generate.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Generate.cs index e31a811733..0bfa8a4549 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Generate.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Generate.cs @@ -26,7 +26,7 @@ public NoTime(TState initialState, Func condition, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_scheduler); @@ -171,7 +171,7 @@ public Absolute(TState initialState, Func condition, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_scheduler, _initialState); @@ -280,7 +280,7 @@ public Relative(TState initialState, Func condition, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_scheduler, _initialState); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupBy.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupBy.cs index 367055e402..13ff5592a7 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupBy.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupBy.cs @@ -25,7 +25,7 @@ public GroupBy(IObservable source, Func keySelector, Fun _comparer = comparer; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); 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 67fdd37712..0d5521f01b 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupByUntil.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupByUntil.cs @@ -27,15 +27,15 @@ public GroupByUntil(IObservable source, Func keySelector _comparer = comparer; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink> { - private readonly object _gate = new object(); - private readonly object _nullGate = new object(); - private readonly CompositeDisposable _groupDisposable = new CompositeDisposable(); + private readonly object _gate = new(); + private readonly object _nullGate = new(); + private readonly CompositeDisposable _groupDisposable = new(); 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 626d1fbca2..842dc54f27 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupJoin.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/GroupJoin.cs @@ -25,14 +25,14 @@ public GroupJoin(IObservable left, IObservable right, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : IdentitySink { - private readonly object _gate = new object(); - private readonly CompositeDisposable _group = new CompositeDisposable(); + private readonly object _gate = new(); + private readonly CompositeDisposable _group = new(); private readonly RefCountDisposable _refCount; private readonly SortedDictionary> _leftMap; private readonly SortedDictionary _rightMap; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/If.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/If.cs index 4bec903dc4..e1d2f53e35 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/If.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/If.cs @@ -19,7 +19,7 @@ public If(Func condition, IObservable thenSource, IObservable Eval() => _condition() ? _thenSource : _elseSource; - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/IgnoreElements.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/IgnoreElements.cs index 34c1809133..3cca3fb340 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/IgnoreElements.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/IgnoreElements.cs @@ -13,7 +13,7 @@ public IgnoreElements(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/IsEmpty.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/IsEmpty.cs index 6518294461..2700ec6f9a 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/IsEmpty.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/IsEmpty.cs @@ -13,7 +13,7 @@ public IsEmpty(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); 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 3e0748645f..3b7db67747 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Join.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Join.cs @@ -24,16 +24,16 @@ public Join(IObservable left, IObservable right, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : IdentitySink { - private readonly object _gate = new object(); - private readonly CompositeDisposable _group = new CompositeDisposable(); - private readonly SortedDictionary _leftMap = new SortedDictionary(); - private readonly SortedDictionary _rightMap = new SortedDictionary(); + private readonly object _gate = new(); + private readonly CompositeDisposable _group = new(); + private readonly SortedDictionary _leftMap = new(); + private readonly SortedDictionary _rightMap = new(); private readonly Func> _leftDurationSelector; private readonly Func> _rightDurationSelector; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/LastAsync.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/LastAsync.cs index 6b741e7780..890c388478 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/LastAsync.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/LastAsync.cs @@ -15,7 +15,7 @@ public Sequence(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -77,7 +77,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/LastOrDefaultAsync.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/LastOrDefaultAsync.cs index 1a64fbcc8d..c6a6622403 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/LastOrDefaultAsync.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/LastOrDefaultAsync.cs @@ -15,7 +15,7 @@ public Sequence(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -61,7 +61,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/LongCount.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/LongCount.cs index bfbe902741..d04f3ff12d 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/LongCount.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/LongCount.cs @@ -15,7 +15,7 @@ public All(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -62,7 +62,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Materialize.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Materialize.cs index d115249972..0f833c01b9 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Materialize.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Materialize.cs @@ -15,7 +15,7 @@ public Materialize(IObservable source) public IObservable Dematerialize() => _source.AsObservable(); - protected override _ CreateSink(IObserver> observer) => new _(observer); + protected override _ CreateSink(IObserver> observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Max.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Max.cs index 28f589ab37..18936fb26d 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Max.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Max.cs @@ -150,7 +150,7 @@ public MaxDouble(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -211,7 +211,7 @@ public MaxSingle(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -272,7 +272,7 @@ public MaxDecimal(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -333,7 +333,7 @@ public MaxInt32(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -394,7 +394,7 @@ public MaxInt64(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -455,7 +455,7 @@ public MaxDoubleNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -505,7 +505,7 @@ public MaxSingleNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -555,7 +555,7 @@ public MaxDecimalNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -605,7 +605,7 @@ public MaxInt32Nullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -655,7 +655,7 @@ public MaxInt64Nullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); 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 31e02256e0..f3f56893ca 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/MaxBy.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/MaxBy.cs @@ -19,7 +19,7 @@ public MaxBy(IObservable source, Func keySelector, IComp _comparer = comparer; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); 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 9feddf82cc..06e5971913 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Merge.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Merge.cs @@ -23,16 +23,16 @@ public ObservablesMaxConcurrency(IObservable> sources, int _maxConcurrent = maxConcurrent; } - protected override _ CreateSink(IObserver observer) => new _(_maxConcurrent, observer); + protected override _ CreateSink(IObserver observer) => new(_maxConcurrent, observer); protected override void Run(_ sink) => sink.Run(_sources); internal sealed class _ : Sink, TSource> { - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly int _maxConcurrent; - private readonly Queue> _q = new Queue>(); - private readonly CompositeDisposable _group = new CompositeDisposable(); + private readonly Queue> _q = new(); + private readonly CompositeDisposable _group = new(); public _(int maxConcurrent, IObserver observer) : base(observer) @@ -158,14 +158,14 @@ public Observables(IObservable> sources) _sources = sources; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_sources); internal sealed class _ : Sink, TSource> { - private readonly object _gate = new object(); - private readonly CompositeDisposable _group = new CompositeDisposable(); + private readonly object _gate = new(); + private readonly CompositeDisposable _group = new(); public _(IObserver observer) : base(observer) @@ -278,14 +278,14 @@ public Tasks(IObservable> sources) _sources = sources; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_sources); internal sealed class _ : Sink, TSource> { - private readonly object _gate = new object(); - private readonly CancellationTokenSource _cts = new CancellationTokenSource(); + private readonly object _gate = new(); + private readonly CancellationTokenSource _cts = new(); public _(IObserver observer) : base(observer) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Min.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Min.cs index c1544c8353..e2785200fb 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Min.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Min.cs @@ -150,7 +150,7 @@ public MinDouble(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -211,7 +211,7 @@ public MinSingle(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -272,7 +272,7 @@ public MinDecimal(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -333,7 +333,7 @@ public MinInt32(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -394,7 +394,7 @@ public MinInt64(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -455,7 +455,7 @@ public MinDoubleNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -505,7 +505,7 @@ public MinSingleNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -555,7 +555,7 @@ public MinDecimalNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -605,7 +605,7 @@ public MinInt32Nullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -655,7 +655,7 @@ public MinInt64Nullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); 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 ed19632040..6c87ab8016 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/MinBy.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/MinBy.cs @@ -19,7 +19,7 @@ public MinBy(IObservable source, Func keySelector, IComp _comparer = comparer; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Multicast.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Multicast.cs index ef9c38c8b9..26f5cc1f14 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Multicast.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Multicast.cs @@ -20,7 +20,7 @@ public Multicast(IObservable source, Func observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/OfType.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/OfType.cs index 9653540707..6932677173 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/OfType.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/OfType.cs @@ -13,7 +13,7 @@ public OfType(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/OnErrorResumeNext.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/OnErrorResumeNext.cs index f14f9317f9..85f36d8639 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/OnErrorResumeNext.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/OnErrorResumeNext.cs @@ -15,7 +15,7 @@ public OnErrorResumeNext(IEnumerable> sources) _sources = sources; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_sources); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Range.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Range.cs index 344cc28c54..3b4a193fa6 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Range.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Range.cs @@ -20,7 +20,7 @@ public RangeRecursive(int start, int count, IScheduler scheduler) _scheduler = scheduler; } - protected override RangeSink CreateSink(IObserver observer) => new RangeSink(_start, _count, observer); + protected override RangeSink CreateSink(IObserver observer) => new(_start, _count, observer); protected override void Run(RangeSink sink) => sink.Run(_scheduler); @@ -86,7 +86,7 @@ public RangeLongRunning(int start, int count, ISchedulerLongRunning scheduler) _scheduler = scheduler; } - protected override RangeSink CreateSink(IObserver observer) => new RangeSink(_start, _count, observer); + protected override RangeSink CreateSink(IObserver observer) => new(_start, _count, observer); protected override void Run(RangeSink sink) => sink.Run(_scheduler); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/RefCount.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/RefCount.cs index b1358df8c2..686b3ee654 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/RefCount.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/RefCount.cs @@ -15,7 +15,7 @@ internal sealed class Eager : Producer { private readonly IConnectableObservable _source; - private readonly object _gate = new object(); + private readonly object _gate = new(); /// /// Contains the current active connection's state or null @@ -32,7 +32,7 @@ public Eager(IConnectableObservable source, int minObservers) _minObservers = minObservers; } - protected override _ CreateSink(IObserver observer) => new _(observer, this); + protected override _ CreateSink(IObserver observer) => new(observer, this); protected override void Run(_ sink) => sink.Run(); @@ -156,7 +156,7 @@ public Lazy(IConnectableObservable source, TimeSpan disconnectTime, ISc _minObservers = minObservers; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); @@ -175,10 +175,7 @@ public void Run(Lazy parent) { if (++parent._count == parent._minObservers) { - if (parent._connectableSubscription == null) - { - parent._connectableSubscription = parent._source.Connect(); - } + parent._connectableSubscription ??= parent._source.Connect(); Disposable.TrySetSerial(ref parent._serial, new SingleAssignmentDisposable()); } diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Repeat.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Repeat.cs index ffce126382..7188032670 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Repeat.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Repeat.cs @@ -20,7 +20,7 @@ public ForeverRecursive(TResult value, IScheduler scheduler) _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(_value, observer); + protected override _ CreateSink(IObserver observer) => new(_value, observer); protected override void Run(_ sink) => sink.Run(_scheduler); @@ -75,7 +75,7 @@ public ForeverLongRunning(TResult value, ISchedulerLongRunning scheduler) _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(_value, observer); + protected override _ CreateSink(IObserver observer) => new(_value, observer); protected override void Run(_ sink) => sink.Run(_scheduler); @@ -120,7 +120,7 @@ public CountRecursive(TResult value, int repeatCount, IScheduler scheduler) _repeatCount = repeatCount; } - protected override _ CreateSink(IObserver observer) => new _(_value, _repeatCount, observer); + protected override _ CreateSink(IObserver observer) => new(_value, _repeatCount, observer); protected override void Run(_ sink) => sink.Run(_scheduler); @@ -192,7 +192,7 @@ public CountLongRunning(TResult value, int repeatCount, ISchedulerLongRunning sc _repeatCount = repeatCount; } - protected override _ CreateSink(IObserver observer) => new _(_value, _repeatCount, observer); + protected override _ CreateSink(IObserver observer) => new(_value, _repeatCount, observer); protected override void Run(_ sink) => sink.Run(_scheduler); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/RepeatWhen.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/RepeatWhen.cs index f40a17cecd..9e03819d96 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/RepeatWhen.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/RepeatWhen.cs @@ -36,7 +36,9 @@ public IDisposable Subscribe(IObserver observer) if (redo == null) { +#pragma warning disable CA2201 // (Do not raise reserved exception types.) Backwards compatibility prevents us from complying. throw new NullReferenceException("The handler returned a null IObservable"); +#pragma warning restore CA2201 } } catch (Exception ex) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/RetryWhen.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/RetryWhen.cs index 5ba582cf4a..f7ee3944d0 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/RetryWhen.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/RetryWhen.cs @@ -37,7 +37,9 @@ public IDisposable Subscribe(IObserver observer) if (redo == null) { +#pragma warning disable CA2201 // (Do not raise reserved exception types.) Backwards compatibility prevents us from complying. throw new NullReferenceException("The handler returned a null IObservable"); +#pragma warning restore CA2201 } } catch (Exception ex) @@ -161,7 +163,9 @@ public void OnNext(U value) internal sealed class RedoSerializedObserver : IObserver { - private static readonly Exception SignaledIndicator = new Exception(); +#pragma warning disable CA2201 // (Do not raise reserved exception types.) This is a sentinel, and is not thrown, so there's no need for it to be anything else. + private static readonly Exception SignaledIndicator = new(); +#pragma warning restore CA2201 private readonly IObserver _downstream; private readonly ConcurrentQueue _queue; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Return.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Return.cs index 2fa0f9a569..1cfbce40ae 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Return.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Return.cs @@ -18,7 +18,7 @@ public Return(TResult value, IScheduler scheduler) _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(_value, observer); + protected override _ CreateSink(IObserver observer) => new(_value, observer); protected override void Run(_ sink) => sink.Run(_scheduler); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Sample.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Sample.cs index c5e15e962d..66422eff36 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Sample.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Sample.cs @@ -18,13 +18,13 @@ public Sample(IObservable source, IObservable sampler) _sampler = sampler; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : IdentitySink { - private readonly object _gate = new object(); + private readonly object _gate = new(); public _(IObserver observer) : base(observer) @@ -165,13 +165,13 @@ public Sample(IObservable source, TimeSpan interval, IScheduler schedul _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : IdentitySink { - private readonly object _gate = new object(); + private readonly object _gate = new(); public _(IObserver observer) : base(observer) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Scan.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Scan.cs index 67b8a2353a..f4593dfb22 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Scan.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Scan.cs @@ -17,7 +17,7 @@ public Scan(IObservable source, TAccumulate seed, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -61,7 +61,7 @@ public Scan(IObservable source, Func accumul _accumulator = accumulator; } - protected override _ CreateSink(IObserver observer) => new _(_accumulator, observer); + protected override _ CreateSink(IObserver observer) => new(_accumulator, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Select.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Select.cs index 7f74e145da..0fccea6296 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Select.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Select.cs @@ -17,7 +17,7 @@ public Selector(IObservable source, Func selector) _selector = selector; } - protected override _ CreateSink(IObserver observer) => new _(_selector, observer); + protected override _ CreateSink(IObserver observer) => new(_selector, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -60,7 +60,7 @@ public SelectorIndexed(IObservable source, Func _selector = selector; } - protected override _ CreateSink(IObserver observer) => new _(_selector, observer); + protected override _ CreateSink(IObserver observer) => new(_selector, observer); protected override void Run(_ sink) => sink.Run(_source); 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 b72caae4f0..17c19f80cc 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs @@ -25,14 +25,14 @@ public ObservableSelector(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink { - private readonly object _gate = new object(); - private readonly CompositeDisposable _group = new CompositeDisposable(); + private readonly object _gate = new(); + private readonly CompositeDisposable _group = new(); private readonly Func> _collectionSelector; private readonly Func _resultSelector; @@ -186,14 +186,14 @@ public ObservableSelectorIndexed(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink { - private readonly object _gate = new object(); - private readonly CompositeDisposable _group = new CompositeDisposable(); + private readonly object _gate = new(); + private readonly CompositeDisposable _group = new(); private readonly Func> _collectionSelector; private readonly Func _resultSelector; @@ -354,7 +354,7 @@ public EnumerableSelector(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -439,7 +439,7 @@ public EnumerableSelectorIndexed(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -530,14 +530,14 @@ public TaskSelector(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink { - private readonly object _gate = new object(); - private readonly CancellationTokenSource _cancel = new CancellationTokenSource(); + private readonly object _gate = new(); + private readonly CancellationTokenSource _cancel = new(); private readonly Func> _collectionSelector; private readonly Func _resultSelector; @@ -684,14 +684,14 @@ public TaskSelectorIndexed(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink { - private readonly object _gate = new object(); - private readonly CancellationTokenSource _cancel = new CancellationTokenSource(); + private readonly object _gate = new(); + private readonly CancellationTokenSource _cancel = new(); private readonly Func> _collectionSelector; private readonly Func _resultSelector; @@ -842,15 +842,15 @@ public ObservableSelector(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal class _ : Sink { - protected readonly object _gate = new object(); + protected readonly object _gate = new(); private readonly Func> _selector; - private readonly CompositeDisposable _group = new CompositeDisposable(); + private readonly CompositeDisposable _group = new(); private volatile bool _isStopped; @@ -1074,14 +1074,14 @@ public ObservableSelectorIndexed(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal class _ : Sink { - private readonly object _gate = new object(); - private readonly CompositeDisposable _group = new CompositeDisposable(); + private readonly object _gate = new(); + private readonly CompositeDisposable _group = new(); protected readonly Func> _selector; @@ -1231,7 +1231,7 @@ public ObservableSelectorsIndexed(IObservable source, Func> _selectorOnError; private readonly Func> _selectorOnCompleted; @@ -1310,7 +1310,7 @@ public EnumerableSelector(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -1391,7 +1391,7 @@ public EnumerableSelectorIndexed(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -1474,14 +1474,14 @@ public TaskSelector(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink { - private readonly object _gate = new object(); - private readonly CancellationTokenSource _cts = new CancellationTokenSource(); + private readonly object _gate = new(); + private readonly CancellationTokenSource _cts = new(); private readonly Func> _selector; @@ -1608,14 +1608,14 @@ public TaskSelectorIndexed(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink { - private readonly object _gate = new object(); - private readonly CancellationTokenSource _cts = new CancellationTokenSource(); + private readonly object _gate = new(); + private readonly CancellationTokenSource _cts = new(); private readonly Func> _selector; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SequenceEqual.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SequenceEqual.cs index 95f9540dc4..bba056fb4c 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SequenceEqual.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SequenceEqual.cs @@ -23,7 +23,7 @@ public Observable(IObservable first, IObservable second, IEqua _comparer = comparer; } - protected override _ CreateSink(IObserver observer) => new _(_comparer, observer); + protected override _ CreateSink(IObserver observer) => new(_comparer, observer); protected override void Run(_ sink) => sink.Run(this); @@ -227,7 +227,7 @@ public Enumerable(IObservable first, IEnumerable second, IEqua _comparer = comparer; } - protected override _ CreateSink(IObserver observer) => new _(_comparer, observer); + protected override _ CreateSink(IObserver observer) => new(_comparer, observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SingleAsync.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SingleAsync.cs index b7c551f736..251594fffd 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SingleAsync.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SingleAsync.cs @@ -15,7 +15,7 @@ public Sequence(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -81,7 +81,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SingleOrDefaultAsync.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SingleOrDefaultAsync.cs index 6af1c8fbb4..02609071d1 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SingleOrDefaultAsync.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SingleOrDefaultAsync.cs @@ -15,7 +15,7 @@ public Sequence(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -67,7 +67,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Skip.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Skip.cs index fd7c40d38d..8c51ad6fe4 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Skip.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Skip.cs @@ -32,7 +32,7 @@ public IObservable Combine(int count) return new Count(_source, _count + count); } - protected override _ CreateSink(IObserver observer) => new _(_count, observer); + protected override _ CreateSink(IObserver observer) => new(_count, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -92,7 +92,7 @@ public IObservable Combine(TimeSpan duration) return new Time(_source, duration, _scheduler); } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipLast.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipLast.cs index e5d101cc84..96a15d43e2 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipLast.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipLast.cs @@ -20,7 +20,7 @@ public Count(IObservable source, int count) _count = count; } - protected override _ CreateSink(IObserver observer) => new _(_count, observer); + protected override _ CreateSink(IObserver observer) => new(_count, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -61,7 +61,7 @@ public Time(IObservable source, TimeSpan duration, IScheduler scheduler _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(_duration, observer); + protected override _ CreateSink(IObserver observer) => new(_duration, observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipUntil.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipUntil.cs index cfef5c5f52..9f33dbb006 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipUntil.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipUntil.cs @@ -18,7 +18,7 @@ public SkipUntil(IObservable source, IObservable other) _other = other; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); @@ -151,7 +151,7 @@ public IObservable Combine(DateTimeOffset startTime) return new SkipUntil(_source, startTime, _scheduler); } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipWhile.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipWhile.cs index d77b2a235f..4ae7a09483 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipWhile.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/SkipWhile.cs @@ -17,7 +17,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -72,7 +72,7 @@ public PredicateIndexed(IObservable source, Func pr _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Sum.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Sum.cs index 01ef0caa92..22e9074b8e 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Sum.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Sum.cs @@ -13,7 +13,7 @@ public SumDouble(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -48,7 +48,7 @@ public SumSingle(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -83,7 +83,7 @@ public SumDecimal(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -118,7 +118,7 @@ public SumInt32(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -163,7 +163,7 @@ public SumInt64(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -208,7 +208,7 @@ public SumDoubleNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -246,7 +246,7 @@ public SumSingleNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -284,7 +284,7 @@ public SumDecimalNullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -322,7 +322,7 @@ public SumInt32Nullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); @@ -370,7 +370,7 @@ public SumInt64Nullable(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Switch.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Switch.cs index 56ae7dc833..7359d726be 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Switch.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Switch.cs @@ -15,13 +15,13 @@ public Switch(IObservable> sources) _sources = sources; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_sources); internal sealed class _ : Sink, TSource> { - private readonly object _gate = new object(); + private readonly object _gate = new(); public _(IObserver observer) : base(observer) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Synchronize.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Synchronize.cs index 14f25878a0..18cf16109f 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Synchronize.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Synchronize.cs @@ -20,7 +20,7 @@ public Synchronize(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(_gate, observer); + protected override _ CreateSink(IObserver observer) => new(_gate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Take.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Take.cs index c91c8dd33f..228e19b1c1 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Take.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Take.cs @@ -37,7 +37,7 @@ public IObservable Combine(int count) return new Count(_source, count); } - protected override _ CreateSink(IObserver observer) => new _(_count, observer); + protected override _ CreateSink(IObserver observer) => new(_count, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -99,13 +99,13 @@ public IObservable Combine(TimeSpan duration) return new Time(_source, duration, _scheduler); } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : IdentitySink { - private readonly object _gate = new object(); + private readonly object _gate = new(); public _(IObserver observer) : base(observer) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLast.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLast.cs index e05c7ff367..765158d42a 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLast.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLast.cs @@ -23,7 +23,7 @@ public Count(IObservable source, int count, IScheduler loopScheduler) _loopScheduler = loopScheduler; } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -132,7 +132,7 @@ public Time(IObservable source, TimeSpan duration, IScheduler scheduler _loopScheduler = loopScheduler; } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source, _scheduler); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLastBuffer.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLastBuffer.cs index 01bf75fa1e..dcb65b5699 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLastBuffer.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeLastBuffer.cs @@ -20,7 +20,7 @@ public Count(IObservable source, int count) _count = count; } - protected override _ CreateSink(IObserver> observer) => new _(_count, observer); + protected override _ CreateSink(IObserver> observer) => new(_count, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -74,7 +74,7 @@ public Time(IObservable source, TimeSpan duration, IScheduler scheduler _scheduler = scheduler; } - protected override _ CreateSink(IObserver> observer) => new _(_duration, observer); + protected override _ CreateSink(IObserver> observer) => new(_duration, observer); protected override void Run(_ sink) => sink.Run(_source, _scheduler); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeUntil.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeUntil.cs index c5b1d50670..3d434a1870 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeUntil.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeUntil.cs @@ -18,7 +18,7 @@ public TakeUntil(IObservable source, IObservable other) _other = other; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); @@ -128,7 +128,7 @@ public IObservable Combine(DateTimeOffset endTime) return new TakeUntil(_source, endTime, _scheduler); } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeUntilPredicate.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeUntilPredicate.cs index 65251ea4ca..422c978243 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeUntilPredicate.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeUntilPredicate.cs @@ -20,7 +20,7 @@ public TakeUntilPredicate(IObservable source, Func stopP _stopPredicate = stopPredicate; } - protected override TakeUntilPredicateObserver CreateSink(IObserver observer) => new TakeUntilPredicateObserver(observer, _stopPredicate); + protected override TakeUntilPredicateObserver CreateSink(IObserver observer) => new(observer, _stopPredicate); protected override void Run(TakeUntilPredicateObserver sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeWhile.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeWhile.cs index 02410fe204..7077a9ec22 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeWhile.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TakeWhile.cs @@ -17,7 +17,7 @@ public Predicate(IObservable source, Func predicate) _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -71,7 +71,7 @@ public PredicateIndexed(IObservable source, Func pr _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Throttle.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Throttle.cs index bfaf6a7d67..5b579e0c1d 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Throttle.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Throttle.cs @@ -20,13 +20,13 @@ public Throttle(IObservable source, TimeSpan dueTime, IScheduler schedu _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : IdentitySink { - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly TimeSpan _dueTime; private readonly IScheduler _scheduler; @@ -125,13 +125,13 @@ public Throttle(IObservable source, Func observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : IdentitySink { - private readonly object _gate = new object(); + private readonly object _gate = new(); private readonly Func> _throttleSelector; public _(Throttle parent, IObserver observer) diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Throw.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Throw.cs index d101c3d4e4..72fc691b08 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Throw.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Throw.cs @@ -18,7 +18,7 @@ public Throw(Exception exception, IScheduler scheduler) _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(_exception, observer); + protected override _ CreateSink(IObserver observer) => new(_exception, observer); protected override void Run(_ sink) => sink.Run(_scheduler); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TimeInterval.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TimeInterval.cs index e790aa7418..5cb21c4b6a 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/TimeInterval.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/TimeInterval.cs @@ -17,7 +17,7 @@ public TimeInterval(IObservable source, IScheduler scheduler) _scheduler = scheduler; } - protected override _ CreateSink(IObserver> observer) => new _(observer); + protected override _ CreateSink(IObserver> observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timeout.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timeout.cs index d04f74e8ad..e149f55066 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timeout.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timeout.cs @@ -25,7 +25,7 @@ public Relative(IObservable source, TimeSpan dueTime, IObservable observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -142,7 +142,7 @@ public Absolute(IObservable source, DateTimeOffset dueTime, IObservable _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(_other, observer); + protected override _ CreateSink(IObserver observer) => new(_other, observer); protected override void Run(_ sink) => sink.Run(this); @@ -230,7 +230,7 @@ public Timeout(IObservable source, IObservable firstTimeout, _other = other; } - protected override _ CreateSink(IObserver observer) => new _(this, observer); + protected override _ CreateSink(IObserver observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timer.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timer.cs index 4a3459cfed..a8e4f0b7c9 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timer.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timer.cs @@ -29,7 +29,7 @@ public Relative(TimeSpan dueTime, IScheduler scheduler) _dueTime = dueTime; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this, _dueTime); } @@ -44,7 +44,7 @@ public Absolute(DateTimeOffset dueTime, IScheduler scheduler) _dueTime = dueTime; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this, _dueTime); } @@ -95,7 +95,7 @@ public Relative(TimeSpan dueTime, TimeSpan period, IScheduler scheduler) _dueTime = dueTime; } - protected override _ CreateSink(IObserver observer) => new _(_period, observer); + protected override _ CreateSink(IObserver observer) => new(_period, observer); protected override void Run(_ sink) => sink.Run(this, _dueTime); } @@ -110,7 +110,7 @@ public Absolute(DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler) _dueTime = dueTime; } - protected override _ CreateSink(IObserver observer) => new _(_period, observer); + protected override _ CreateSink(IObserver observer) => new(_period, observer); protected override void Run(_ sink) => sink.Run(this, _dueTime); } diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timestamp.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timestamp.cs index adfc2f1ffa..f055047375 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timestamp.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Timestamp.cs @@ -17,7 +17,7 @@ public Timestamp(IObservable source, IScheduler scheduler) _scheduler = scheduler; } - protected override _ CreateSink(IObserver> observer) => new _(_scheduler, observer); + protected override _ CreateSink(IObserver> observer) => new(_scheduler, observer); protected override void Run(_ sink) => sink.Run(_source); 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 1dcd9bec4e..80d408581f 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToArray.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToArray.cs @@ -15,7 +15,7 @@ public ToArray(IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToDictionary.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToDictionary.cs index 155291a8d4..1df8d6459d 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToDictionary.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToDictionary.cs @@ -22,7 +22,7 @@ public ToDictionary(IObservable source, Func keySelector _comparer = comparer; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); 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 c72afe117e..95cac9d32c 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToList.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToList.cs @@ -15,7 +15,7 @@ public ToList(IObservable source) _source = source; } - protected override _ CreateSink(IObserver> observer) => new _(observer); + protected override _ CreateSink(IObserver> observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToLookup.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToLookup.cs index 16a55fca11..1add64fce8 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToLookup.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToLookup.cs @@ -22,7 +22,7 @@ public ToLookup(IObservable source, Func keySelector, Fu _comparer = comparer; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToObservable.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToObservable.cs index c121810147..2acc885214 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToObservable.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/ToObservable.cs @@ -19,7 +19,7 @@ public ToObservableRecursive(IEnumerable source, IScheduler scheduler) _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source, _scheduler); @@ -137,7 +137,7 @@ public ToObservableLongRunning(IEnumerable source, ISchedulerLongRunnin _scheduler = scheduler; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(_source, _scheduler); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Using.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Using.cs index 776e17fff8..8095864098 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Using.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Using.cs @@ -18,7 +18,7 @@ public Using(Func resourceFactory, Func observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Where.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Where.cs index 61c6bcec04..9e81a75db3 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Where.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Where.cs @@ -22,7 +22,7 @@ public IObservable Combine(Func predicate) return new Predicate(_source, x => _predicate(x) && predicate(x)); } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); @@ -68,7 +68,7 @@ public PredicateIndexed(IObservable source, Func pr _predicate = predicate; } - protected override _ CreateSink(IObserver observer) => new _(_predicate, observer); + protected override _ CreateSink(IObserver observer) => new(_predicate, observer); protected override void Run(_ sink) => sink.Run(_source); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/While.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/While.cs index 40efcfb75b..3bd5df04e2 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/While.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/While.cs @@ -17,7 +17,7 @@ public While(Func condition, IObservable source) _source = source; } - protected override _ CreateSink(IObserver observer) => new _(observer); + protected override _ CreateSink(IObserver observer) => new(observer); protected override void Run(_ sink) => sink.Run(GetSources()); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Window.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Window.cs index 8d33954057..42eda26bff 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Window.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Window.cs @@ -24,14 +24,14 @@ public Count(IObservable source, int count, int skip) _skip = skip; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink> { - private readonly Queue> _queue = new Queue>(); - private readonly SingleAssignmentDisposable _m = new SingleAssignmentDisposable(); + private readonly Queue> _queue = new(); + private readonly SingleAssignmentDisposable _m = new(); private readonly RefCountDisposable _refCountDisposable; private readonly int _count; @@ -124,15 +124,15 @@ public TimeSliding(IObservable source, TimeSpan timeSpan, TimeSpan time _scheduler = scheduler; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : Sink> { - private readonly object _gate = new object(); - private readonly Queue> _q = new Queue>(); - private readonly SerialDisposable _timerD = new SerialDisposable(); + private readonly object _gate = new(); + private readonly Queue> _q = new(); + private readonly SerialDisposable _timerD = new(); private readonly IScheduler _scheduler; private readonly TimeSpan _timeShift; @@ -288,13 +288,13 @@ public TimeHopping(IObservable source, TimeSpan timeSpan, IScheduler sc _scheduler = scheduler; } - protected override _ CreateSink(IObserver> observer) => new _(observer); + protected override _ CreateSink(IObserver> observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : Sink> { - private readonly object _gate = new object(); + private readonly object _gate = new(); private Subject _subject; public _(IObserver> observer) @@ -379,14 +379,14 @@ public Ferry(IObservable source, TimeSpan timeSpan, int count, ISchedul _scheduler = scheduler; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink> { - private readonly object _gate = new object(); - private readonly SerialDisposable _timerD = new SerialDisposable(); + private readonly object _gate = new(); + private readonly SerialDisposable _timerD = new(); private readonly int _count; private readonly TimeSpan _timeSpan; @@ -516,15 +516,15 @@ public Selector(IObservable source, Func> w _windowClosingSelector = windowClosingSelector; } - protected override _ CreateSink(IObserver> observer) => new _(this, observer); + protected override _ CreateSink(IObserver> observer) => new(this, observer); protected override void Run(_ sink) => sink.Run(_source); internal sealed class _ : Sink> { - private readonly object _gate = new object(); - private readonly AsyncLock _windowGate = new AsyncLock(); - private readonly SerialDisposable _m = new SerialDisposable(); + private readonly object _gate = new(); + private readonly AsyncLock _windowGate = new(); + private readonly SerialDisposable _m = new(); private readonly Func> _windowClosingSelector; private Subject _window; @@ -659,13 +659,13 @@ public Boundaries(IObservable source, IObservable windo _windowBoundaries = windowBoundaries; } - protected override _ CreateSink(IObserver> observer) => new _(observer); + protected override _ CreateSink(IObserver> observer) => new(observer); protected override void Run(_ sink) => sink.Run(this); internal sealed class _ : Sink> { - private readonly object _gate = new object(); + private readonly object _gate = new(); private Subject _window; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/WithLatestFrom.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/WithLatestFrom.cs index 6dc6d350d8..051a3bfeff 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/WithLatestFrom.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/WithLatestFrom.cs @@ -19,14 +19,14 @@ public WithLatestFrom(IObservable first, IObservable second, Fu _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_first, _second); internal sealed class _ : IdentitySink { - private readonly object _gate = new object(); - private readonly object _latestGate = new object(); + private readonly object _gate = new(); + private readonly object _latestGate = new(); private readonly Func _resultSelector; diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.NAry.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.NAry.cs index 9bd09f452a..e14a1bdd81 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.NAry.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.NAry.cs @@ -27,7 +27,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3); @@ -90,7 +90,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4); @@ -161,7 +161,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5); @@ -240,7 +240,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6); @@ -327,7 +327,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7); @@ -422,7 +422,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8); @@ -525,7 +525,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9); @@ -636,7 +636,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10); @@ -755,7 +755,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11); @@ -882,7 +882,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12); @@ -1017,7 +1017,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13); @@ -1160,7 +1160,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13, _source14); @@ -1311,7 +1311,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13, _source14, _source15); @@ -1470,7 +1470,7 @@ public Zip(IObservable source1, IObservable source2, IObservable sou _resultSelector = resultSelector; } - protected override _ CreateSink(IObserver observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_source1, _source2, _source3, _source4, _source5, _source6, _source7, _source8, _source9, _source10, _source11, _source12, _source13, _source14, _source15, _source16); 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 bff6fb2604..1e1b88b3d1 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable/Zip.cs @@ -27,7 +27,7 @@ public Observable(IObservable first, IObservable second, Func observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_first, _second); @@ -263,7 +263,7 @@ public Enumerable(IObservable first, IEnumerable second, Func observer) => new _(_resultSelector, observer); + protected override _ CreateSink(IObserver observer) => new(_resultSelector, observer); protected override void Run(_ sink) => sink.Run(_first, _second); @@ -277,7 +277,7 @@ public _(Func resultSelector, IObserver obser _resultSelector = resultSelector; } - int _enumerationInProgress; + private int _enumerationInProgress; private IEnumerator? _rightEnumerator; @@ -344,7 +344,7 @@ public override void OnNext(TFirst value) } bool hasNext; - TSecond right = default; + TSecond? right = default; var wasDisposed = false; try @@ -585,7 +585,7 @@ public Zip(IEnumerable> sources) _sources = sources; } - protected override _ CreateSink(IObserver> observer) => new _(observer); + protected override _ CreateSink(IObserver> observer) => new(observer); protected override void Run(_ sink) => sink.Run(_sources); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/ObservableEx.cs b/Rx.NET/Source/src/System.Reactive/Linq/ObservableEx.cs index 5da63f8805..c9b47addc9 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/ObservableEx.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/ObservableEx.cs @@ -10,11 +10,14 @@ namespace System.Reactive.Linq /// /// Provides a set of static methods for writing in-memory queries over observable sequences. /// +#pragma warning disable CA1711 // (Don't use Ex suffix.) This has been a public type for many years, so we can't rename it now. public static partial class ObservableEx +#pragma warning restore CA1711 { #pragma warning disable IDE1006 // Naming Styles: 3rd party code is known to reflect for this specific field name +#pragma warning disable IDE0044 // Make readonly: since 3rd party code reflects for this, we shouldn't pretend it won't change private static IQueryLanguageEx s_impl = QueryServices.GetQueryImpl(new QueryLanguageEx()); -#pragma warning restore IDE1006 // Naming Styles +#pragma warning restore IDE1006, IDE0044 // Naming Styles, Make readonly #region Create diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Observable_.cs b/Rx.NET/Source/src/System.Reactive/Linq/Observable_.cs index b2418d4738..92ea76a18b 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Observable_.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Observable_.cs @@ -10,7 +10,8 @@ namespace System.Reactive.Linq public static partial class Observable { #pragma warning disable IDE1006 // Naming Styles: 3rd party code is known to reflect for this specific field name +#pragma warning disable IDE0044 // Make readonly: since 3rd party code reflects for this, we shouldn't pretend it won't change private static IQueryLanguage s_impl = QueryServices.GetQueryImpl(new QueryLanguage()); -#pragma warning restore IDE1006 // Naming Styles +#pragma warning restore IDE1006, IDE0044 // Naming Styles, Make readonly } } diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs b/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs index 0096e3e63c..42411b645f 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. -#pragma warning disable 1591 - using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -150,5 +148,3 @@ public static IQbservable When(this IQbservableProvider provid } } } - -#pragma warning restore 1591 diff --git a/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.cs b/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.cs index 3baf104002..17e51b1bf8 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. -#pragma warning disable 1591 - using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -136,5 +134,3 @@ internal static MethodInfo InfoOf(Expression> f) } } } - -#pragma warning restore 1591 diff --git a/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.NAry.cs b/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.NAry.cs index f712b7a99f..5df75275c7 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.NAry.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.NAry.cs @@ -9,7 +9,9 @@ namespace System.Reactive.Linq { +#pragma warning disable CA1711 // (Don't use Ex suffix.) This has been a public type for many years, so we can't rename it now. public static partial class QbservableEx +#pragma warning restore CA1711 { /// /// Merges the specified observable sequences into one observable sequence of tuple values whenever any of the observable sequences produces an element. diff --git a/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.cs b/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.cs index b01a93f1fa..87319ff6b5 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.cs @@ -13,7 +13,9 @@ namespace System.Reactive.Linq /// Provides a set of static methods for writing queries over observable sequences, allowing translation to a target query language. /// [LocalQueryMethodImplementationType(typeof(ObservableEx))] +#pragma warning disable CA1711 // (Don't use Ex suffix.) This has been a public type for many years, so we can't rename it now. public static partial class QbservableEx +#pragma warning restore CA1711 { internal static Expression GetSourceExpression(IObservable source) { diff --git a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Creation.cs b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Creation.cs index 5d7c74c5c7..ff2e979dd1 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Creation.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Creation.cs @@ -96,7 +96,7 @@ public void OnNext(Unit value) } private readonly IDisposable _subscription; - private readonly CancellationTokenSource _cts = new CancellationTokenSource(); + private readonly CancellationTokenSource _cts = new(); public Subscription(Func, CancellationToken, Task> subscribeAsync, IObserver observer) { @@ -169,7 +169,7 @@ public void OnNext(IDisposable value) } private readonly TaskDisposeCompletionObserver _observer; - private readonly CancellationTokenSource _cts = new CancellationTokenSource(); + private readonly CancellationTokenSource _cts = new(); public Subscription(Func, CancellationToken, Task> subscribeAsync, IObserver observer) { @@ -249,7 +249,7 @@ public void OnNext(Action value) } private readonly TaskDisposeCompletionObserver _observer; - private readonly CancellationTokenSource _cts = new CancellationTokenSource(); + private readonly CancellationTokenSource _cts = new(); public Subscription(Func, CancellationToken, Task> subscribeAsync, IObserver observer) { diff --git a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Single.cs b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Single.cs index d0bfadc310..8148971c14 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Single.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Single.cs @@ -316,7 +316,7 @@ public virtual IObservable StartWith(IObservable sour // IQueryLanguage interface, we went for consistency with the public API, hence the odd position of the IScheduler. // - if (!(values is TSource[] valueArray)) + if (values is not TSource[] valueArray) { var valueList = new List(values); valueArray = valueList.ToArray(); diff --git a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguageEx.cs b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguageEx.cs index 95c66e2e77..2be72f3570 100644 --- a/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguageEx.cs +++ b/Rx.NET/Source/src/System.Reactive/Linq/QueryLanguageEx.cs @@ -486,7 +486,7 @@ public virtual IObservable ManySelect(IObservable : ISubject, T> { private readonly T _head; - private readonly AsyncSubject> _tail = new AsyncSubject>(); + private readonly AsyncSubject> _tail = new(); public ChainObservable(T head) { diff --git a/Rx.NET/Source/src/System.Reactive/ListObservable.cs b/Rx.NET/Source/src/System.Reactive/ListObservable.cs index 65792a4acc..de19a920f2 100644 --- a/Rx.NET/Source/src/System.Reactive/ListObservable.cs +++ b/Rx.NET/Source/src/System.Reactive/ListObservable.cs @@ -16,13 +16,12 @@ namespace System.Reactive /// Represents an object that retains the elements of the observable sequence and signals the end of the sequence. /// /// The type of elements received from the source sequence. - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "By design; Observable suffix takes precedence.")] [Experimental] public class ListObservable : IList, IObservable { private readonly IDisposable _subscription; - private readonly AsyncSubject _subject = new AsyncSubject(); - private readonly List _results = new List(); + private readonly AsyncSubject _subject = new(); + private readonly List _results = new(); /// /// 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/Notification.cs b/Rx.NET/Source/src/System.Reactive/Notification.cs index e1bc7ea4af..32d8acecc3 100644 --- a/Rx.NET/Source/src/System.Reactive/Notification.cs +++ b/Rx.NET/Source/src/System.Reactive/Notification.cs @@ -38,7 +38,6 @@ public enum NotificationKind /// /// The type of the elements received by the observer. [Serializable] - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals", Justification = "Resembles a discriminated union with finite number of subclasses (external users shouldn't create their own subtypes), each of which does override GetHashCode itself.")] public abstract class Notification : IEquatable> { /// diff --git a/Rx.NET/Source/src/System.Reactive/ObservableQuery.cs b/Rx.NET/Source/src/System.Reactive/ObservableQuery.cs index afa2bb34c7..abe1629a56 100644 --- a/Rx.NET/Source/src/System.Reactive/ObservableQuery.cs +++ b/Rx.NET/Source/src/System.Reactive/ObservableQuery.cs @@ -46,7 +46,7 @@ IQueryable IQueryProvider.CreateQuery(Expression expression) // // observable.AsQbservable()..ToEnumerable().AsQueryable() // - if (!(expression is MethodCallExpression call) || + if (expression is not MethodCallExpression call || call.Method.DeclaringType != typeof(Qbservable) || call.Method.Name != nameof(Qbservable.ToQueryable)) { @@ -316,7 +316,9 @@ private IList VisitQbservableOperatorArguments(MethodInfo method, IE // if (method.Name == "When") { +#pragma warning disable CA1851 // (Possible multiple enumerations of 'IEnumerable'.) Simple fixes could actually make things worse (e.g., by making an unnecessary copy), so unless specific perf issues become apparent here, we will tolerate this. var lastArgument = arguments.Last(); +#pragma warning restore CA1851 if (lastArgument.NodeType == ExpressionType.NewArrayInit) { var paramsArray = (NewArrayExpression)lastArgument; @@ -330,7 +332,9 @@ private IList VisitQbservableOperatorArguments(MethodInfo method, IE } } +#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection return arguments.Select(arg => Visit(arg)).ToList(); +#pragma warning restore CA1851 } private class Lazy @@ -362,7 +366,7 @@ public T Value } } - private static readonly Lazy> ObservableMethods = new Lazy>(() => GetMethods(typeof(Observable))); + private static readonly Lazy> ObservableMethods = new(() => GetMethods(typeof(Observable))); private static MethodCallExpression FindObservableMethod(MethodInfo method, IList arguments) { @@ -395,11 +399,8 @@ private static MethodCallExpression FindObservableMethod(MethodInfo method, ILis // From all the operators with the method's name, find the one that matches all arguments. // var typeArgs = method.IsGenericMethod ? method.GetGenericArguments() : null; - var targetMethod = methods[method.Name].FirstOrDefault(candidateMethod => ArgsMatch(candidateMethod, arguments, typeArgs)); - if (targetMethod == null) - { - throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Providers.NO_MATCHING_METHOD_FOUND, method.Name, targetType.Name)); - } + var targetMethod = methods[method.Name].FirstOrDefault(candidateMethod => ArgsMatch(candidateMethod, arguments, typeArgs)) + ?? throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings_Providers.NO_MATCHING_METHOD_FOUND, method.Name, targetType.Name)); // // Restore generic arguments. diff --git a/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Concurrency/DispatcherScheduler.cs b/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Concurrency/DispatcherScheduler.cs index 7770df3f36..613ec646e7 100644 --- a/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Concurrency/DispatcherScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Concurrency/DispatcherScheduler.cs @@ -20,7 +20,7 @@ public class DispatcherScheduler : LocalScheduler, ISchedulerPeriodic /// Gets the scheduler that schedules work on the current . /// [Obsolete(Constants_WindowsThreading.OBSOLETE_INSTANCE_PROPERTY)] - public static DispatcherScheduler Instance => new DispatcherScheduler(System.Windows.Threading.Dispatcher.CurrentDispatcher); + public static DispatcherScheduler Instance => new(System.Windows.Threading.Dispatcher.CurrentDispatcher); /// /// Gets the scheduler that schedules work on the for the current thread. @@ -29,12 +29,8 @@ public static DispatcherScheduler Current { get { - var dispatcher = System.Windows.Threading.Dispatcher.FromThread(Thread.CurrentThread); - if (dispatcher == null) - { - throw new InvalidOperationException(Strings_WindowsThreading.NO_DISPATCHER_CURRENT_THREAD); - } - + var dispatcher = System.Windows.Threading.Dispatcher.FromThread(Thread.CurrentThread) + ?? throw new InvalidOperationException(Strings_WindowsThreading.NO_DISPATCHER_CURRENT_THREAD); return new DispatcherScheduler(dispatcher); } } diff --git a/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Linq/Observable.Remoting.cs b/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Linq/Observable.Remoting.cs index 9f6e94e5b3..9b2f40e2fc 100644 --- a/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Linq/Observable.Remoting.cs +++ b/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Linq/Observable.Remoting.cs @@ -71,9 +71,7 @@ public static IQbservable Remotable(this IQbservable return source.Provider.CreateQuery( Expression.Call( null, -#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), -#pragma warning restore IL2060 source.Expression ) ); @@ -98,7 +96,6 @@ public static IQbservable Remotable(this IQbservable return source.Provider.CreateQuery( Expression.Call( null, -#pragma warning disable IL2060 // ('System.Reflection.MethodInfo.MakeGenericMethod' can not be statically analyzed.) This gets the MethodInfo for the method running right now, so it can't have been trimmed ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), #pragma warning restore IL2060 source.Expression, diff --git a/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Linq/QueryLanguage.Remoting.cs b/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Linq/QueryLanguage.Remoting.cs index 0f09cbb78b..bbd8272f9a 100644 --- a/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Linq/QueryLanguage.Remoting.cs +++ b/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Linq/QueryLanguage.Remoting.cs @@ -54,8 +54,8 @@ // // The two CodeAnalysis suppressions below are explained by the Justification property (scroll to the right): // -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2136:TransparencyAnnotationsShouldNotConflictFxCopRule", Scope = "member", Target = "System.Reactive.Linq.QueryLanguage+RemotableObserver`1.#Unregister()", Justification = "This error only occurs while running FxCop on local builds that don't have NO_CODECOVERAGE set, causing the assembly not to be marked with APTCA (see AssemblyInfo.cs). When APTCA is enabled in official builds, this SecurityTreatAsSafe annotation is required.")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2136:TransparencyAnnotationsShouldNotConflictFxCopRule", Scope = "member", Target = "System.Reactive.Linq.QueryLanguage+RemotableObservable`1+RemotableSubscription.#Unregister()", Justification = "This error only occurs while running FxCop on local builds that don't have NO_CODECOVERAGE set, causing the assembly not to be marked with APTCA (see AssemblyInfo.cs). When APTCA is enabled in official builds, this SecurityTreatAsSafe annotation is required.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2136:TransparencyAnnotationsShouldNotConflictFxCopRule", Scope = "member", Target = "~M:System.Reactive.Linq.RemotingObservable.RemotableObserver`1.Unregister", Justification = "This error only occurs while running FxCop on local builds that don't have NO_CODECOVERAGE set, causing the assembly not to be marked with APTCA (see AssemblyInfo.cs). When APTCA is enabled in official builds, this SecurityTreatAsSafe annotation is required.")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2136:TransparencyAnnotationsShouldNotConflictFxCopRule", Scope = "member", Target = "~M:System.Reactive.Linq.RemotingObservable.RemotableObservable`1.RemotableSubscription.Unregister", Justification = "This error only occurs while running FxCop on local builds that don't have NO_CODECOVERAGE set, causing the assembly not to be marked with APTCA (see AssemblyInfo.cs). When APTCA is enabled in official builds, this SecurityTreatAsSafe annotation is required.")] namespace System.Reactive.Linq { @@ -140,10 +140,7 @@ public void OnCompleted() private void Unregister() { var lease = (ILease)RemotingServices.GetLifetimeService(this); - if (lease != null) - { - lease.Unregister(this); - } + lease?.Unregister(this); } [SecurityCritical] @@ -211,10 +208,7 @@ public void Dispose() private void Unregister() { var lease = (ILease)RemotingServices.GetLifetimeService(this); - if (lease != null) - { - lease.Unregister(this); - } + lease?.Unregister(this); } [SecurityCritical] diff --git a/Rx.NET/Source/src/System.Reactive/Platforms/UWP/Concurrency/CoreDispatcherScheduler.cs b/Rx.NET/Source/src/System.Reactive/Platforms/UWP/Concurrency/CoreDispatcherScheduler.cs index ec42cfd799..ccba5d225f 100644 --- a/Rx.NET/Source/src/System.Reactive/Platforms/UWP/Concurrency/CoreDispatcherScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Platforms/UWP/Concurrency/CoreDispatcherScheduler.cs @@ -53,12 +53,8 @@ public static CoreDispatcherScheduler Current { get { - var window = CoreWindow.GetForCurrentThread(); - if (window == null) - { - throw new InvalidOperationException(Strings_WindowsThreading.NO_WINDOW_CURRENT); - } - + var window = CoreWindow.GetForCurrentThread() + ?? throw new InvalidOperationException(Strings_WindowsThreading.NO_WINDOW_CURRENT); return new CoreDispatcherScheduler(window.Dispatcher); } } diff --git a/Rx.NET/Source/src/System.Reactive/Platforms/UWP/IEventPatternSource.cs b/Rx.NET/Source/src/System.Reactive/Platforms/UWP/IEventPatternSource.cs index dcf77da43b..4d4f267ad8 100644 --- a/Rx.NET/Source/src/System.Reactive/Platforms/UWP/IEventPatternSource.cs +++ b/Rx.NET/Source/src/System.Reactive/Platforms/UWP/IEventPatternSource.cs @@ -18,7 +18,9 @@ public interface IEventPatternSource /// /// Event signaling the next element in the data stream. /// +#pragma warning disable CA1003 // (Use generic EventHandler.) The use of the Windows.Foundation handler type is by design event TypedEventHandler OnNext; +#pragma warning restore CA1003 } } #endif 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 f56435757c..92b6e324ad 100644 --- a/Rx.NET/Source/src/System.Reactive/Runtime/CompilerServices/TaskObservableMethodBuilder.cs +++ b/Rx.NET/Source/src/System.Reactive/Runtime/CompilerServices/TaskObservableMethodBuilder.cs @@ -14,7 +14,9 @@ namespace System.Runtime.CompilerServices /// Represents a builder for asynchronous methods that return a task-like . /// /// The type of the elements in the sequence. +#pragma warning disable CA1815 // (Override equals on value types.) Method only meant to be used by await/async generated code, so equality is not required. public struct TaskObservableMethodBuilder +#pragma warning restore CA1815 { /// /// The compiler-generated asynchronous state machine representing the execution flow of the asynchronous @@ -31,7 +33,9 @@ public struct TaskObservableMethodBuilder /// Creates an instance of the struct. /// /// A new instance of the struct. +#pragma warning disable CA1000 // (Do not declare static members on generic types.) Async method builders are required to define a static Create method, and are require to be generic when the async type produces a result. public static TaskObservableMethodBuilder Create() => default; +#pragma warning restore CA1000 // Do not declare static members on generic types /// /// Begins running the builder with the associated state machine. @@ -39,7 +43,9 @@ public struct TaskObservableMethodBuilder /// The type of the state machine. /// The state machine instance, passed by reference. /// is null. +#pragma warning disable CA1045 // (Avoid ref.) Required because this is an async method builder public void Start(ref TStateMachine stateMachine) +#pragma warning restore CA1045 where TStateMachine : IAsyncStateMachine { if (stateMachine == null) @@ -118,7 +124,9 @@ public void SetException(Exception exception) /// The type of the state machine. /// The awaiter. /// The state machine. +#pragma warning disable CA1045 // (Avoid ref.) Required because this is an async method builder public void AwaitOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) +#pragma warning restore CA1045 where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine { @@ -154,7 +162,9 @@ public void AwaitOnCompleted(ref TAwaiter awaiter, ref /// The awaiter. /// The state machine. [SecuritySafeCritical] +#pragma warning disable CA1045 // (Avoid ref.) Required because this is an async method builder public void AwaitUnsafeOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) +#pragma warning restore CA1045 where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine { diff --git a/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs b/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs index 01f2ae13e5..5ac108ee4a 100644 --- a/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs +++ b/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs @@ -22,15 +22,16 @@ public sealed class AsyncSubject : SubjectBase, INotifyCompletion private bool _hasValue; private Exception? _exception; +#pragma warning disable CA1825 // (Avoid zero-length array allocations.) The identity of these arrays matters, so we can't use the shared Array.Empty() instance /// /// A pre-allocated empty array indicating the AsyncSubject has terminated. /// private static readonly AsyncSubjectDisposable[] Terminated = new AsyncSubjectDisposable[0]; - /// /// A pre-allocated empty array indicating the AsyncSubject has been disposed. /// private static readonly AsyncSubjectDisposable[] Disposed = new AsyncSubjectDisposable[0]; +#pragma warning restore CA1825 #endregion @@ -412,7 +413,6 @@ private void InvokeOnOriginalContext() /// /// The last element of the subject. Throws an InvalidOperationException if no element was received. /// The source sequence is empty. - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Await pattern for C# and VB compilers.")] public T GetResult() { if (Volatile.Read(ref _observers) != Terminated) diff --git a/Rx.NET/Source/src/System.Reactive/Subjects/BehaviorSubject.cs b/Rx.NET/Source/src/System.Reactive/Subjects/BehaviorSubject.cs index 04d0000cc7..5647a9fdf9 100644 --- a/Rx.NET/Source/src/System.Reactive/Subjects/BehaviorSubject.cs +++ b/Rx.NET/Source/src/System.Reactive/Subjects/BehaviorSubject.cs @@ -17,7 +17,7 @@ public sealed class BehaviorSubject : SubjectBase { #region Fields - private readonly object _gate = new object(); + private readonly object _gate = new(); private ImmutableList> _observers; private bool _isStopped; diff --git a/Rx.NET/Source/src/System.Reactive/Subjects/ReplaySubject.cs b/Rx.NET/Source/src/System.Reactive/Subjects/ReplaySubject.cs index afc3a42d9b..aedb1a6a86 100644 --- a/Rx.NET/Source/src/System.Reactive/Subjects/ReplaySubject.cs +++ b/Rx.NET/Source/src/System.Reactive/Subjects/ReplaySubject.cs @@ -215,7 +215,7 @@ public override IDisposable Subscribe(IObserver observer) private abstract class ReplayBase : SubjectBase { - private readonly object _gate = new object(); + private readonly object _gate = new(); private ImmutableList> _observers; @@ -698,7 +698,7 @@ internal sealed class FastImmediateObserver : IScheduledObserver /// /// Gate to control ownership transfer and protect data structures. /// - private readonly object _gate = new object(); + private readonly object _gate = new(); /// /// Observer to forward notifications to. @@ -708,7 +708,7 @@ internal sealed class FastImmediateObserver : IScheduledObserver /// /// Queue to enqueue OnNext notifications into. /// - private Queue _queue = new Queue(); + private Queue _queue = new(); /// /// Standby queue to swap out for _queue when transferring ownership. This allows to reuse @@ -811,10 +811,7 @@ public void EnsureActive(int count) // if (_queue.Count > 0) { - if (_queue2 == null) - { - _queue2 = new Queue(); - } + _queue2 ??= new Queue(); // // Swap out the current queue for a fresh or recycled one. The standby diff --git a/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs b/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs index 6ff8e0dbb2..53a464d4e4 100644 --- a/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs +++ b/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs @@ -18,8 +18,10 @@ public sealed class Subject : SubjectBase private SubjectDisposable[] _observers; private Exception? _exception; +#pragma warning disable CA1825 // (Avoid zero-length array allocations.) The identity of these arrays matters, so we can't use the shared Array.Empty() instance private static readonly SubjectDisposable[] Terminated = new SubjectDisposable[0]; private static readonly SubjectDisposable[] Disposed = new SubjectDisposable[0]; +#pragma warning restore CA1825 #endregion diff --git a/Rx.NET/Source/src/System.Reactive/Subjects/SubjectBase.cs b/Rx.NET/Source/src/System.Reactive/Subjects/SubjectBase.cs index 8f68f22f23..fd14a4dbe0 100644 --- a/Rx.NET/Source/src/System.Reactive/Subjects/SubjectBase.cs +++ b/Rx.NET/Source/src/System.Reactive/Subjects/SubjectBase.cs @@ -8,6 +8,7 @@ namespace System.Reactive.Subjects /// Base class for objects that are both an observable sequence as well as an observer. /// /// The type of the elements processed by the subject. +#pragma warning disable CA1063 // (Overridable IDisposable.) This analyzer wants us to make breaking changes to its public API, which we can't do. public abstract class SubjectBase : ISubject, IDisposable { /// @@ -35,7 +36,9 @@ public abstract class SubjectBase : ISubject, IDisposable /// /// The exception to send to all currently subscribed observers. /// is null. +#pragma warning disable CA1716 // (Identifiers should not match keywords.) This has been the name for years, so the (admittedly small) risk from changing it doesn't seem to offer a meaningful benefit. public abstract void OnError(Exception error); +#pragma warning restore CA1716 /// /// Notifies all subscribed observers about the arrival of the specified element in the sequence. @@ -51,4 +54,5 @@ public abstract class SubjectBase : ISubject, IDisposable /// is null. public abstract IDisposable Subscribe(IObserver observer); } +#pragma warning restore CA1063 } diff --git a/Rx.NET/Source/src/System.Reactive/Threading/Tasks/TaskObservableExtensions.cs b/Rx.NET/Source/src/System.Reactive/Threading/Tasks/TaskObservableExtensions.cs index 7b6ec827d6..a2d08438a7 100644 --- a/Rx.NET/Source/src/System.Reactive/Threading/Tasks/TaskObservableExtensions.cs +++ b/Rx.NET/Source/src/System.Reactive/Threading/Tasks/TaskObservableExtensions.cs @@ -50,8 +50,8 @@ public IDisposable Subscribe(IObserver observer) (task, tuple.observer), static tuple2 => tuple2.task.EmitTaskResult(tuple2.observer)), (scheduler: _scheduler, observer), - cts.Token, - options); + options, + cts.Token); } if (_ignoreExceptionsAfterUnsubscribe) @@ -97,8 +97,8 @@ public IDisposable Subscribe(IObserver observer) (task, tuple.observer), static tuple2 => tuple2.task.EmitTaskResult(tuple2.observer)), (scheduler: _scheduler, observer), - cts.Token, - options); + options, + cts.Token); } if (_ignoreExceptionsAfterUnsubscribe) @@ -470,7 +470,9 @@ public static Task ToTask(this IObservable observable /// The scheduler used for overriding where the task completion signals will be issued. /// A task that will receive the last element or the exception produced by the observable sequence. /// or is null. +#pragma warning disable CA1068 // (CancellationToken parameters must come last.) Would be a breaking change. public static Task ToTask(this IObservable observable, CancellationToken cancellationToken, IScheduler scheduler) +#pragma warning restore CA1068 { return observable.ToTask(cancellationToken, state: null).ContinueOnScheduler(scheduler); } @@ -580,7 +582,9 @@ private void Cancel() /// The state to use as the underlying task's . /// A task that will receive the last element or the exception produced by the observable sequence. /// is null. +#pragma warning disable CA1068 // (CancellationToken parameters must come last.) Would be a breaking change. public static Task ToTask(this IObservable observable, CancellationToken cancellationToken, object? state) +#pragma warning restore CA1068 { if (observable == null) { @@ -625,7 +629,9 @@ public static Task ToTask(this IObservable observable /// The scheduler used for overriding where the task completion signals will be issued. /// A task that will receive the last element or the exception produced by the observable sequence. /// or is null. +#pragma warning disable CA1068 // (CancellationToken parameters must come last.) Would be a breaking change. public static Task ToTask(this IObservable observable, CancellationToken cancellationToken, object? state, IScheduler scheduler) +#pragma warning restore CA1068 { return observable.ToTask(cancellationToken, state).ContinueOnScheduler(scheduler); } diff --git a/Rx.NET/Source/src/System.Reactive/TimeInterval.cs b/Rx.NET/Source/src/System.Reactive/TimeInterval.cs index e34012b371..96d1b59b81 100644 --- a/Rx.NET/Source/src/System.Reactive/TimeInterval.cs +++ b/Rx.NET/Source/src/System.Reactive/TimeInterval.cs @@ -71,7 +71,7 @@ public TimeInterval(T value, TimeSpan interval) /// /// The System.Object to compare with the current . /// true if the specified System.Object is equal to the current ; otherwise, false. - public override bool Equals(object? obj) => obj is TimeInterval && Equals((TimeInterval)obj); + public override bool Equals(object? obj) => obj is TimeInterval interval && Equals(interval); /// /// Returns the hash code for the current value. diff --git a/Rx.NET/Source/src/System.Reactive/Timestamped.cs b/Rx.NET/Source/src/System.Reactive/Timestamped.cs index 3adc08deb9..73b6342c27 100644 --- a/Rx.NET/Source/src/System.Reactive/Timestamped.cs +++ b/Rx.NET/Source/src/System.Reactive/Timestamped.cs @@ -72,7 +72,7 @@ public Timestamped(T value, DateTimeOffset timestamp) /// /// The System.Object to compare with the current . /// true if the specified System.Object is equal to the current ; otherwise, false. - public override bool Equals(object? obj) => obj is Timestamped && Equals((Timestamped)obj); + public override bool Equals(object? obj) => obj is Timestamped timestamped && Equals(timestamped); /// /// Returns the hash code for the current value. diff --git a/Rx.NET/Source/src/System.Reactive/Unit.cs b/Rx.NET/Source/src/System.Reactive/Unit.cs index 1cf242d829..b5239483be 100644 --- a/Rx.NET/Source/src/System.Reactive/Unit.cs +++ b/Rx.NET/Source/src/System.Reactive/Unit.cs @@ -42,7 +42,7 @@ namespace System.Reactive /// The first value to compare. /// The second value to compare. /// Because has a single value, this always returns true. - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "first", Justification = "Parameter required for operator overloading."), Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "second", Justification = "Parameter required for operator overloading.")] +#pragma warning disable IDE0060 // (Remove unused parameter.) Required part of public API public static bool operator ==(Unit first, Unit second) => true; /// @@ -51,8 +51,8 @@ namespace System.Reactive /// The first value to compare. /// The second value to compare. /// Because has a single value, this always returns false. - [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "first", Justification = "Parameter required for operator overloading."), Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "second", Justification = "Parameter required for operator overloading.")] public static bool operator !=(Unit first, Unit second) => false; +#pragma warning restore IDE0060 /// /// Gets the single value. diff --git a/Rx.NET/Source/tests/.editorconfig b/Rx.NET/Source/tests/.editorconfig new file mode 100644 index 0000000000..409f6e5319 --- /dev/null +++ b/Rx.NET/Source/tests/.editorconfig @@ -0,0 +1,10 @@ +[*.cs] + +# Test projects don't need to conform to the .NET Framework class library design guidelines, +# because they are not libraries intended for public consumption. +dotnet_analyzer_diagnostic.category-Design.severity=none + +# A couple of the disable diagnostics have suppressions in the code, so we get 'unnecessary +# suppression' messages unless we re-enable them. +dotnet_diagnostic.CA1067.severity = warning +dotnet_diagnostic.CA1806.severity = warning diff --git a/Rx.NET/Source/tests/Directory.build.props b/Rx.NET/Source/tests/Directory.build.props index b190807678..d29ecf3f99 100644 --- a/Rx.NET/Source/tests/Directory.build.props +++ b/Rx.NET/Source/tests/Directory.build.props @@ -2,5 +2,24 @@ $(MSBuildThisFileDirectory)..\Test.ruleset - + + + None + 7.0-None + 7.0-None + + $(NoWarn);CA2201;IDE1006 + + + + + + \ No newline at end of file diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.verified.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.verified.cs index 8d91199e12..6e3936ec8c 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.verified.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.verified.cs @@ -54,7 +54,7 @@ public class EventPattern : System.IEquatable? other) { } public override bool Equals(object? obj) { } public override int GetHashCode() { } @@ -646,6 +646,10 @@ public struct SingleAssignmentDisposableValue public System.IDisposable? Disposable { get; set; } public bool IsDisposed { get; } public void Dispose() { } + public override bool Equals(object? obj) { } + public override int GetHashCode() { } + public static bool operator !=(System.Reactive.Disposables.SingleAssignmentDisposableValue left, System.Reactive.Disposables.SingleAssignmentDisposableValue right) { } + public static bool operator ==(System.Reactive.Disposables.SingleAssignmentDisposableValue left, System.Reactive.Disposables.SingleAssignmentDisposableValue right) { } } public abstract class StableCompositeDisposable : System.IDisposable, System.Reactive.Disposables.ICancelable { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/App.xaml.cs b/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/App.xaml.cs index c8188b60b6..0b8287c832 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/App.xaml.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.Uwp.DeviceRunner/App.xaml.cs @@ -38,7 +38,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) } #endif - Frame rootFrame = Window.Current.Content as Frame; + var rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/DispatcherHelpers.cs b/Rx.NET/Source/tests/Tests.System.Reactive/DispatcherHelpers.cs index 4b95635cf4..b3312dbb21 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/DispatcherHelpers.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/DispatcherHelpers.cs @@ -15,9 +15,9 @@ namespace ReactiveTests { #if HAS_DISPATCHER - static class DispatcherHelpers + internal static class DispatcherHelpers { - private static readonly Semaphore s_oneDispatcher = new Semaphore(1, 1); + private static readonly Semaphore s_oneDispatcher = new(1, 1); public static IDisposable RunTest(out DispatcherWrapper wrapper) { @@ -69,16 +69,16 @@ public void Dispose() #endif } - class DispatcherWrapper + internal class DispatcherWrapper { - private Dispatcher _dispatcher; + private readonly Dispatcher _dispatcher; public DispatcherWrapper(Dispatcher dispatcher) { _dispatcher = dispatcher; } - public Dispatcher Dispatcher { get { return _dispatcher; } } + public Dispatcher Dispatcher => _dispatcher; public static implicit operator Dispatcher(DispatcherWrapper wrapper) { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyDisposable.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyDisposable.cs index 2e509a8229..ec6f2caed1 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyDisposable.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyDisposable.cs @@ -8,7 +8,7 @@ namespace ReactiveTests.Dummies { internal class DummyDisposable : IDisposable { - public static readonly DummyDisposable Instance = new DummyDisposable(); + public static readonly DummyDisposable Instance = new(); public void Dispose() { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyEnumerable.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyEnumerable.cs index 314c77379b..c9166baee4 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyEnumerable.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyEnumerable.cs @@ -9,7 +9,7 @@ namespace ReactiveTests.Dummies { internal class DummyEnumerable : IEnumerable { - public static readonly DummyEnumerable Instance = new DummyEnumerable(); + public static readonly DummyEnumerable Instance = new(); private DummyEnumerable() { @@ -28,7 +28,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() internal class NullEnumeratorEnumerable : IEnumerable { - public static readonly NullEnumeratorEnumerable Instance = new NullEnumeratorEnumerable(); + public static readonly NullEnumeratorEnumerable Instance = new(); private NullEnumeratorEnumerable() { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyObservable.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyObservable.cs index 5a63131d8a..8d1f9ee43b 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyObservable.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyObservable.cs @@ -8,7 +8,7 @@ namespace ReactiveTests.Dummies { internal class DummyObservable : IObservable { - public static readonly DummyObservable Instance = new DummyObservable(); + public static readonly DummyObservable Instance = new(); private DummyObservable() { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyObserver.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyObserver.cs index 19254c78d9..160cda9fea 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyObserver.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyObserver.cs @@ -8,7 +8,7 @@ namespace ReactiveTests.Dummies { internal class DummyObserver : IObserver { - public static readonly DummyObserver Instance = new DummyObserver(); + public static readonly DummyObserver Instance = new(); private DummyObserver() { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyScheduler.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyScheduler.cs index fc1ba12f3a..1e7985587f 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyScheduler.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Dummies/DummyScheduler.cs @@ -9,7 +9,7 @@ namespace ReactiveTests.Dummies { internal class DummyScheduler : IScheduler { - public static readonly DummyScheduler Instance = new DummyScheduler(); + public static readonly DummyScheduler Instance = new(); private DummyScheduler() { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Extensions.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Extensions.cs index 217408defa..7087e96cf2 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Extensions.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Extensions.cs @@ -34,13 +34,11 @@ public static void EnsureTrampoline(this CurrentThreadScheduler scheduler, Actio public static IEnumerable Zip(this IEnumerable source1, IEnumerable source2, Func f) { - using (var e1 = source1.GetEnumerator()) - using (var e2 = source2.GetEnumerator()) + using var e1 = source1.GetEnumerator(); + using var e2 = source2.GetEnumerator(); + while (e1.MoveNext() && e2.MoveNext()) { - while (e1.MoveNext() && e2.MoveNext()) - { - yield return f(e1.Current, e2.Current); - } + yield return f(e1.Current, e2.Current); } } } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/MockDisposable.cs b/Rx.NET/Source/tests/Tests.System.Reactive/MockDisposable.cs index 1660d4dbf0..26ed95247f 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/MockDisposable.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/MockDisposable.cs @@ -8,13 +8,14 @@ namespace ReactiveTests { +#pragma warning disable CA1816 // (Overridable IDisposable.) This is a specialized base type, and it would be inappropriate to encourage anyone to build derived types that do more in Dispose. public class MockDisposable : List, IDisposable { - private TestScheduler _scheduler; + private readonly TestScheduler _scheduler; public MockDisposable(TestScheduler scheduler) { - this._scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); + _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); Add(scheduler.Clock); } @@ -23,4 +24,5 @@ public void Dispose() Add(_scheduler.Clock); } } +#pragma warning restore CA1816 } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs b/Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs index 943ede77dd..cf34f30b51 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/MockEnumerable.cs @@ -11,13 +11,13 @@ namespace ReactiveTests public class MockEnumerable : IEnumerable { public readonly TestScheduler Scheduler; - public readonly List Subscriptions = new List(); - private IEnumerable _underlyingEnumerable; + public readonly List Subscriptions = new(); + private readonly IEnumerable _underlyingEnumerable; public MockEnumerable(TestScheduler scheduler, IEnumerable underlyingEnumerable) { Scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler)); - this._underlyingEnumerable = underlyingEnumerable ?? throw new ArgumentNullException(nameof(underlyingEnumerable)); + _underlyingEnumerable = underlyingEnumerable ?? throw new ArgumentNullException(nameof(underlyingEnumerable)); } public IEnumerator GetEnumerator() @@ -33,16 +33,16 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() private class MockEnumerator : IEnumerator { private readonly List _subscriptions; - private IEnumerator _enumerator; - private TestScheduler _scheduler; + private readonly IEnumerator _enumerator; + private readonly TestScheduler _scheduler; private readonly int _index; private bool _disposed; public MockEnumerator(TestScheduler scheduler, List subscriptions, IEnumerator enumerator) { - this._subscriptions = subscriptions; - this._enumerator = enumerator; - this._scheduler = scheduler; + _subscriptions = subscriptions; + _enumerator = enumerator; + _scheduler = scheduler; _index = subscriptions.Count; subscriptions.Add(new Subscription(scheduler.Clock)); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/NullErrorObservable.cs b/Rx.NET/Source/tests/Tests.System.Reactive/NullErrorObservable.cs index 9630197f15..bc525659c9 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/NullErrorObservable.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/NullErrorObservable.cs @@ -9,7 +9,7 @@ namespace ReactiveTests { public class NullErrorObservable : IObservable { - public static NullErrorObservable Instance = new NullErrorObservable(); + public static readonly NullErrorObservable Instance = new(); private NullErrorObservable() { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/TaskErrorObservation.cs b/Rx.NET/Source/tests/Tests.System.Reactive/TaskErrorObservation.cs index e0da45e743..88441af2cd 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/TaskErrorObservation.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/TaskErrorObservation.cs @@ -65,7 +65,7 @@ public IDisposable SuscribeWithoutKeepingSourceReachable( _taskWeakReference = new(t); return t; }, - this.Exception); + Exception); } public IDisposable SuscribeWithoutKeepingSourceReachable( @@ -152,7 +152,7 @@ private bool IsTaskStillReachable() private void HandleUnobservedException(object sender, UnobservedTaskExceptionEventArgs e) { - if (e.Exception.InnerException == this.Exception) + if (e.Exception.InnerException == Exception) { e.SetObserved(); _exceptionReportedAsUnobserved.Set(); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/TestBase.cs b/Rx.NET/Source/tests/Tests.System.Reactive/TestBase.cs index 20025aa17b..3c92f32c50 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/TestBase.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/TestBase.cs @@ -19,7 +19,7 @@ public void RunAsync(Action a) public class Waiter { - private ManualResetEvent _evt = new ManualResetEvent(false); + private readonly ManualResetEvent _evt = new(false); public void Set() { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/AnonymousTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/AnonymousTest.cs index a849a8684d..f84ba70e56 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/AnonymousTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/AnonymousTest.cs @@ -7,6 +7,8 @@ using Microsoft.Reactive.Testing; using Microsoft.VisualStudio.TestTools.UnitTesting; +#pragma warning disable CA1806 // (Unused new instance.) These tests expect the constructor to throw. + namespace ReactiveTests.Tests { [TestClass] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ArgumentValidationTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ArgumentValidationTest.cs index 256dda61e3..0595a01e82 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ArgumentValidationTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ArgumentValidationTest.cs @@ -32,7 +32,7 @@ public class ArgumentValidationTest /// as strings generated via , /// mapped to a value. /// - private static Dictionary _defaultValues; + private static readonly Dictionary _defaultValues; /// /// Prepare the default instances for various types used @@ -423,7 +423,7 @@ private static void VerifyClass(Type type) catch (Exception ex) { // reflection wraps the actual exception, let's unwrap it - if (!(ex.InnerException is ArgumentNullException)) + if (ex.InnerException is not ArgumentNullException) { throw new Exception("Method threw: " + method + " @ " + i, ex); } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ControlSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ControlSchedulerTest.cs index 72e54e9738..1e84ff57af 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ControlSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ControlSchedulerTest.cs @@ -23,7 +23,9 @@ public class ControlSchedulerTest [TestMethod] public void Ctor_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new ControlScheduler(null)); +#pragma warning restore CA1806 } [TestMethod] @@ -56,12 +58,12 @@ public void Schedule() { var evt = new ManualResetEvent(false); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new ControlScheduler(lbl); - sch.Schedule(() => { lbl.Text = "Okay"; Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); }); - sch.Schedule(() => { Assert.Equal("Okay", lbl.Text); Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + sch.Schedule(() => { lbl.Text = "Okay"; Assert.NotEqual(id, Environment.CurrentManagedThreadId); }); + sch.Schedule(() => { Assert.Equal("Okay", lbl.Text); Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } @@ -110,19 +112,19 @@ private void ScheduleRelative_(TimeSpan delay) { var evt = new ManualResetEvent(false); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new ControlScheduler(lbl); sch.Schedule(delay, () => { lbl.Text = "Okay"; - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); sch.Schedule(() => { Assert.Equal("Okay", lbl.Text); - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); }); @@ -138,7 +140,7 @@ public void ScheduleRelative_Nested() { var evt = new ManualResetEvent(false); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new ControlScheduler(lbl); @@ -147,12 +149,12 @@ public void ScheduleRelative_Nested() sch.Schedule(TimeSpan.FromSeconds(0.1), () => { lbl.Text = "Okay"; - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); sch.Schedule(() => { Assert.Equal("Okay", lbl.Text); - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); }); @@ -169,14 +171,14 @@ public void ScheduleRelative_Cancel() { var evt = new ManualResetEvent(false); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new ControlScheduler(lbl); sch.Schedule(TimeSpan.FromSeconds(0.1), () => { lbl.Text = "Okay"; - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); var d = sch.Schedule(TimeSpan.FromSeconds(0.1), () => { @@ -191,7 +193,7 @@ public void ScheduleRelative_Cancel() sch.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.Equal("Okay", lbl.Text); - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); }); @@ -204,7 +206,9 @@ public void ScheduleRelative_Cancel() public void SchedulePeriodic_ArgumentChecking() { var s = new ControlScheduler(new Label()); +#pragma warning disable IDE0034 // (Simplify 'default'.) Want to be explicit about overload being tested. ReactiveAssert.Throws(() => s.SchedulePeriodic(42, TimeSpan.FromSeconds(1), default(Func))); +#pragma warning restore IDE0034 ReactiveAssert.Throws(() => s.SchedulePeriodic(42, TimeSpan.Zero, x => x)); ReactiveAssert.Throws(() => s.SchedulePeriodic(42, TimeSpan.FromMilliseconds(1).Subtract(TimeSpan.FromTicks(1)), x => x)); } @@ -216,7 +220,7 @@ public void SchedulePeriodic() { var evt = new ManualResetEvent(false); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new ControlScheduler(lbl); @@ -225,7 +229,7 @@ public void SchedulePeriodic() d.Disposable = sch.SchedulePeriodic(1, TimeSpan.FromSeconds(0.1), n => { lbl.Text = "Okay " + n; - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); if (n == 3) { @@ -234,7 +238,7 @@ public void SchedulePeriodic() sch.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.Equal("Okay 3", lbl.Text); - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); } @@ -258,7 +262,7 @@ public void SchedulePeriodic_Nested() { var evt = new ManualResetEvent(false); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new ControlScheduler(lbl); @@ -271,7 +275,7 @@ public void SchedulePeriodic_Nested() d.Disposable = sch.SchedulePeriodic(1, TimeSpan.FromSeconds(0.1), n => { lbl.Text = "Okay " + n; - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); if (n == 3) { @@ -280,7 +284,7 @@ public void SchedulePeriodic_Nested() sch.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.Equal("Okay 3", lbl.Text); - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/CurrentThreadSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/CurrentThreadSchedulerTest.cs index 64b3659d36..1cf233802b 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/CurrentThreadSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/CurrentThreadSchedulerTest.cs @@ -34,9 +34,9 @@ public void CurrentThread_Now() [TestMethod] public void CurrentThread_ScheduleAction() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var ran = false; - Scheduler.CurrentThread.Schedule(() => { Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); ran = true; }); + Scheduler.CurrentThread.Schedule(() => { Assert.Equal(id, Environment.CurrentManagedThreadId); ran = true; }); Assert.True(ran); } @@ -59,11 +59,11 @@ public void CurrentThread_ScheduleActionError() [TestMethod] public void CurrentThread_ScheduleActionNested() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var ran = false; Scheduler.CurrentThread.Schedule(() => { - Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); + Assert.Equal(id, Environment.CurrentManagedThreadId); Scheduler.CurrentThread.Schedule(() => { ran = true; }); }); Assert.True(ran); @@ -72,11 +72,11 @@ public void CurrentThread_ScheduleActionNested() [TestMethod] public void CurrentThread_ScheduleActionNested_TimeSpan() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var ran = false; Scheduler.CurrentThread.Schedule(() => { - Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); + Assert.Equal(id, Environment.CurrentManagedThreadId); Scheduler.CurrentThread.Schedule(TimeSpan.FromSeconds(1), () => { ran = true; }); }); Assert.True(ran); @@ -85,24 +85,24 @@ public void CurrentThread_ScheduleActionNested_TimeSpan() [TestMethod] public void CurrentThread_ScheduleActionDue() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var ran = false; - Scheduler.CurrentThread.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); ran = true; }); + Scheduler.CurrentThread.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.Equal(id, Environment.CurrentManagedThreadId); ran = true; }); Assert.True(ran, "ran"); } [TestMethod] public void CurrentThread_ScheduleActionDueNested() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var ran = false; Scheduler.CurrentThread.Schedule(TimeSpan.FromSeconds(0.2), () => { - Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); + Assert.Equal(id, Environment.CurrentManagedThreadId); Scheduler.CurrentThread.Schedule(TimeSpan.FromSeconds(0.2), () => { - Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); + Assert.Equal(id, Environment.CurrentManagedThreadId); ran = true; }); }); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DefaultSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DefaultSchedulerTest.cs index df7d15532d..4b723463b2 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DefaultSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DefaultSchedulerTest.cs @@ -35,27 +35,27 @@ public void Get_Now() [TestMethod] public void ScheduleAction() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = DefaultScheduler.Instance; var evt = new ManualResetEvent(false); - nt.Schedule(() => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(() => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } [TestMethod] public void ScheduleActionDue() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = DefaultScheduler.Instance; var evt = new ManualResetEvent(false); - nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } [TestMethod] public void ScheduleActionCancel() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = DefaultScheduler.Instance; var set = false; var d = nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.True(false); set = true; }); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DispatcherSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DispatcherSchedulerTest.cs index 1d2563103a..8ca6a9543c 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DispatcherSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/DispatcherSchedulerTest.cs @@ -22,7 +22,9 @@ public class DispatcherSchedulerTest : TestBase [TestMethod] public void Ctor_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new DispatcherScheduler(null)); +#pragma warning restore CA1806 } [TestMethod] @@ -104,11 +106,11 @@ public void Schedule() { RunAsync(evt => { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new DispatcherScheduler(disp); sch.Schedule(() => { - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); }); @@ -122,7 +124,7 @@ public void ScheduleError() { var ex = new Exception(); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var evt = new ManualResetEvent(false); Exception thrownEx = null; @@ -158,17 +160,17 @@ private void ScheduleRelative_(TimeSpan delay) { var evt = new ManualResetEvent(false); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new DispatcherScheduler(disp); sch.Schedule(delay, () => { - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); sch.Schedule(delay, () => { - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); }); @@ -184,13 +186,13 @@ public void ScheduleRelative_Cancel() { var evt = new ManualResetEvent(false); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new DispatcherScheduler(disp); sch.Schedule(TimeSpan.FromSeconds(0.1), () => { - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); var d = sch.Schedule(TimeSpan.FromSeconds(0.1), () => { @@ -205,7 +207,7 @@ public void ScheduleRelative_Cancel() sch.Schedule(TimeSpan.FromSeconds(0.2), () => { - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); }); @@ -221,7 +223,9 @@ public void SchedulePeriodic_ArgumentChecking() { var s = new DispatcherScheduler(disp); +#pragma warning disable IDE0034 // (Simplify 'default'.) Want to be explicit about overload being tested. ReactiveAssert.Throws(() => s.SchedulePeriodic(42, TimeSpan.FromSeconds(1), default(Func))); +#pragma warning restore IDE0034 ReactiveAssert.Throws(() => s.SchedulePeriodic(42, TimeSpan.FromSeconds(-1), x => x)); } } @@ -233,7 +237,7 @@ public void SchedulePeriodic() { var evt = new ManualResetEvent(false); - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var sch = new DispatcherScheduler(disp); @@ -241,7 +245,7 @@ public void SchedulePeriodic() d.Disposable = sch.SchedulePeriodic(1, TimeSpan.FromSeconds(0.1), n => { - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); if (n == 3) { @@ -249,7 +253,7 @@ public void SchedulePeriodic() sch.Schedule(TimeSpan.FromSeconds(0.2), () => { - Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); + Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/EventLoopSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/EventLoopSchedulerTest.cs index 176f2def98..9b1a85209c 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/EventLoopSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/EventLoopSchedulerTest.cs @@ -29,12 +29,14 @@ public void EventLoop_ArgumentChecking() { using var el = new EventLoopScheduler(); +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new EventLoopScheduler(null)); ReactiveAssert.Throws(() => el.Schedule(42, default)); ReactiveAssert.Throws(() => el.Schedule(42, DateTimeOffset.Now, default)); ReactiveAssert.Throws(() => el.Schedule(42, TimeSpan.Zero, default)); ReactiveAssert.Throws(() => el.SchedulePeriodic(42, TimeSpan.FromSeconds(1), default)); ReactiveAssert.Throws(() => el.SchedulePeriodic(42, TimeSpan.FromSeconds(-1), _ => _)); +#pragma warning restore CA1806 } [TestMethod] @@ -49,14 +51,12 @@ public void EventLoop_Now() [TestMethod] public void EventLoop_DisposeWithInFlightActions() { - using (var scheduler = new EventLoopScheduler()) - using (var subscription = Observable + using var scheduler = new EventLoopScheduler(); + using var subscription = Observable .Range(1, 10) .ObserveOn(scheduler) - .Subscribe(_ => Thread.Sleep(50))) - { - Thread.Sleep(50); - } + .Subscribe(_ => Thread.Sleep(50)); + Thread.Sleep(50); } [TestMethod] @@ -82,11 +82,11 @@ public void EventLoop_DifferentThread() using var el = new EventLoopScheduler(); el.Schedule(() => { - id = Thread.CurrentThread.ManagedThreadId; + id = Environment.CurrentManagedThreadId; gate.Release(); }); Assert.True(gate.WaitOne(MaxWaitTime), "Timeout!"); - Assert.NotEqual(Thread.CurrentThread.ManagedThreadId, id); + Assert.NotEqual(Environment.CurrentManagedThreadId, id); } [TestMethod] @@ -312,22 +312,18 @@ public void EventLoop_Immediate() { for (var j = 1; j <= M; j *= 10) { - using (var e = new EventLoopScheduler()) - { - using (var d = new CompositeDisposable()) - { - var cd = new CountdownEvent(j); + using var e = new EventLoopScheduler(); + using var d = new CompositeDisposable(); + var cd = new CountdownEvent(j); - for (var k = 0; k < j; k++) - { - d.Add(e.Schedule(() => cd.Signal())); - } + for (var k = 0; k < j; k++) + { + d.Add(e.Schedule(() => cd.Signal())); + } - if (!cd.Wait(10000)) - { - Assert.True(false, "j = " + j); - } - } + if (!cd.Wait(10000)) + { + Assert.True(false, "j = " + j); } } } @@ -343,22 +339,18 @@ public void EventLoop_TimeCollisions() { for (var j = 1; j <= M; j *= 10) { - using (var e = new EventLoopScheduler()) - { - using (var d = new CompositeDisposable()) - { - var cd = new CountdownEvent(j); + using var e = new EventLoopScheduler(); + using var d = new CompositeDisposable(); + var cd = new CountdownEvent(j); - for (var k = 0; k < j; k++) - { - d.Add(e.Schedule(TimeSpan.FromMilliseconds(100), () => cd.Signal())); - } + for (var k = 0; k < j; k++) + { + d.Add(e.Schedule(TimeSpan.FromMilliseconds(100), () => cd.Signal())); + } - if (!cd.Wait(10000)) - { - Assert.True(false, "j = " + j); - } - } + if (!cd.Wait(10000)) + { + Assert.True(false, "j = " + j); } } } @@ -374,22 +366,18 @@ public void EventLoop_Spread() { for (var j = 1; j <= M; j *= 10) { - using (var e = new EventLoopScheduler()) - { - using (var d = new CompositeDisposable()) - { - var cd = new CountdownEvent(j); + using var e = new EventLoopScheduler(); + using var d = new CompositeDisposable(); + var cd = new CountdownEvent(j); - for (var k = 0; k < j; k++) - { - d.Add(e.Schedule(TimeSpan.FromMilliseconds(k), () => cd.Signal())); - } + for (var k = 0; k < j; k++) + { + d.Add(e.Schedule(TimeSpan.FromMilliseconds(k), () => cd.Signal())); + } - if (!cd.Wait(10000)) - { - Assert.True(false, "j = " + j); - } - } + if (!cd.Wait(10000)) + { + Assert.True(false, "j = " + j); } } } @@ -400,25 +388,23 @@ public void EventLoop_Periodic() { var n = 0; - using (var s = new EventLoopScheduler()) - { - var e = new ManualResetEvent(false); - - var d = s.SchedulePeriodic(TimeSpan.FromMilliseconds(25), () => - { - if (Interlocked.Increment(ref n) == 10) - { - e.Set(); - } - }); + using var s = new EventLoopScheduler(); + var e = new ManualResetEvent(false); - if (!e.WaitOne(10000)) + var d = s.SchedulePeriodic(TimeSpan.FromMilliseconds(25), () => + { + if (Interlocked.Increment(ref n) == 10) { - Assert.True(false); + e.Set(); } + }); - d.Dispose(); + if (!e.WaitOne(10000)) + { + Assert.True(false); } + + d.Dispose(); } #if STRESS diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/HistoricalSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/HistoricalSchedulerTest.cs index ae23699fad..0afb3352c0 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/HistoricalSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/HistoricalSchedulerTest.cs @@ -383,7 +383,9 @@ public void Sleep2() [TestMethod] public void WithComparer_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new HistoricalScheduler(DateTimeOffset.Now, null)); +#pragma warning restore CA1806 } [TestMethod] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ImmediateSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ImmediateSchedulerTest.cs index a8c4545db1..70c55f5cee 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ImmediateSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ImmediateSchedulerTest.cs @@ -28,9 +28,9 @@ public void Immediate_Now() [TestMethod] public void Immediate_ScheduleAction() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var ran = false; - Scheduler.Immediate.Schedule(() => { Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); ran = true; }); + Scheduler.Immediate.Schedule(() => { Assert.Equal(id, Environment.CurrentManagedThreadId); ran = true; }); Assert.True(ran); } @@ -149,9 +149,9 @@ public void Immediate_ArgumentChecking_More() [TestMethod] public void Immediate_ScheduleActionDue() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var ran = false; - Scheduler.Immediate.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); ran = true; }); + Scheduler.Immediate.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.Equal(id, Environment.CurrentManagedThreadId); ran = true; }); Assert.True(ran, "ran"); } } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/NewThreadSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/NewThreadSchedulerTest.cs index f8d22fd36b..2fbd21194c 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/NewThreadSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/NewThreadSchedulerTest.cs @@ -19,6 +19,7 @@ public class NewThreadSchedulerTest [TestMethod] public void NewThread_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new NewThreadScheduler(null)); ReactiveAssert.Throws(() => NewThreadScheduler.Default.Schedule(42, default)); ReactiveAssert.Throws(() => NewThreadScheduler.Default.Schedule(42, DateTimeOffset.Now, default)); @@ -26,6 +27,7 @@ public void NewThread_ArgumentChecking() ReactiveAssert.Throws(() => NewThreadScheduler.Default.SchedulePeriodic(42, TimeSpan.FromSeconds(1), default)); ReactiveAssert.Throws(() => NewThreadScheduler.Default.ScheduleLongRunning(42, default)); ReactiveAssert.Throws(() => NewThreadScheduler.Default.SchedulePeriodic(42, TimeSpan.FromSeconds(-1), _ => _)); +#pragma warning restore CA1806 } [TestMethod] @@ -38,20 +40,20 @@ public void NewThread_Now() [TestMethod] public void NewThread_ScheduleAction() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = NewThreadScheduler.Default; var evt = new ManualResetEvent(false); - nt.Schedule(() => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(() => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } [TestMethod] public void NewThread_ScheduleActionDue() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = NewThreadScheduler.Default; var evt = new ManualResetEvent(false); - nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ScheduledItemTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ScheduledItemTest.cs index 69adf560ca..c56314d17c 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ScheduledItemTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ScheduledItemTest.cs @@ -19,12 +19,14 @@ public class ScheduledItemTest : ReactiveTest [TestMethod] public void ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new ScheduledItem(default, 42, (x, y) => Disposable.Empty, DateTimeOffset.Now)); ReactiveAssert.Throws(() => new ScheduledItem(Scheduler.Default, 42, default, DateTimeOffset.Now)); ReactiveAssert.Throws(() => new ScheduledItem(default, 42, (x, y) => Disposable.Empty, DateTimeOffset.Now, Comparer.Default)); ReactiveAssert.Throws(() => new ScheduledItem(Scheduler.Default, 42, default, DateTimeOffset.Now, Comparer.Default)); ReactiveAssert.Throws(() => new ScheduledItem(Scheduler.Default, 42, (x, y) => Disposable.Empty, DateTimeOffset.Now, default)); +#pragma warning restore CA1806 } [TestMethod] @@ -87,7 +89,6 @@ public void Equalities() var si1 = new SI2(42, 123); var si2 = new SI2(42, 123); var si3 = new SI2(42, 321); - var si4 = new SI2(43, 123); #pragma warning disable 1718 Assert.False(si1 != si1); @@ -124,12 +125,9 @@ protected override IDisposable InvokeCore() private class SI2 : ScheduledItem { - private readonly int _value; - - public SI2(int dueTime, int value) + public SI2(int dueTime, int _) : base(dueTime, Comparer.Default) { - _value = value; } protected override IDisposable InvokeCore() 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 cabde89dfa..1eb8592433 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 @@ -1366,19 +1366,21 @@ public void SchedulerAsync_ScheduleAsync_NoCancellation1() var o = s.CreateObserver(); - s.ScheduleAsync(async (_, ct) => + s.ScheduleAsync(async (scheduler, _) => { o.OnNext(42); - await _.Yield(); +#pragma warning disable CA2016 // (Forward CancellationToken.) We are testing the methods that don't take a CancellationToken here + await scheduler.Yield(); o.OnNext(43); - await _.Sleep(TimeSpan.FromTicks(10)); + await scheduler.Sleep(TimeSpan.FromTicks(10)); o.OnNext(44); - await _.Sleep(new DateTimeOffset(250, TimeSpan.Zero)); + await scheduler.Sleep(new DateTimeOffset(250, TimeSpan.Zero)); +#pragma warning restore CA2016 o.OnNext(45); }); @@ -1400,19 +1402,19 @@ public void SchedulerAsync_ScheduleAsync_NoCancellation2() var o = s.CreateObserver(); - s.ScheduleAsync(async (_, ct) => + s.ScheduleAsync(async (scheduler, ct) => { o.OnNext(42); - await _.Yield(ct); + await scheduler.Yield(ct); o.OnNext(43); - await _.Sleep(TimeSpan.FromTicks(10), ct); + await scheduler.Sleep(TimeSpan.FromTicks(10), ct); o.OnNext(44); - await _.Sleep(new DateTimeOffset(250, TimeSpan.Zero), ct); + await scheduler.Sleep(new DateTimeOffset(250, TimeSpan.Zero), ct); o.OnNext(45); }); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/StopwatchTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/StopwatchTest.cs index b80a2182ff..6159960199 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/StopwatchTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/StopwatchTest.cs @@ -8,7 +8,9 @@ namespace ReactiveTests.Tests { internal static class StopwatchTest { +#pragma warning disable IDE0060 // (Remove unused parameter.) Will be used when code reinstated public static void Run(IStopwatchProvider stopwatchProvider) +#pragma warning restore IDE0060 { /* * TODO: Temporarily disabled until we iron out all of the scheduler improvements. diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SynchronizationContextSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SynchronizationContextSchedulerTest.cs index 1e2a9f555b..a055f5e05f 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SynchronizationContextSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/SynchronizationContextSchedulerTest.cs @@ -23,8 +23,10 @@ public void SynchronizationContext_ArgumentChecking() var ms = new MySync(); var s = new SynchronizationContextScheduler(ms); +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new SynchronizationContextScheduler(null)); ReactiveAssert.Throws(() => new SynchronizationContextScheduler(null, true)); +#pragma warning restore CA1806 ReactiveAssert.Throws(() => s.Schedule(42, default)); ReactiveAssert.Throws(() => s.Schedule(42, DateTimeOffset.Now, default)); ReactiveAssert.Throws(() => s.Schedule(42, TimeSpan.Zero, default)); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/TaskPoolSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/TaskPoolSchedulerTest.cs index 33eae3fcc0..a55d8fb483 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/TaskPoolSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/TaskPoolSchedulerTest.cs @@ -18,7 +18,9 @@ public class TaskPoolSchedulerTest [TestMethod] public void TaskPool_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new TaskPoolScheduler(null)); +#pragma warning restore CA1806 ReactiveAssert.Throws(() => TaskPoolScheduler.Default.Schedule(42, default)); ReactiveAssert.Throws(() => TaskPoolScheduler.Default.Schedule(42, DateTimeOffset.Now, default)); ReactiveAssert.Throws(() => TaskPoolScheduler.Default.Schedule(42, TimeSpan.Zero, default)); @@ -36,37 +38,37 @@ public void TaskPool_Now() [TestMethod] public void TaskPool_ScheduleAction() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = TaskPoolScheduler.Default; var evt = new ManualResetEvent(false); - nt.Schedule(() => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(() => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } [TestMethod] public void TaskPool_ScheduleActionDueNow() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = TaskPoolScheduler.Default; var evt = new ManualResetEvent(false); - nt.Schedule(TimeSpan.Zero, () => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(TimeSpan.Zero, () => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } [TestMethod] public void TaskPool_ScheduleActionDue() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = TaskPoolScheduler.Default; var evt = new ManualResetEvent(false); - nt.Schedule(TimeSpan.FromMilliseconds(1), () => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(TimeSpan.FromMilliseconds(1), () => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } [TestMethod] public void TaskPool_ScheduleActionCancel() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = TaskPoolScheduler.Default; var set = false; var d = nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.True(false); set = true; }); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ThreadPoolSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ThreadPoolSchedulerTest.cs index 966706f4fc..1905462c5a 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ThreadPoolSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/ThreadPoolSchedulerTest.cs @@ -35,10 +35,10 @@ public void Get_Now() [TestMethod] public void ScheduleAction() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = ThreadPoolScheduler.Instance; var evt = new ManualResetEvent(false); - nt.Schedule(() => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(() => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } @@ -100,37 +100,37 @@ public void ProperRooting_NoGC_Periodic() [TestMethod] public void ScheduleActionDueRelative() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = ThreadPoolScheduler.Instance; var evt = new ManualResetEvent(false); - nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } [TestMethod] public void ScheduleActionDue0() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = ThreadPoolScheduler.Instance; var evt = new ManualResetEvent(false); - nt.Schedule(TimeSpan.FromTicks(0), () => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(TimeSpan.FromTicks(0), () => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } [TestMethod] public void ScheduleActionDueAbsolute() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = ThreadPoolScheduler.Instance; var evt = new ManualResetEvent(false); - nt.Schedule(DateTimeOffset.UtcNow + TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.Schedule(DateTimeOffset.UtcNow + TimeSpan.FromSeconds(0.2), () => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } [TestMethod] public void ScheduleActionCancel() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = ThreadPoolScheduler.Instance; var set = false; var d = nt.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.True(false); set = true; }); @@ -152,10 +152,10 @@ public void ScheduleLongRunning_ArgumentChecking() [TestMethod] public void ScheduleLongRunning() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var nt = ThreadPoolScheduler.Instance; var evt = new ManualResetEvent(false); - nt.ScheduleLongRunning(42, (x, cancel) => { Assert.NotEqual(id, Thread.CurrentThread.ManagedThreadId); evt.Set(); }); + nt.ScheduleLongRunning(42, (x, cancel) => { Assert.NotEqual(id, Environment.CurrentManagedThreadId); evt.Set(); }); evt.WaitOne(); } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/VirtualSchedulerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/VirtualSchedulerTest.cs index 2f97e6b565..5777842e8e 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/VirtualSchedulerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Concurrency/VirtualSchedulerTest.cs @@ -56,10 +56,10 @@ public void Virtual_Now() [TestMethod] public void Virtual_ScheduleAction() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var ran = false; var scheduler = new VirtualSchedulerTestScheduler(); - scheduler.Schedule(() => { Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); ran = true; }); + scheduler.Schedule(() => { Assert.Equal(id, Environment.CurrentManagedThreadId); ran = true; }); scheduler.Start(); Assert.True(ran); } @@ -92,12 +92,14 @@ public void Virtual_InitialAndComparer_Now() [TestMethod] public void Virtual_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new VirtualSchedulerTestScheduler("", null)); ReactiveAssert.Throws(() => new VirtualSchedulerTestScheduler().ScheduleRelative(0, 'a', null)); ReactiveAssert.Throws(() => new VirtualSchedulerTestScheduler().ScheduleAbsolute(0, "", null)); ReactiveAssert.Throws(() => new VirtualSchedulerTestScheduler().Schedule(0, default)); ReactiveAssert.Throws(() => new VirtualSchedulerTestScheduler().Schedule(0, TimeSpan.Zero, default)); ReactiveAssert.Throws(() => new VirtualSchedulerTestScheduler().Schedule(0, DateTimeOffset.UtcNow, default)); +#pragma warning restore CA1806 ReactiveAssert.Throws(() => VirtualTimeSchedulerExtensions.ScheduleAbsolute(default(VirtualSchedulerTestScheduler), "", () => { })); ReactiveAssert.Throws(() => VirtualTimeSchedulerExtensions.ScheduleAbsolute(new VirtualSchedulerTestScheduler(), "", default)); @@ -108,7 +110,9 @@ public void Virtual_ArgumentChecking() [TestMethod] public void Historical_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new HistoricalScheduler(DateTime.Now, default)); +#pragma warning restore CA1806 ReactiveAssert.Throws(() => new HistoricalScheduler().ScheduleAbsolute(42, DateTime.Now, default)); ReactiveAssert.Throws(() => new HistoricalScheduler().ScheduleRelative(42, TimeSpan.FromSeconds(1), default)); } @@ -116,10 +120,10 @@ public void Historical_ArgumentChecking() [TestMethod] public void Virtual_ScheduleActionDue() { - var id = Thread.CurrentThread.ManagedThreadId; + var id = Environment.CurrentManagedThreadId; var ran = false; var scheduler = new VirtualSchedulerTestScheduler(); - scheduler.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.Equal(id, Thread.CurrentThread.ManagedThreadId); ran = true; }); + scheduler.Schedule(TimeSpan.FromSeconds(0.2), () => { Assert.Equal(id, Environment.CurrentManagedThreadId); ran = true; }); scheduler.Start(); Assert.True(ran, "ran"); } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ConnectableObservable.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ConnectableObservable.cs index 005491963c..03020f95b8 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ConnectableObservable.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ConnectableObservable.cs @@ -10,7 +10,7 @@ namespace ReactiveTests.Tests { internal class ConnectableObservable : IConnectableObservable { - private IConnectableObservable _o; + private readonly IConnectableObservable _o; public ConnectableObservable(IObservable o, ISubject s) { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/DefaultConcurrencyAbstractionLayerTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/DefaultConcurrencyAbstractionLayerTest.cs index aba9a94e87..a15517332f 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/DefaultConcurrencyAbstractionLayerTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/DefaultConcurrencyAbstractionLayerTest.cs @@ -18,14 +18,11 @@ namespace ReactiveTests.Tests [Serializable] public class DefaultConcurrencyAbstractionLayerTest { - private AppDomain _domain; + private readonly AppDomain _domain; public DefaultConcurrencyAbstractionLayerTest() { - if (_domain == null) - { - _domain = AppDomain.CreateDomain("Default_CAL", null, new AppDomainSetup { ApplicationBase = AppDomain.CurrentDomain.BaseDirectory }); - } + _domain ??= AppDomain.CreateDomain("Default_CAL", null, new AppDomainSetup { ApplicationBase = AppDomain.CurrentDomain.BaseDirectory }); } private void Run(CrossAppDomainDelegate a) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Disposables/DisposableTests.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Disposables/DisposableTests.cs index bf070382a9..b0a166bd13 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Disposables/DisposableTests.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Disposables/DisposableTests.cs @@ -68,7 +68,7 @@ public void BooleanDisposable() [TestMethod] public void SingleAssignmentDisposable_SetNull() { - var d = new SingleAssignmentDisposable + _ = new SingleAssignmentDisposable { Disposable = null }; @@ -130,9 +130,11 @@ public void SingleAssignmentDisposable_SetMultipleTimes() [TestMethod] public void CompositeDisposable_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new CompositeDisposable(default(IDisposable[]))); ReactiveAssert.Throws(() => new CompositeDisposable(default(IEnumerable))); ReactiveAssert.Throws(() => new CompositeDisposable(-1)); +#pragma warning restore CA1806 } [TestMethod] @@ -242,14 +244,18 @@ public void CompositeDisposable_CollectionInitializer() public void CompositeDisposable_AddNull_via_params_ctor() { IDisposable d1 = null; +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new CompositeDisposable(d1)); +#pragma warning restore CA1806 } [TestMethod] public void CompositeDisposable_AddNull_via_IEnum_ctor() { IEnumerable values = new IDisposable[] { null }; +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new CompositeDisposable(values)); +#pragma warning restore CA1806 } [TestMethod] @@ -542,13 +548,17 @@ public void CancellationDisposable_TokenCtor() [TestMethod] public void ContextDisposable_CreateNullContext() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new ContextDisposable(null, Disposable.Empty)); +#pragma warning restore CA1806 } [TestMethod] public void ContextDisposable_CreateNullDisposable() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new ContextDisposable(new SynchronizationContext(), null)); +#pragma warning restore CA1806 } [TestMethod] @@ -644,7 +654,9 @@ public void SerialDisposable_Dispose() [TestMethod] public void RefCountDisposable_Ctor_Null() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new RefCountDisposable(null)); +#pragma warning restore CA1806 } [TestMethod] @@ -720,8 +732,10 @@ public void RefCountDisposable_Throw_If_Disposed() [TestMethod] public void ScheduledDisposable_Null() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new ScheduledDisposable(null, Disposable.Empty)); ReactiveAssert.Throws(() => new ScheduledDisposable(Scheduler.Immediate, null)); +#pragma warning restore CA1806 } [TestMethod] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/EventPatternSourceBaseTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/EventPatternSourceBaseTest.cs index 9bb639d65d..cbe68bcc09 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/EventPatternSourceBaseTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/EventPatternSourceBaseTest.cs @@ -18,8 +18,10 @@ public void ArgumentChecking() { var xs = Observable.Empty>(); +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new MyEventPatternSource(null, (a, x) => { })); ReactiveAssert.Throws(() => new MyEventPatternSource(xs, null)); +#pragma warning restore CA1806 var e = new MyEventPatternSource(xs, (a, x) => { }) { 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 8a7fe28ca2..0585be9815 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 @@ -16,7 +16,7 @@ public class HalfSerializerTest { private int _wip; private Exception _error; - private Consumer _consumer = new Consumer(); + private readonly Consumer _consumer = new(); [TestMethod] public void HalfSerializer_OnNext() @@ -138,7 +138,7 @@ public void HalfSerializer_OnNext_Reentrant_OnCompleted() private sealed class Consumer : ISink { - internal List Items = new List(); + internal List Items = new(); internal int Done; internal Exception Exc; @@ -168,8 +168,8 @@ private sealed class ReentrantConsumer : ISink public ReentrantConsumer(HalfSerializerTest parent, bool errorReenter) { - this._parent = parent; - this._errorReenter = errorReenter; + _parent = parent; + _errorReenter = errorReenter; } public void ForwardOnCompleted() 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 0574401c95..46364ea0ea 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs @@ -41,7 +41,7 @@ public void ScanFiles() if (error.Length != 0) { - Assert.False(true, $"Files with no license header: {count}\r\n{error.ToString()}"); + Assert.False(true, $"Files with no license header: {count}\r\n{error}"); } } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/CastTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/CastTest.cs index 63d27ca5e3..0435d5e34b 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/CastTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/CastTest.cs @@ -146,7 +146,7 @@ public void Cast_NotValid() internal class A : IEquatable { - private int _id; + private readonly int _id; public A(int id) { @@ -200,7 +200,7 @@ public D(int id) internal class E : IEquatable { - private int _id; + private readonly int _id; public E(int id) { 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 076e072b31..a254bd8c4f 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 @@ -97,7 +97,7 @@ public void CreateAsync_NullCoalescingDisposable2() Assert.True(lst.SequenceEqual(new[] { 42 })); } - private Task Producer1(IObserver results, CancellationToken token, IScheduler scheduler) + private Task Producer1(IObserver results, IScheduler scheduler, CancellationToken token) { var tcs = new TaskCompletionSource(); @@ -122,7 +122,7 @@ public void CreateAsync_Never() var scheduler = new TestScheduler(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer1(observer, token, scheduler)) + Observable.Create((observer, token) => Producer1(observer, scheduler, token)) ); res.Messages.AssertEqual( @@ -137,7 +137,7 @@ public void CreateAsync_Never() }); } - private Task Producer2(IObserver results, CancellationToken token, IScheduler scheduler) + private Task Producer2(IObserver results, IScheduler scheduler, CancellationToken token) { var tcs = new TaskCompletionSource(); @@ -166,7 +166,7 @@ public void CreateAsync_Completed1() var scheduler = new TestScheduler(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer2(observer, token, scheduler)) + Observable.Create((observer, token) => Producer2(observer, scheduler, token)) ); res.Messages.AssertEqual( @@ -179,7 +179,7 @@ public void CreateAsync_Completed1() }); } - private Task Producer3(IObserver results, CancellationToken token, IScheduler scheduler) + private Task Producer3(IObserver results, IScheduler scheduler, CancellationToken token) { var tcs = new TaskCompletionSource(); @@ -208,7 +208,7 @@ public void CreateAsync_Completed2() var scheduler = new TestScheduler(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer3(observer, token, scheduler)) + Observable.Create((observer, token) => Producer3(observer, scheduler, token)) ); res.Messages.AssertEqual( @@ -221,7 +221,7 @@ public void CreateAsync_Completed2() }); } - private Task Producer4(IObserver results, CancellationToken token, IScheduler scheduler, Exception exception) + private Task Producer4(IObserver results, IScheduler scheduler, Exception exception, CancellationToken token) { var tcs = new TaskCompletionSource(); @@ -252,7 +252,7 @@ public void CreateAsync_Error1() var exception = new Exception(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer4(observer, token, scheduler, exception)) + Observable.Create((observer, token) => Producer4(observer, scheduler, exception, token)) ); res.Messages.AssertEqual( @@ -265,7 +265,7 @@ public void CreateAsync_Error1() }); } - private Task Producer5(IObserver results, CancellationToken token, IScheduler scheduler, Exception exception) + private Task Producer5(IObserver results, IScheduler scheduler, Exception exception, CancellationToken token) { var tcs = new TaskCompletionSource(); @@ -296,7 +296,7 @@ public void CreateAsync_Error2() var exception = new Exception(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer5(observer, token, scheduler, exception)) + Observable.Create((observer, token) => Producer5(observer, scheduler, exception, token)) ); res.Messages.AssertEqual( @@ -309,7 +309,9 @@ public void CreateAsync_Error2() }); } - private Task Producer6(IObserver results, CancellationToken token, Exception exception) +#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; } @@ -324,7 +326,7 @@ public void CreateAsync_Error3() var exception = new InvalidOperationException(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer6(observer, token, exception)) + Observable.Create((observer, token) => Producer6(observer, exception, token)) ); res.Messages.AssertEqual( @@ -333,7 +335,7 @@ public void CreateAsync_Error3() }); } - private Task Producer7(IObserver results, CancellationToken token, IScheduler scheduler) + private Task Producer7(IObserver results, IScheduler scheduler, CancellationToken token) { var tcs = new TaskCompletionSource(); @@ -362,7 +364,7 @@ public void CreateAsync_Cancel1() var scheduler = new TestScheduler(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer7(observer, token, scheduler)), + Observable.Create((observer, token) => Producer7(observer, scheduler, token)), 650 ); @@ -375,7 +377,7 @@ public void CreateAsync_Cancel1() }); } - private Task Producer8(IObserver results, CancellationToken token, IScheduler scheduler) + private Task Producer8(IObserver results, IScheduler scheduler, CancellationToken token) { var tcs = new TaskCompletionSource(); @@ -404,7 +406,7 @@ public void CreateAsync_Cancel2() var scheduler = new TestScheduler(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer8(observer, token, scheduler)), + Observable.Create((observer, token) => Producer8(observer, scheduler, token)), 650 ); @@ -417,7 +419,7 @@ public void CreateAsync_Cancel2() }); } - private Task Producer9(IObserver results, CancellationToken token, IScheduler scheduler) + private Task Producer9(IObserver results, IScheduler scheduler, CancellationToken token) { var tcs = new TaskCompletionSource(); @@ -446,7 +448,7 @@ public void CreateAsync_Cancel3() var scheduler = new TestScheduler(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer9(observer, token, scheduler)), + Observable.Create((observer, token) => Producer9(observer, scheduler, token)), 750 ); @@ -460,7 +462,7 @@ public void CreateAsync_Cancel3() }); } - private Task Producer10(IObserver results, CancellationToken token, IScheduler scheduler) + private Task Producer10(IObserver results, IScheduler scheduler, CancellationToken token) { var tcs = new TaskCompletionSource(); @@ -489,7 +491,7 @@ public void CreateAsync_Cancel4() var scheduler = new TestScheduler(); var res = scheduler.Start(() => - Observable.Create((observer, token) => Producer10(observer, token, scheduler)) + Observable.Create((observer, token) => Producer10(observer, scheduler, token)) ); res.Messages.Take(4).AssertEqual( @@ -570,7 +572,8 @@ public void CreateAsync_Task_Token() observer.OnNext(42); } - }); + }, + CancellationToken.None); }); var lst = new List(); @@ -753,7 +756,9 @@ public void CreateWithTaskAction_NoPrematureTermination() o.OnNext(x); }); +#pragma warning disable IDE0039 // (Use local function.) We are testing for a returned Action, and want to be explicit about that. Action a = () => d.Dispose(); +#pragma warning restore IDE0039 return a; }); 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 02e408025a..13b0aa30a9 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 @@ -1717,29 +1717,23 @@ public void Delay_ErrorHandling1() private class ImpulseScheduler : IScheduler { - public DateTimeOffset Now - { - get { return DateTimeOffset.UtcNow; } - } + public DateTimeOffset Now => DateTimeOffset.UtcNow; public IDisposable Schedule(TState state, Func action) { throw new NotImplementedException(); } - private ManualResetEvent _event = new ManualResetEvent(false); - private ManualResetEvent _done = new ManualResetEvent(false); - - public ManualResetEvent Event { get { return _event; } } - public ManualResetEvent Done { get { return _done; } } + public ManualResetEvent Event { get; } = new(false); + public ManualResetEvent Done { get; } = new(false); public IDisposable Schedule(TState state, TimeSpan dueTime, Func action) { Scheduler.Default.Schedule(() => { - _event.WaitOne(); + Event.WaitOne(); action(this, state); - _done.Set(); + Done.Set(); }); return Disposable.Empty; @@ -1776,8 +1770,8 @@ public void Delay_LongRunning_CancelEarly() private class MyLongRunning1 : LocalScheduler, ISchedulerLongRunning { - private ManualResetEvent _start; - private ManualResetEvent _stop; + private readonly ManualResetEvent _start; + private readonly ManualResetEvent _stop; public MyLongRunning1(ManualResetEvent start, ManualResetEvent stop) { @@ -1833,8 +1827,8 @@ public void Delay_Selector_Immediate() private class MyLongRunning2 : LocalScheduler, ISchedulerLongRunning { - private ManualResetEvent _start; - private ManualResetEvent _stop; + private readonly ManualResetEvent _start; + private readonly ManualResetEvent _stop; public MyLongRunning2(ManualResetEvent start, ManualResetEvent stop) { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/DoWhileTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/DoWhileTest.cs index 5e5d7d45b8..ce2495d381 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/DoWhileTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/DoWhileTest.cs @@ -186,7 +186,7 @@ public void DoWhile_SometimesThrows() var ex = new Exception(); - var results = scheduler.Start(() => Observable.DoWhile(xs, () => ++n < 3 ? true : Throw(ex))); + var results = scheduler.Start(() => Observable.DoWhile(xs, () => ++n < 3 || Throw(ex))); results.Messages.AssertEqual( OnNext(250, 1), diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FirstOrDefaultTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FirstOrDefaultTest.cs index af3987ff02..3dceb500b1 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FirstOrDefaultTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FirstOrDefaultTest.cs @@ -99,7 +99,7 @@ public void FirstOrDefault_NoDoubleSet() private class O : IObservable { - private readonly ManualResetEvent _event = new ManualResetEvent(false); + private readonly ManualResetEvent _event = new(false); private IObserver _observer; public void Wait() 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 403d8cefb5..4e2a3fa11e 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().SequenceEqual(new[] { 1, 2 }); + ObservableEx.ForkJoin(Observable.Return(1), Observable.Return(2)).First().AssertEqual(new[] { 1, 2 }); } [TestMethod] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromAsyncPatternTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromAsyncPatternTest.cs index ce5d6edae2..95e7075b89 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromAsyncPatternTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromAsyncPatternTest.cs @@ -18,15 +18,6 @@ namespace ReactiveTests.Tests [TestClass] public class FromAsyncPatternTest : ReactiveTest { - private readonly Task _doneTask; - - public FromAsyncPatternTest() - { - var tcs = new TaskCompletionSource(); - tcs.SetResult(42); - _doneTask = tcs.Task; - } - [TestMethod] public void FromAsyncPattern_ArgumentChecking() { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromAsyncTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromAsyncTest.cs index 0ba7835868..a0286f96fa 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromAsyncTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromAsyncTest.cs @@ -272,7 +272,7 @@ public void FromAsync_Func_Scheduler1() xs.Subscribe(res => { x = res; - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -281,7 +281,7 @@ public void FromAsync_Func_Scheduler1() e.WaitOne(); Assert.Equal(42, x); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } [TestMethod] @@ -297,7 +297,7 @@ public void FromAsync_Func_Scheduler2() xs.Subscribe(res => { x = res; - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -306,7 +306,7 @@ public void FromAsync_Func_Scheduler2() e.WaitOne(); Assert.Equal(42, x); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } #endif @@ -376,7 +376,7 @@ public void FromAsync_ActionWithCancel_Success() var xs = Observable.FromAsync(ct => { i++; - return Task.Factory.StartNew(() => { }); + return Task.Factory.StartNew(() => { }, CancellationToken.None); // Not forwarding ct because we want this task always to run and complete. }); Assert.Equal(Unit.Default, xs.Single()); @@ -405,7 +405,7 @@ public void FromAsync_ActionWithCancel_Throw_Asynchronous() var ex = new Exception(); var xs = Observable.FromAsync(ct => - Task.Factory.StartNew(() => { throw ex; }) + Task.Factory.StartNew(() => { throw ex; }, CancellationToken.None) // Not forwarding ct because we always want this task to run and fail ); ReactiveAssert.Throws(ex, () => xs.Single()); @@ -433,7 +433,8 @@ public void FromAsync_ActionWithCancel_Cancel() { f.Set(); } - }) + }, + CancellationToken.None) // Not forwarding ct because we are testing the case where the task is already running by the time cancellation is detected ); var d = xs.Subscribe(_ => { }); @@ -547,7 +548,7 @@ public void FromAsync_Action_Scheduler1() var xs = Observable.FromAsync(() => (Task)tcs.Task, Scheduler.Immediate); xs.Subscribe(res => { - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -555,7 +556,7 @@ public void FromAsync_Action_Scheduler1() e.WaitOne(); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } [TestMethod] @@ -569,7 +570,7 @@ public void FromAsync_Action_Scheduler2() var xs = Observable.FromAsync(ct => (Task)tcs.Task, Scheduler.Immediate); xs.Subscribe(res => { - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -577,7 +578,7 @@ public void FromAsync_Action_Scheduler2() e.WaitOne(); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } #endif diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromEventPatternTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromEventPatternTest.cs index 9ba64a7c86..3256582c3b 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromEventPatternTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/FromEventPatternTest.cs @@ -392,13 +392,13 @@ public void FromEventPattern_Reflection_Instance_E1() scheduler.ScheduleAbsolute(1050, () => fe.M1(6)); var results = scheduler.Start(() => - Observable.FromEventPattern(fe, "E1").Select(evt => new { Sender = evt.Sender, EventArgs = (object)evt.EventArgs }) + Observable.FromEventPattern(fe, "E1").Select(evt => (evt.Sender, EventArgs: (object)evt.EventArgs)) ); results.Messages.AssertEqual( - OnNext(250, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 3 } }), - OnNext(350, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 4 } }), - OnNext(450, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 5 } }) + OnNext(250, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 3 })), + OnNext(350, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 4 })), + OnNext(450, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 5 })) ); } @@ -417,13 +417,13 @@ public void FromEventPattern_Reflection_Instance_E2() scheduler.ScheduleAbsolute(1050, () => fe.M2(6)); var results = scheduler.Start(() => - Observable.FromEventPattern(fe, "E2").Select(evt => new { Sender = evt.Sender, EventArgs = (object)evt.EventArgs }) + Observable.FromEventPattern(fe, "E2").Select(evt => (evt.Sender, EventArgs: (object)evt.EventArgs)) ); results.Messages.AssertEqual( - OnNext(250, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 3 } }), - OnNext(350, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 4 } }), - OnNext(450, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 5 } }) + OnNext(250, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 3 })), + OnNext(350, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 4 })), + OnNext(450, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 5 })) ); } @@ -442,13 +442,13 @@ public void FromEventPattern_Reflection_Instance_E2_WithSender() scheduler.ScheduleAbsolute(1050, () => fe.M2(6)); var results = scheduler.Start(() => - Observable.FromEventPattern(fe, "E2").Select(evt => new { Sender = evt.Sender, EventArgs = (object)evt.EventArgs }) + Observable.FromEventPattern(fe, "E2").Select(evt => (evt.Sender, EventArgs: (object)evt.EventArgs)) ); results.Messages.AssertEqual( - OnNext(250, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 3 } }), - OnNext(350, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 4 } }), - OnNext(450, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 5 } }) + OnNext(250, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 3 })), + OnNext(350, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 4 })), + OnNext(450, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 5 })) ); } @@ -467,13 +467,13 @@ public void FromEventPattern_Reflection_Instance_E3() scheduler.ScheduleAbsolute(1050, () => fe.M3(6)); var results = scheduler.Start(() => - Observable.FromEventPattern(fe, "E3").Select(evt => new { Sender = evt.Sender, EventArgs = (object)evt.EventArgs }) + Observable.FromEventPattern(fe, "E3").Select(evt => (evt.Sender, EventArgs: (object)evt.EventArgs)) ); results.Messages.AssertEqual( - OnNext(250, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 3 } }), - OnNext(350, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 4 } }), - OnNext(450, new { Sender = (object)fe, EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 5 } }) + OnNext(250, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 3 })), + OnNext(350, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 4 })), + OnNext(450, (Sender: (object)fe, EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 5 })) ); } @@ -552,13 +552,13 @@ public void FromEventPattern_Reflection_Static_E6() scheduler.ScheduleAbsolute(1050, () => FromEventPattern.M6(6)); var results = scheduler.Start(() => - Observable.FromEventPattern(typeof(FromEventPattern), "E6").Select(evt => new { Sender = evt.Sender, EventArgs = (object)evt.EventArgs }) + Observable.FromEventPattern(typeof(FromEventPattern), "E6").Select(evt => (evt.Sender, EventArgs: (object)evt.EventArgs)) ); results.Messages.AssertEqual( - OnNext(250, new { Sender = default(object), EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 3 } }), - OnNext(350, new { Sender = default(object), EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 4 } }), - OnNext(450, new { Sender = default(object), EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 5 } }) + OnNext(250, (Sender: default(object), EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 3 })), + OnNext(350, (Sender: default(object), EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 4 })), + OnNext(450, (Sender: default(object), EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 5 })) ); } @@ -575,13 +575,13 @@ public void FromEventPattern_Reflection_Static_E6_WithSender() scheduler.ScheduleAbsolute(1050, () => FromEventPattern.M6(6)); var results = scheduler.Start(() => - Observable.FromEventPattern(typeof(FromEventPattern), "E6").Select(evt => new { Sender = evt.Sender, EventArgs = (object)evt.EventArgs }) + Observable.FromEventPattern(typeof(FromEventPattern), "E6").Select(evt => (evt.Sender, EventArgs: (object)evt.EventArgs)) ); results.Messages.AssertEqual( - OnNext(250, new { Sender = default(object), EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 3 } }), - OnNext(350, new { Sender = default(object), EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 4 } }), - OnNext(450, new { Sender = default(object), EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 5 } }) + OnNext(250, (Sender: default(object), EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 3 })), + OnNext(350, (Sender: default(object), EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 4 })), + OnNext(450, (Sender: default(object), EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 5 })) ); } @@ -598,13 +598,13 @@ public void FromEventPattern_Reflection_Static_NonGeneric_E6() scheduler.ScheduleAbsolute(1050, () => FromEventPattern.M6(6)); var results = scheduler.Start(() => - Observable.FromEventPattern(typeof(FromEventPattern), "E6").Select(evt => new { Sender = evt.Sender, EventArgs = evt.EventArgs }) + Observable.FromEventPattern(typeof(FromEventPattern), "E6").Select(evt => (evt.Sender, evt.EventArgs)) ); results.Messages.AssertEqual( - OnNext(250, new { Sender = default(object), EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 3 } }), - OnNext(350, new { Sender = default(object), EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 4 } }), - OnNext(450, new { Sender = default(object), EventArgs = (object)new FromEventPattern.TestEventArgs { Id = 5 } }) + OnNext(250, (Sender: default(object), EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 3 })), + OnNext(350, (Sender: default(object), EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 4 })), + OnNext(450, (Sender: default(object), EventArgs: (object)new FromEventPattern.TestEventArgs { Id = 5 })) ); } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/GroupByTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/GroupByTest.cs index 6754d93f85..ac98a4ea92 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/GroupByTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/GroupByTest.cs @@ -3483,18 +3483,18 @@ public void GroupBy_Capacity_NullKeys_Error() internal class GroupByComparer : IEqualityComparer { - private TestScheduler _scheduler; + private readonly TestScheduler _scheduler; private readonly int _equalsThrowsAfter; private readonly ushort _getHashCodeThrowsAfter; - public Exception HashCodeException = new Exception(); - public Exception EqualsException = new Exception(); + public Exception HashCodeException = new(); + public Exception EqualsException = new(); public GroupByComparer(TestScheduler scheduler, ushort equalsThrowsAfter, ushort getHashCodeThrowsAfter) { - this._scheduler = scheduler; - this._equalsThrowsAfter = equalsThrowsAfter; - this._getHashCodeThrowsAfter = getHashCodeThrowsAfter; + _scheduler = scheduler; + _equalsThrowsAfter = equalsThrowsAfter; + _getHashCodeThrowsAfter = getHashCodeThrowsAfter; } public GroupByComparer(TestScheduler scheduler) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MaxTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MaxTest.cs index 280fbcad5a..0dbec43fa9 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MaxTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MaxTest.cs @@ -2393,7 +2393,7 @@ public void MaxOfT_Selector_Regular_Comparer() internal class ReverseComparer : IComparer { - private IComparer _comparer; + private readonly IComparer _comparer; public ReverseComparer(IComparer comparer) { 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 8386e17b94..da906a92ae 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 @@ -1835,7 +1835,7 @@ public void Merge_TaskWithCompletionSource_Canceled_Async() done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] @@ -1859,7 +1859,7 @@ public void Merge_TaskWithCompletionSource_Canceled_Sync() done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MinByTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MinByTest.cs index 423b9bca2e..e17d9a626e 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MinByTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MinByTest.cs @@ -373,7 +373,7 @@ public void MinBy_ComparerThrows() private class ReverseComparer : IComparer { - private IComparer _comparer; + private readonly IComparer _comparer; public ReverseComparer(IComparer comparer) { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ObserveOnTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ObserveOnTest.cs index 52bb0691ae..edb05142e0 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ObserveOnTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ObserveOnTest.cs @@ -37,20 +37,24 @@ public void ObserveOn_ArgumentChecking() var someObservable = Observable.Empty(); #if HAS_WINFORMS +#pragma warning disable IDE0034 // (Simplify 'default'.) Want to be explicit about overloads being tested. ReactiveAssert.Throws(() => Observable.ObserveOn(default(IObservable), new ControlScheduler(new Label()))); ReactiveAssert.Throws(() => Observable.ObserveOn(someObservable, default(ControlScheduler))); ReactiveAssert.Throws(() => ControlObservable.ObserveOn(default(IObservable), new Label())); ReactiveAssert.Throws(() => ControlObservable.ObserveOn(someObservable, default(Label))); +#pragma warning restore IDE0034 #endif #if HAS_DISPATCHER +#pragma warning disable IDE0034 // (Simplify 'default'.) Want to be explicit about overloads being tested. ReactiveAssert.Throws(() => Observable.ObserveOn(default(IObservable), new DispatcherScheduler(Dispatcher.CurrentDispatcher))); ReactiveAssert.Throws(() => Observable.ObserveOn(someObservable, default(DispatcherScheduler))); ReactiveAssert.Throws(() => DispatcherObservable.ObserveOn(default(IObservable), Dispatcher.CurrentDispatcher)); ReactiveAssert.Throws(() => DispatcherObservable.ObserveOn(someObservable, default(Dispatcher))); ReactiveAssert.Throws(() => DispatcherObservable.ObserveOnDispatcher(default(IObservable))); +#pragma warning restore IDE0034 #endif ReactiveAssert.Throws(() => Observable.ObserveOn(default, new SynchronizationContext())); ReactiveAssert.Throws(() => Observable.ObserveOn(someObservable, default(SynchronizationContext))); @@ -206,7 +210,7 @@ public void ObserveOn_Error() [TestClass] public class ObserveOnReactiveTest : ReactiveTest { - private static TimeSpan MaxWaitTime = TimeSpan.FromSeconds(10); + private static readonly TimeSpan MaxWaitTime = TimeSpan.FromSeconds(10); [TestMethod] public void ObserveOn_Scheduler_ArgumentChecking() @@ -380,7 +384,7 @@ public void ObserveOn_Scheduler_OnNextThrows() private class MyScheduler : IScheduler { internal Exception _exception; - private ManualResetEvent _evt; + private readonly ManualResetEvent _evt; public MyScheduler(ManualResetEvent e) { @@ -658,7 +662,7 @@ public void ObserveOn_LongRunning_SameThread() Observable.Range(1, N) .ObserveOn(scheduler) .Subscribe( - v => threads.Add(Thread.CurrentThread.ManagedThreadId), + v => threads.Add(Environment.CurrentManagedThreadId), e => cde.Signal(), () => cde.Signal() ); @@ -682,7 +686,7 @@ public void ObserveOn_LongRunning_DisableOptimizations() Observable.Range(1, N) .ObserveOn(scheduler) .Subscribe( - v => threads.Add(Thread.CurrentThread.ManagedThreadId), + v => threads.Add(Environment.CurrentManagedThreadId), e => cde.Signal(), () => cde.Signal() ); @@ -695,7 +699,7 @@ public void ObserveOn_LongRunning_DisableOptimizations() internal class MyCtx : SynchronizationContext { - private IScheduler _scheduler; + private readonly IScheduler _scheduler; public MyCtx(IScheduler scheduler) { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RefCountTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RefCountTest.cs index 88b3991654..4b3ec9ad4a 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RefCountTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/RefCountTest.cs @@ -457,7 +457,7 @@ public void RefCount_source_already_completed_synchronously() [TestMethod] public void RefCount_minObservers_not_connected_Eager() { - int connected = 0; + var connected = 0; var source = Observable.Defer(() => { connected++; @@ -507,7 +507,7 @@ public void RefCount_minObservers_connected_Eager() [TestMethod] public void RefCount_minObservers_not_connected_Lazy() { - int connected = 0; + var connected = 0; var source = Observable.Defer(() => { connected++; 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 e35b2b4a3a..f65c9c2fc2 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 @@ -2066,7 +2066,7 @@ public void SelectMany_Enumerable_SelectorThrows_ResultSelector() private class CurrentThrowsEnumerable : IEnumerable { - private IEnumerable _e; + private readonly IEnumerable _e; private readonly Exception _ex; public CurrentThrowsEnumerable(IEnumerable e, Exception ex) @@ -2087,7 +2087,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() private class Enumerator : IEnumerator { - private IEnumerator _e; + private readonly IEnumerator _e; private readonly Exception _ex; public Enumerator(IEnumerator e, Exception ex) @@ -2181,7 +2181,7 @@ public void SelectMany_Enumerable_CurrentThrows_ResultSelector() private class MoveNextThrowsEnumerable : IEnumerable { - private IEnumerable _e; + private readonly IEnumerable _e; private readonly Exception _ex; public MoveNextThrowsEnumerable(IEnumerable e, Exception ex) @@ -2202,7 +2202,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() private class Enumerator : IEnumerator { - private IEnumerator _e; + private readonly IEnumerator _e; private readonly Exception _ex; public Enumerator(IEnumerator e, Exception ex) @@ -5289,7 +5289,7 @@ public void SelectMany_TaskWithCompletionSource_Simple_Canceled_Async() done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] @@ -5313,7 +5313,7 @@ public void SelectMany_TaskWithCompletionSource_Simple_Canceled_Sync() done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] @@ -5682,7 +5682,7 @@ public void SelectMany_TaskWithCompletionSource_WithResultSelector_Canceled_Asyn done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] @@ -5706,7 +5706,7 @@ public void SelectMany_TaskWithCompletionSource_WithResultSelector_Canceled_Sync done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] @@ -6221,7 +6221,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_Simple_Canceled_Async() done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] @@ -6245,7 +6245,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_Simple_Canceled_Sync() done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] @@ -6614,7 +6614,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_WithResultSelector_Canc done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] @@ -6638,7 +6638,7 @@ public void SelectManyWithIndex_TaskWithCompletionSource_WithResultSelector_Canc done.WaitOne(); lst.AssertEqual(new int[0]); - Assert.True(err is TaskCanceledException && ((TaskCanceledException)err).Task == tcss[1].Task); + Assert.True(err is TaskCanceledException tcException && tcException.Task == tcss[1].Task); } [TestMethod] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/StartAsyncTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/StartAsyncTest.cs index 66e80e3120..4dcaef2561 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/StartAsyncTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/StartAsyncTest.cs @@ -288,7 +288,7 @@ public void StartAsync_Func_Scheduler1() xs.Subscribe(res => { x = res; - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -297,7 +297,7 @@ public void StartAsync_Func_Scheduler1() e.WaitOne(); Assert.Equal(42, x); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } [TestMethod] @@ -313,7 +313,7 @@ public void StartAsync_Func_Scheduler2() xs.Subscribe(res => { x = res; - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -322,7 +322,7 @@ public void StartAsync_Func_Scheduler2() e.WaitOne(); Assert.Equal(42, x); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } #endif @@ -393,7 +393,7 @@ public void StartAsync_ActionWithCancel_Success() var xs = Observable.StartAsync(ct => { i++; - return Task.Factory.StartNew(() => { }); + return Task.Factory.StartNew(() => { }, CancellationToken.None); // Not forwarding ct because we always want this task to run to completion in this test. }); Assert.Equal(Unit.Default, xs.Single()); @@ -422,7 +422,7 @@ public void StartAsync_ActionWithCancel_Throw_Asynchronous() var ex = new Exception(); var xs = Observable.StartAsync(ct => - Task.Factory.StartNew(() => { throw ex; }) + Task.Factory.StartNew(() => { throw ex; }, CancellationToken.None) // Not forwarding ct because we always want this task to run and then fail in this test ); ReactiveAssert.Throws(ex, () => xs.Single()); @@ -454,7 +454,8 @@ public void StartAsync_ActionWithCancel_Cancel() { f.Set(); } - }) + }, + CancellationToken.None) // Not forwarding ct because we are testing the case where the task is already running by the time cancellation is detected ); e.WaitOne(); @@ -572,7 +573,7 @@ public void StartAsync_Action_Scheduler1() var xs = Observable.StartAsync(() => (Task)tcs.Task, Scheduler.Immediate); xs.Subscribe(res => { - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -580,7 +581,7 @@ public void StartAsync_Action_Scheduler1() e.WaitOne(); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } [TestMethod] @@ -594,7 +595,7 @@ public void StartAsync_Action_Scheduler2() var xs = Observable.StartAsync(ct => (Task)tcs.Task, Scheduler.Immediate); xs.Subscribe(res => { - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -602,7 +603,7 @@ public void StartAsync_Action_Scheduler2() e.WaitOne(); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } #endif diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/SubscribeOnTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/SubscribeOnTest.cs index 7761320ad3..4c1d61984d 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/SubscribeOnTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/SubscribeOnTest.cs @@ -37,19 +37,23 @@ public void SubscribeOn_ArgumentChecking() var someObservable = Observable.Empty(); #if HAS_WINFORMS +#pragma warning disable IDE0034 // (Simplify 'default'.) Want to be explicit about overload being tested. ReactiveAssert.Throws(() => Observable.SubscribeOn(default(IObservable), new ControlScheduler(new Label()))); ReactiveAssert.Throws(() => Observable.SubscribeOn(someObservable, default(ControlScheduler))); ReactiveAssert.Throws(() => ControlObservable.SubscribeOn(default(IObservable), new Label())); ReactiveAssert.Throws(() => ControlObservable.SubscribeOn(someObservable, default(Label))); +#pragma warning restore IDE0034 #endif #if HAS_DISPATCHER +#pragma warning disable IDE0034 // (Simplify 'default'.) Want to be explicit about overload being tested. ReactiveAssert.Throws(() => Observable.SubscribeOn(default(IObservable), new DispatcherScheduler(Dispatcher.CurrentDispatcher))); ReactiveAssert.Throws(() => Observable.SubscribeOn(someObservable, default(DispatcherScheduler))); ReactiveAssert.Throws(() => DispatcherObservable.SubscribeOn(default(IObservable), Dispatcher.CurrentDispatcher)); ReactiveAssert.Throws(() => DispatcherObservable.SubscribeOn(someObservable, default(Dispatcher))); ReactiveAssert.Throws(() => DispatcherObservable.SubscribeOnDispatcher(default(IObservable))); +#pragma warning restore IDE0034 #endif ReactiveAssert.Throws(() => Observable.SubscribeOn(default, new SynchronizationContext())); ReactiveAssert.Throws(() => Observable.SubscribeOn(someObservable, default(SynchronizationContext))); @@ -59,7 +63,7 @@ public void SubscribeOn_ArgumentChecking() [TestMethod] public void SubscribeOn_Control() { - bool okay = true; + var okay = true; using (WinFormsTestUtils.RunTest(out var lbl)) { @@ -93,7 +97,7 @@ public void SubscribeOn_Control() [TestMethod] public void SubscribeOn_ControlScheduler() { - bool okay = true; + var okay = true; using (WinFormsTestUtils.RunTest(out var lbl)) { @@ -136,7 +140,7 @@ public void SubscribeOn_Dispatcher() RunAsync(evt => { var s = new AsyncSubject(); - bool okay = true; + var okay = true; var d = Observable.Create(obs => { okay &= (SynchronizationContext.Current is System.Windows.Threading.DispatcherSynchronizationContext); @@ -167,7 +171,7 @@ public void SubscribeOn_DispatcherScheduler() RunAsync(evt => { var s = new AsyncSubject(); - bool okay = true; + var okay = true; var d = Observable.Create(obs => { okay &= (SynchronizationContext.Current is System.Windows.Threading.DispatcherSynchronizationContext); @@ -198,7 +202,7 @@ public void SubscribeOn_CurrentDispatcher() RunAsync(evt => { var s = new AsyncSubject(); - bool okay = true; + var okay = true; dispatcher.BeginInvoke(new Action(() => { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ThrottleTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ThrottleTest.cs index 3ad3e90607..598835083e 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ThrottleTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ThrottleTest.cs @@ -33,17 +33,6 @@ public void Throttle_ArgumentChecking() ReactiveAssert.Throws(() => Observable.Throttle(someObservable, TimeSpan.FromSeconds(-1), scheduler)); } - private IEnumerable>> Generate(S seed, Func condition, Func iterate, Func>> selector, Func>> final) - { - S s; - for (s = seed; condition(s); s = iterate(s)) - { - yield return selector(s); - } - - yield return final(s); - } - [TestMethod] public void Throttle_TimeSpan_AllPass() { 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 5b91fc6410..202893b96b 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 @@ -861,7 +861,7 @@ public override int GetHashCode() public override bool Equals(object obj) { - if (!(obj is TimerRun other)) + if (obj is not TimerRun other) { return false; } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/WhileTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/WhileTest.cs index f864541e92..a2c5f6cfea 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/WhileTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/WhileTest.cs @@ -181,7 +181,7 @@ public void While_SometimesThrows() var ex = new Exception(); - var results = scheduler.Start(() => Observable.While(() => ++n < 3 ? true : Throw(ex), xs)); + var results = scheduler.Start(() => Observable.While(() => ++n < 3 || Throw(ex), xs)); results.Messages.AssertEqual( OnNext(250, 1), diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ZipTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ZipTest.cs index 25134b3f6b..e6e701216e 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ZipTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ZipTest.cs @@ -4098,9 +4098,9 @@ public void ZipWithEnumerable_NoAsyncDisposeOnCurrent() private class MoveNextDisposeDetectEnumerable : IEnumerable, IEnumerator { - readonly IDisposable _disposable; + private readonly IDisposable _disposable; - readonly bool _disposeOnMoveNext; + private readonly bool _disposeOnMoveNext; private bool _moveNextRunning; @@ -4575,7 +4575,7 @@ public void Zip2WithImmediateReturn() [TestMethod] public void Zip3WithImmediateReturn() { - int result = 0; + var result = 0; Observable.Zip( Observable.Return(1), diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableExTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableExTest.cs index a8ad5729d7..26771de6d8 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableExTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/QbservableExTest.cs @@ -15,8 +15,8 @@ namespace ReactiveTests.Tests public class QbservableExTest : ReactiveTest { private readonly IQbservable _qbNull = null; - private IQbservable _qbMy = new MyQbservable(); - private IQbservableProvider _qbp = new MyQbservableProvider(); + private readonly IQbservable _qbMy = new MyQbservable(); + private readonly IQbservableProvider _qbp = new MyQbservableProvider(); [TestMethod] public void ForkJoin_ArgumentNullChecks() 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 dae42fa71d..f65a8a32f6 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 @@ -27,8 +27,8 @@ namespace ReactiveTests.Tests public class QbservableTest { private readonly IQbservable _qbNull = null; - private IQbservable _qbMy = new MyQbservable(); - private IQbservableProvider _qbp = new MyQbservableProvider(); + private readonly IQbservable _qbMy = new MyQbservable(); + private readonly IQbservableProvider _qbp = new MyQbservableProvider(); [TestMethod] public void LocalQueryMethodImplementationTypeAttribute() @@ -1749,7 +1749,9 @@ public void Qbservable_TwoProviders_Amb() xs.Concat(ys.Provider.Amb(xs)).ForEach(_ => { }); } +#pragma warning disable IDE0060 // (Remove unused parameter.) Required for type inference private void Ignore(IQbservable q) +#pragma warning restore IDE0060 { } @@ -1773,7 +1775,7 @@ join q in qbgs on o.Key equals q.Key select new { Name = o.Key, Observable = o.ToList(), Qbservable = q.ToList() }) .ToList(); - bool filterReturn(Type t) + static bool filterReturn(Type t) { if (t.GetTypeInfo().IsGenericType) { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Subjects/ReplaySubjectTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Subjects/ReplaySubjectTest.cs index 66aafc66cf..2684199ecf 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Subjects/ReplaySubjectTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Subjects/ReplaySubjectTest.cs @@ -42,6 +42,7 @@ public void OnError_ArgumentChecking() [TestMethod] public void Constructor_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We are just testing whether or not the constructor throws. ReactiveAssert.Throws(() => new ReplaySubject(-1)); ReactiveAssert.Throws(() => new ReplaySubject(-1, DummyScheduler.Instance)); ReactiveAssert.Throws(() => new ReplaySubject(-1, TimeSpan.Zero)); @@ -64,6 +65,7 @@ public void Constructor_ArgumentChecking() new ReplaySubject(0, DummyScheduler.Instance); new ReplaySubject(TimeSpan.Zero, DummyScheduler.Instance); new ReplaySubject(0, TimeSpan.Zero, DummyScheduler.Instance); +#pragma warning restore CA1806 } [TestMethod] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ListObservableTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ListObservableTest.cs index 322d5c41b1..8ed6d15d3a 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ListObservableTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/ListObservableTest.cs @@ -21,7 +21,9 @@ public partial class ListObservableTest : ReactiveTest [TestMethod] public void Ctor_ArgumentChecking() { +#pragma warning disable CA1806 // (Unused new instance.) We expect the constructor to throw. ReactiveAssert.Throws(() => new ListObservable(null)); +#pragma warning restore CA1806 } [TestMethod] 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 27b7ecd0f6..affd585853 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 Dictionary _disposeOn = new Dictionary(); + private readonly Dictionary _disposeOn = new(); 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 85b363e142..5fcf70233f 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)obj)._value : obj }); + return (bool)equ.Invoke(_value, new object[] { obj is EitherBase eitherBase ? eitherBase._value : obj }); } public override int GetHashCode() @@ -195,6 +195,7 @@ public void Switch(Action caseLeft, Action caseRight) mth.Invoke(_value, new object[] { caseLeft, caseRight }); } +#pragma warning disable CA1067 // (Override Object.Equals(object) when implementing IEquatable) - not required in the tests that use this type public sealed class Left : Either, IEquatable { public TLeft Value @@ -238,5 +239,6 @@ public bool Equals(Right other) return (bool)equ.Invoke(_value, new object[] { 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 1b6313a8c5..9386165013 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 List>(); + internal List> _queue = new(); private DateTimeOffset _now; @@ -1026,7 +1026,7 @@ public Work(Action action, object state) private class MyCAL : IConcurrencyAbstractionLayer { - internal List> _queue = new List>(); + internal List> _queue = new(); public IDisposable StartTimer(Action action, object state, TimeSpan dueTime) { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/TaskLikeSupportTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/TaskLikeSupportTest.cs index e98f9e3e61..414c1930c8 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/TaskLikeSupportTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/TaskLikeSupportTest.cs @@ -79,7 +79,7 @@ public async Task BasicsNoSynchronizationContext() [TestMethod] public async Task BasicsWithSynchronizationContext() { - SynchronizationContext ctx = SynchronizationContext.Current; + var ctx = SynchronizationContext.Current; try { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); @@ -91,7 +91,6 @@ public async Task BasicsWithSynchronizationContext() } } -#pragma warning disable 1998 private async ITaskObservable ManOrBoy_Basics() { var res = 0; @@ -117,6 +116,5 @@ private async ITaskObservable ManOrBoy_Basics() return res; } -#pragma warning restore 1998 } } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/TaskObservableExtensionsTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/TaskObservableExtensionsTest.cs index 7f155d5c11..72ef92b6d2 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/TaskObservableExtensionsTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/TaskObservableExtensionsTest.cs @@ -378,7 +378,7 @@ public void TaskToObservable_NonVoid_Scheduler() xs.Subscribe(res => { x = res; - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -387,7 +387,7 @@ public void TaskToObservable_NonVoid_Scheduler() e.WaitOne(); Assert.Equal(42, x); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } #endif @@ -736,7 +736,7 @@ public void TaskToObservable_Void_Scheduler() var xs = ((Task)tcs.Task).ToObservable(Scheduler.Immediate); xs.Subscribe(res => { - t = Thread.CurrentThread.ManagedThreadId; + t = Environment.CurrentManagedThreadId; e.Set(); }); @@ -744,7 +744,7 @@ public void TaskToObservable_Void_Scheduler() e.WaitOne(); - Assert.Equal(Thread.CurrentThread.ManagedThreadId, t); + Assert.Equal(Environment.CurrentManagedThreadId, t); } #endif @@ -1125,7 +1125,7 @@ public void ToTask_Scheduler_Resumed_On_Thread_Cancel_With_State_And_Cancellatio Assert.Equal(new TaskCanceledException(task).CancellationToken, cts.Token); } - sealed class OneshotScheduler : IScheduler + private sealed class OneshotScheduler : IScheduler { public DateTimeOffset Now => DateTimeOffset.Now; @@ -1158,7 +1158,7 @@ public void Run() public bool HasTask => _task != null; - sealed class Work : IDisposable + private sealed class Work : IDisposable { internal TState State; internal Func Action; @@ -1173,7 +1173,7 @@ public void Dispose() [TestMethod] public async Task ToTask_Scheduler_Dispose_Can_Propagate() { - async Task asyncMethod() + static async Task asyncMethod() { await Task.Delay(500); Console.WriteLine("Done"); diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/WinFormsTestUtils.cs b/Rx.NET/Source/tests/Tests.System.Reactive/WinFormsTestUtils.cs index 5ab150128c..955387ab53 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/WinFormsTestUtils.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/WinFormsTestUtils.cs @@ -12,7 +12,7 @@ namespace ReactiveTests.Tests { internal static class WinFormsTestUtils { - private static readonly Semaphore s_oneWinForms = new Semaphore(1, 1); + private static readonly Semaphore s_oneWinForms = new(1, 1); public static IDisposable RunTest(out Label label) {