Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit f525e98

Browse files
committed
Merge pull request #1970 from Clockwork-Muse/System.Linq.Parallel_CastArgumentNull
Add missing null-argument check to System.Linq.Parallel.Cast().
2 parents 59c5b6a + 63c1862 commit f525e98

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5363,6 +5363,8 @@ public static ParallelQuery<TResult> OfType<TResult>(this ParallelQuery source)
53635363
/// </exception>
53645364
public static ParallelQuery<TResult> Cast<TResult>(this ParallelQuery source)
53655365
{
5366+
if (source == null) throw new ArgumentNullException("source");
5367+
53665368
return source.Cast<TResult>();
53675369
}
53685370

src/System.Linq.Parallel/tests/QueryOperators/CastTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ public static void Cast_Assignable_InvalidCastException(Labeled<ParallelQuery<in
118118
}
119119

120120
[Fact]
121-
public static void Cast_NullReferenceException()
121+
public static void Cast_ArgumentNullException()
122122
{
123-
// Everything else throws ArgumentNullException, but Cast is missing the check that would do so.
124-
Assert.Throws<NullReferenceException>(() => ((ParallelQuery<object>)null).Cast<int>());
123+
Assert.Throws<ArgumentNullException>(() => ((ParallelQuery<object>)null).Cast<int>());
125124
}
126125

127126
private class Castable

0 commit comments

Comments
 (0)