Skip to content

Commit 6bcb54f

Browse files
author
Oren Novotny
authored
Merge pull request #1039 from dotnet/dev/bartde/ide_warnings
Address a few minor IDE warnings
2 parents 3110620 + 856b8f2 commit 6bcb54f

File tree

9 files changed

+27
-21
lines changed

9 files changed

+27
-21
lines changed

Ix.NET/Source/Benchmarks.System.Interactive/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Benchmarks.System.Interactive
1010
{
1111
internal class Program
1212
{
13-
internal static void Main(string[] args)
13+
internal static void Main()
1414
{
1515
Console.WriteLine("Effective Ix-version: " + typeof(EnumerableEx).Assembly.GetName().Version);
1616

Ix.NET/Source/System.Interactive.Async.Providers.Tests/AssertEx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal static void SucceedOrFailProper(Action action)
3636
}
3737
catch (AggregateException ex)
3838
{
39-
var inner = ex.Flatten().InnerException;
39+
_ = ex.Flatten().InnerException;
4040

4141
// TODO: proper assert; unfortunately there's not always a good call stack
4242
}

Ix.NET/Source/System.Interactive.Async.Tests/System/Linq/Operators/Never.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
65
using System.Linq;
76
using System.Threading;
87
using System.Threading.Tasks;
@@ -25,7 +24,7 @@ public async Task Never1()
2524
[Fact]
2625
public async Task CancelToken_UnblocksAsync()
2726
{
28-
var cts = new CancellationTokenSource();
27+
using var cts = new CancellationTokenSource();
2928

3029
var en = AsyncEnumerableEx.Never<int>().GetAsyncEnumerator(cts.Token);
3130

Ix.NET/Source/System.Interactive.Tests/AssertEx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal static void SucceedOrFailProper(Action action)
4242
}
4343
catch (AggregateException ex)
4444
{
45-
var inner = ex.Flatten().InnerException;
45+
_ = ex.Flatten().InnerException;
4646

4747
// TODO: proper assert; unfortunately there's not always a good call stack
4848
}

Ix.NET/Source/System.Interactive.Tests/System/Linq/Operators/Publish.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void Publish6()
162162
AssertThrows<MyException>(() => e2.MoveNext());
163163
}
164164

165-
class MyException : Exception
165+
private class MyException : Exception
166166
{
167167
}
168168

Ix.NET/Source/System.Interactive/System/Linq/Operators/IgnoreElements.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static IEnumerable<TSource> IgnoreElements<TSource>(this IEnumerable<TSou
2424

2525
private static IEnumerable<TSource> IgnoreElementsCore<TSource>(IEnumerable<TSource> source)
2626
{
27-
foreach (var item in source)
27+
foreach (var _ in source)
2828
;
2929

3030
yield break;

Ix.NET/Source/System.Linq.Async.Queryable.Tests/AssertEx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal static void SucceedOrFailProper(Action action)
3636
}
3737
catch (AggregateException ex)
3838
{
39-
var inner = ex.Flatten().InnerException;
39+
_ = ex.Flatten().InnerException;
4040

4141
// TODO: proper assert; unfortunately there's not always a good call stack
4242
}

Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToAsyncEnumerable.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public async Task ToAsyncEnumerable_Observable_Throw()
286286
[Fact]
287287
public async Task ToAsyncEnumerable_Observable_Dispose()
288288
{
289-
var stop = new ManualResetEvent(false);
289+
using var stop = new ManualResetEvent(false);
290290

291291
var xs = new MyObservable<int>(obs =>
292292
{
@@ -320,9 +320,9 @@ public async Task ToAsyncEnumerable_Observable_Dispose()
320320
[Fact]
321321
public async Task ToAsyncEnumerable_Observable_Zip()
322322
{
323-
var subCount = 0;
323+
using var stop = new ManualResetEvent(false);
324324

325-
var stop = new ManualResetEvent(false);
325+
var subCount = 0;
326326

327327
var xs = new MyObservable<int>(obs =>
328328
{
@@ -360,7 +360,7 @@ public async Task ToAsyncEnumerable_Observable_Zip()
360360
[Fact]
361361
public async Task ToAsyncEnumerable_Observable_Cancel()
362362
{
363-
var stop = new ManualResetEvent(false);
363+
using var stop = new ManualResetEvent(false);
364364

365365
var xs = new MyObservable<int>(obs =>
366366
{
@@ -380,7 +380,7 @@ public async Task ToAsyncEnumerable_Observable_Cancel()
380380
return new MyDisposable(cts.Cancel);
381381
}).ToAsyncEnumerable();
382382

383-
var c = new CancellationTokenSource();
383+
using var c = new CancellationTokenSource();
384384

385385
var e = xs.GetAsyncEnumerator(c.Token);
386386

@@ -396,7 +396,7 @@ public async Task ToAsyncEnumerable_Observable_Cancel()
396396
[Fact]
397397
public async Task ToAsyncEnumerable_Observable6_Async()
398398
{
399-
var stop = new ManualResetEvent(false);
399+
using var stop = new ManualResetEvent(false);
400400

401401
var xs = new MyObservable<int>(obs =>
402402
{

Ix.NET/Source/System.Linq.Async.Tests/System/Linq/Operators/ToObservable.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ public void ToObservable_Null()
2222
[Fact]
2323
public void ToObservable1()
2424
{
25+
using var evt = new ManualResetEvent(false);
26+
2527
var fail = false;
26-
var evt = new ManualResetEvent(false);
2728

2829
var xs = AsyncEnumerable.Empty<int>().ToObservable();
2930
xs.Subscribe(new MyObserver<int>(
@@ -49,9 +50,10 @@ public void ToObservable1()
4950
[Fact]
5051
public void ToObservable2()
5152
{
53+
using var evt = new ManualResetEvent(false);
54+
5255
var lst = new List<int>();
5356
var fail = false;
54-
var evt = new ManualResetEvent(false);
5557

5658
var xs = Return42.ToObservable();
5759
xs.Subscribe(new MyObserver<int>(
@@ -78,9 +80,10 @@ public void ToObservable2()
7880
[Fact]
7981
public void ToObservable3()
8082
{
83+
using var evt = new ManualResetEvent(false);
84+
8185
var lst = new List<int>();
8286
var fail = false;
83-
var evt = new ManualResetEvent(false);
8487

8588
var xs = AsyncEnumerable.Range(0, 10).ToObservable();
8689
xs.Subscribe(new MyObserver<int>(
@@ -107,10 +110,11 @@ public void ToObservable3()
107110
[Fact]
108111
public void ToObservable4()
109112
{
113+
using var evt = new ManualResetEvent(false);
114+
110115
var ex1 = new Exception("Bang!");
111116
var ex_ = default(Exception);
112117
var fail = false;
113-
var evt = new ManualResetEvent(false);
114118

115119
var xs = Throw<int>(ex1).ToObservable();
116120
xs.Subscribe(new MyObserver<int>(
@@ -138,8 +142,9 @@ public void ToObservable4()
138142
[Fact]
139143
public void ToObservable_DisposesEnumeratorOnCompletion()
140144
{
145+
using var evt = new ManualResetEvent(false);
146+
141147
var fail = false;
142-
var evt = new ManualResetEvent(false);
143148

144149
var ae = AsyncEnumerable.Create(
145150
_ => AsyncEnumerator.Create<int>(
@@ -170,8 +175,9 @@ public void ToObservable_DisposesEnumeratorOnCompletion()
170175
[Fact]
171176
public void ToObservable_DisposesEnumeratorWhenSubscriptionIsDisposed()
172177
{
178+
using var evt = new ManualResetEvent(false);
179+
173180
var fail = false;
174-
var evt = new ManualResetEvent(false);
175181
var subscription = default(IDisposable);
176182
var subscriptionAssignedTcs = new TaskCompletionSource<object>();
177183

@@ -216,9 +222,10 @@ public void ToObservable_DisposesEnumeratorWhenSubscriptionIsDisposed()
216222
[Fact]
217223
public void ToObservable_DesNotCallMoveNextAgainWhenSubscriptionIsDisposed()
218224
{
225+
using var evt = new ManualResetEvent(false);
226+
219227
var fail = false;
220228
var moveNextCount = 0;
221-
var evt = new ManualResetEvent(false);
222229
var subscription = default(IDisposable);
223230
var subscriptionAssignedTcs = new TaskCompletionSource<object>();
224231

0 commit comments

Comments
 (0)