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-USfalse$(MSBuildProjectName.Contains('Tests'))
- $(MSBuildThisFileDirectory)Rx.rulesettrue$(MSBuildThisFileDirectory)artifactstruetruelatest
-
-
- 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_INTERNALRx;Reactive;Extensions;Observable;LINQ;EventsReactive 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