You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
3
external/corefx/src/System.Linq/dir.props
vendored
3
external/corefx/src/System.Linq/dir.props
vendored
@@ -2,7 +2,8 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>4.2.0.0</AssemblyVersion>
|
||||
<AssemblyVersion>4.2.1.0</AssemblyVersion>
|
||||
<AssemblyKey>MSFT</AssemblyKey>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
<IsUAP>true</IsUAP>
|
||||
</PropertyGroup>
|
||||
|
||||
8
external/corefx/src/System.Linq/src/ILLinkTrim.xml
vendored
Normal file
8
external/corefx/src/System.Linq/src/ILLinkTrim.xml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<linker>
|
||||
<assembly fullname="System.Linq">
|
||||
<!-- required by debugger, see comment in System/Linq/DebugView.cs -->
|
||||
<type fullname="System.Linq.SystemCore_EnumerableDebugView" />
|
||||
<type fullname="System.Linq.SystemCore_EnumerableDebugView`1" />
|
||||
<type fullname="System.Linq.SystemCore_EnumerableDebugViewEmptyException" />
|
||||
</assembly>
|
||||
</linker>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -231,18 +231,10 @@ namespace System.Linq
|
||||
{
|
||||
IEnumerable<TResult> enumerable = _selector(element);
|
||||
|
||||
int count;
|
||||
if (EnumerableHelpers.TryGetCount(enumerable, out count))
|
||||
if (builder.ReserveOrAdd(enumerable))
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
builder.Reserve(count);
|
||||
deferredCopies.Add(enumerable);
|
||||
}
|
||||
continue;
|
||||
deferredCopies.Add(enumerable);
|
||||
}
|
||||
|
||||
builder.AddRange(enumerable);
|
||||
}
|
||||
|
||||
TResult[] array = builder.ToArray();
|
||||
@@ -252,7 +244,6 @@ namespace System.Linq
|
||||
{
|
||||
Marker marker = markers[i];
|
||||
IEnumerable<TResult> enumerable = deferredCopies[i];
|
||||
|
||||
EnumerableHelpers.Copy(enumerable, array, marker.Index, marker.Count);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,25 +186,25 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullSource()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate((x, y) => x + y));
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate(0, (x, y) => x + y));
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate(0, (x, y) => x + y, i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate((x, y) => x + y));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate(0, (x, y) => x + y));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Aggregate(0, (x, y) => x + y, i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullFunc()
|
||||
{
|
||||
Func<int, int, int> func = null;
|
||||
Assert.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(func));
|
||||
Assert.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(0, func));
|
||||
Assert.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(0, func, i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(func));
|
||||
AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(0, func));
|
||||
AssertExtensions.Throws<ArgumentNullException>("func", () => Enumerable.Range(0, 3).Aggregate(0, func, i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullResultSelector()
|
||||
{
|
||||
Func<int, int> resultSelector = null;
|
||||
Assert.Throws<ArgumentNullException>("resultSelector", () => Enumerable.Range(0, 3).Aggregate(0, (x, y) => x + y, resultSelector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("resultSelector", () => Enumerable.Range(0, 3).Aggregate(0, (x, y) => x + y, resultSelector));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,14 +66,14 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).All(i => i != 0));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).All(i => i != 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullPredicate_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<int, bool> predicate = null;
|
||||
Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).All(predicate));
|
||||
AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).All(predicate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,15 +88,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Any());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Any(i => i != 0));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Any());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Any(i => i != 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullPredicate_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<int, bool> predicate = null;
|
||||
Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Any(predicate));
|
||||
AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Any(predicate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void SourceNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Append(1));
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Prepend(1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Append(1));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Prepend(1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -58,15 +58,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullableFloat_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float?>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullableFloat_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<float?, float?> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float?>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float?>().Average(selector));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -95,15 +95,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void Int_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Int_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<int, int> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int>().Average(selector));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Int_TestData()
|
||||
@@ -163,15 +163,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullableInt_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int?>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullableInt_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<int?, int?> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int?>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<int?>().Average(selector));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -200,15 +200,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void Long_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Long_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<long, long> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long>().Average(selector));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Long_TestData()
|
||||
@@ -269,15 +269,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullableLong_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<long?>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullableLong_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<long?, long?> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long?>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<long?>().Average(selector));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -306,15 +306,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void Double_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Double_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<double, double> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double>().Average(selector));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Double_TestData()
|
||||
@@ -369,15 +369,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullableDouble_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<double?>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullableDouble_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<double?, double?> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double?>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<double?>().Average(selector));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -406,15 +406,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void Decimal_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Decimal_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<decimal, decimal> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal>().Average(selector));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Decimal_TestData()
|
||||
@@ -467,15 +467,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullableDecimal_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<decimal?>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullableDecimal_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<decimal?, decimal?> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal?>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<decimal?>().Average(selector));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -512,15 +512,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void Float_NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Average());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Average(i => i));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Average());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<float>)null).Average(i => i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Float_NullSelector_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<float, float> selector = null;
|
||||
Assert.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float>().Average(selector));
|
||||
AssertExtensions.Throws<ArgumentNullException>("selector", () => Enumerable.Empty<float>().Average(selector));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Float_TestData()
|
||||
|
||||
@@ -225,7 +225,7 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullSource()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<object>)null).Cast<string>());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<object>)null).Cast<string>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -58,14 +58,14 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void FirstNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("first", () => ((IEnumerable<int>)null).Concat(Enumerable.Range(0, 0)));
|
||||
Assert.Throws<ArgumentNullException>("first", () => ((IEnumerable<int>)null).Concat(null)); // If both inputs are null, throw for "first" first
|
||||
AssertExtensions.Throws<ArgumentNullException>("first", () => ((IEnumerable<int>)null).Concat(Enumerable.Range(0, 0)));
|
||||
AssertExtensions.Throws<ArgumentNullException>("first", () => ((IEnumerable<int>)null).Concat(null)); // If both inputs are null, throw for "first" first
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SecondNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("second", () => Enumerable.Range(0, 0).Concat(null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("second", () => Enumerable.Range(0, 0).Concat(null));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -223,6 +223,7 @@ namespace System.Linq.Tests
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(ManyConcatsData))]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Stack overflows on desktop due to inefficient Concat implementation")]
|
||||
public void ManyConcatsRunOnce(IEnumerable<IEnumerable<int>> sources, IEnumerable<int> expected)
|
||||
{
|
||||
foreach (var transform in IdentityTransforms<int>())
|
||||
@@ -251,24 +252,39 @@ namespace System.Linq.Tests
|
||||
var supposedlyLargeCollection = new DelegateBasedCollection<int> { CountWorker = () => int.MaxValue };
|
||||
var tinyCollection = new DelegateBasedCollection<int> { CountWorker = () => 1 };
|
||||
|
||||
Action<Action> assertThrows = (testCode) =>
|
||||
{
|
||||
// The full .NET Framework uses unsigned arithmetic summing up collection counts.
|
||||
// See https://github.com/dotnet/corefx/pull/11492.
|
||||
if (PlatformDetection.IsFullFramework)
|
||||
{
|
||||
testCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Throws<OverflowException>(testCode);
|
||||
}
|
||||
};
|
||||
|
||||
// We need to use checked arithmetic summing up the collections' counts.
|
||||
Assert.Throws<OverflowException>(() => supposedlyLargeCollection.Concat(tinyCollection).Count());
|
||||
Assert.Throws<OverflowException>(() => tinyCollection.Concat(tinyCollection).Concat(supposedlyLargeCollection).Count());
|
||||
Assert.Throws<OverflowException>(() => tinyCollection.Concat(tinyCollection).Concat(tinyCollection).Concat(supposedlyLargeCollection).Count());
|
||||
assertThrows(() => supposedlyLargeCollection.Concat(tinyCollection).Count());
|
||||
assertThrows(() => tinyCollection.Concat(tinyCollection).Concat(supposedlyLargeCollection).Count());
|
||||
assertThrows(() => tinyCollection.Concat(tinyCollection).Concat(tinyCollection).Concat(supposedlyLargeCollection).Count());
|
||||
|
||||
// This applies to ToArray() and ToList() as well, which try to preallocate the exact size
|
||||
// needed if all inputs are ICollections.
|
||||
Assert.Throws<OverflowException>(() => supposedlyLargeCollection.Concat(tinyCollection).ToArray());
|
||||
Assert.Throws<OverflowException>(() => tinyCollection.Concat(tinyCollection).Concat(supposedlyLargeCollection).ToArray());
|
||||
Assert.Throws<OverflowException>(() => tinyCollection.Concat(tinyCollection).Concat(tinyCollection).Concat(supposedlyLargeCollection).ToArray());
|
||||
assertThrows(() => supposedlyLargeCollection.Concat(tinyCollection).ToArray());
|
||||
assertThrows(() => tinyCollection.Concat(tinyCollection).Concat(supposedlyLargeCollection).ToArray());
|
||||
assertThrows(() => tinyCollection.Concat(tinyCollection).Concat(tinyCollection).Concat(supposedlyLargeCollection).ToArray());
|
||||
|
||||
Assert.Throws<OverflowException>(() => supposedlyLargeCollection.Concat(tinyCollection).ToList());
|
||||
Assert.Throws<OverflowException>(() => tinyCollection.Concat(tinyCollection).Concat(supposedlyLargeCollection).ToList());
|
||||
Assert.Throws<OverflowException>(() => tinyCollection.Concat(tinyCollection).Concat(tinyCollection).Concat(supposedlyLargeCollection).ToList());
|
||||
assertThrows(() => supposedlyLargeCollection.Concat(tinyCollection).ToList());
|
||||
assertThrows(() => tinyCollection.Concat(tinyCollection).Concat(supposedlyLargeCollection).ToList());
|
||||
assertThrows(() => tinyCollection.Concat(tinyCollection).Concat(tinyCollection).Concat(supposedlyLargeCollection).ToList());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[OuterLoop("This test tries to catch stack overflows and can take a long time.")]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Stack overflows on desktop due to inefficient Concat implementation")]
|
||||
public void CountOfConcatCollectionChainShouldBeResilientToStackOverflow()
|
||||
{
|
||||
// Currently, .Concat chains of 3+ ICollections are represented as a
|
||||
@@ -303,6 +319,7 @@ namespace System.Linq.Tests
|
||||
|
||||
[Fact]
|
||||
[OuterLoop("This test tries to catch stack overflows and can take a long time.")]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Stack overflows on desktop due to inefficient Concat implementation")]
|
||||
public void CountOfConcatEnumerableChainShouldBeResilientToStackOverflow()
|
||||
{
|
||||
// Concat chains where one or more of the inputs is not an ICollection
|
||||
@@ -338,6 +355,7 @@ namespace System.Linq.Tests
|
||||
|
||||
[Fact]
|
||||
[OuterLoop("This test tries to catch stack overflows and can take a long time.")]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Stack overflows on desktop due to inefficient Concat implementation")]
|
||||
public void GettingFirstEnumerableShouldBeResilientToStackOverflow()
|
||||
{
|
||||
// When MoveNext() is first called on a chain of 3+ Concats, we have to
|
||||
@@ -366,6 +384,7 @@ namespace System.Linq.Tests
|
||||
|
||||
[Fact]
|
||||
[OuterLoop("This test tries to catch stack overflows and can take a long time.")]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Stack overflows on desktop due to inefficient Concat implementation")]
|
||||
public void GetEnumerableOfConcatCollectionChainFollowedByEnumerableNodeShouldBeResilientToStackOverflow()
|
||||
{
|
||||
// Since concatenating even 1 lazy enumerable ruins the ability for ToArray/ToList
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<BuildConfigurations>
|
||||
netcoreapp;
|
||||
netstandard;
|
||||
uapaot;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -111,8 +111,8 @@ namespace System.Linq.Tests
|
||||
{
|
||||
IEnumerable<int> source = null;
|
||||
|
||||
Assert.Throws<ArgumentNullException>("source", () => source.Contains(42));
|
||||
Assert.Throws<ArgumentNullException>("source", () => source.Contains(42, EqualityComparer<int>.Default));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => source.Contains(42));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => source.Contains(42, EqualityComparer<int>.Default));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -119,15 +119,15 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Count());
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Count(i => i != 0));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Count());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).Count(i => i != 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullPredicate_ThrowsArgumentNullException()
|
||||
{
|
||||
Func<int, bool> predicate = null;
|
||||
Assert.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Count(predicate));
|
||||
AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).Count(predicate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,8 +94,8 @@ namespace System.Linq.Tests
|
||||
{
|
||||
IEnumerable<int> source = null;
|
||||
|
||||
Assert.Throws<ArgumentNullException>("source", () => source.DefaultIfEmpty());
|
||||
Assert.Throws<ArgumentNullException>("source", () => source.DefaultIfEmpty(42));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => source.DefaultIfEmpty());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => source.DefaultIfEmpty(42));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace System.Linq.Tests
|
||||
{
|
||||
string[] source = null;
|
||||
|
||||
Assert.Throws<ArgumentNullException>("source", () => source.Distinct());
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => source.Distinct());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -157,7 +157,7 @@ namespace System.Linq.Tests
|
||||
{
|
||||
string[] source = null;
|
||||
|
||||
Assert.Throws<ArgumentNullException>("source", () => source.Distinct(StringComparer.Ordinal));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => source.Distinct(StringComparer.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).ElementAtOrDefault(2));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).ElementAtOrDefault(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,13 +56,13 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void InvalidIndex_ThrowsArgumentOutOfRangeException()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>("index", () => new int?[] { 9, 8 }.ElementAt(-1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("index", () => new int[] { 1, 2, 3, 4 }.ElementAt(4));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("index", () => new int[0].ElementAt(0));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => new int?[] { 9, 8 }.ElementAt(-1));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => new int[] { 1, 2, 3, 4 }.ElementAt(4));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => new int[0].ElementAt(0));
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(-4, 5).ElementAt(-1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(5, 5).ElementAt(5));
|
||||
Assert.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(0, 0).ElementAt(0));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(-4, 5).ElementAt(-1));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(5, 5).ElementAt(5));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => NumberRangeGuaranteedNotCollectionType(0, 0).ElementAt(0));
|
||||
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void NullSource_ThrowsArgumentNullException()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).ElementAt(2));
|
||||
AssertExtensions.Throws<ArgumentNullException>("source", () => ((IEnumerable<int>)null).ElementAt(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,27 +25,33 @@ namespace System.Linq.Tests
|
||||
[Fact]
|
||||
public void SingleInstance()
|
||||
{
|
||||
Assert.Same(GetEmptyPartition<int>(), GetEmptyPartition<int>());
|
||||
// .NET Core returns the instance as an optimization.
|
||||
// see https://github.com/dotnet/corefx/pull/2401.
|
||||
Assert.Equal(!PlatformDetection.IsFullFramework, ReferenceEquals(GetEmptyPartition<int>(), GetEmptyPartition<int>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SkipSame()
|
||||
{
|
||||
var empty = GetEmptyPartition<int>();
|
||||
Assert.Same(empty, empty.Skip(2));
|
||||
IEnumerable<int> empty = GetEmptyPartition<int>();
|
||||
// .NET Core returns the instance as an optimization.
|
||||
// see https://github.com/dotnet/corefx/pull/2401.
|
||||
Assert.Equal(!PlatformDetection.IsFullFramework, ReferenceEquals(empty, empty.Skip(2)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TakeSame()
|
||||
{
|
||||
var empty = GetEmptyPartition<int>();
|
||||
Assert.Same(empty, empty.Take(2));
|
||||
IEnumerable<int> empty = GetEmptyPartition<int>();
|
||||
// .NET Core returns the instance as an optimization.
|
||||
// see https://github.com/dotnet/corefx/pull/2401.
|
||||
Assert.Equal(!PlatformDetection.IsFullFramework, ReferenceEquals(empty, empty.Take(2)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ElementAtThrows()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>("index", () => GetEmptyPartition<int>().ElementAt(0));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => GetEmptyPartition<int>().ElementAt(0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -103,8 +103,8 @@ namespace System.Linq.Tests
|
||||
string[] first = null;
|
||||
string[] second = { "bBo", "shriC" };
|
||||
|
||||
Assert.Throws<ArgumentNullException>("first", () => first.Except(second));
|
||||
Assert.Throws<ArgumentNullException>("first", () => first.Except(second, new AnagramEqualityComparer()));
|
||||
AssertExtensions.Throws<ArgumentNullException>("first", () => first.Except(second));
|
||||
AssertExtensions.Throws<ArgumentNullException>("first", () => first.Except(second, new AnagramEqualityComparer()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -113,8 +113,8 @@ namespace System.Linq.Tests
|
||||
string[] first = { "Bob", "Tim", "Robert", "Chris" };
|
||||
string[] second = null;
|
||||
|
||||
Assert.Throws<ArgumentNullException>("second", () => first.Except(second));
|
||||
Assert.Throws<ArgumentNullException>("second", () => first.Except(second, new AnagramEqualityComparer()));
|
||||
AssertExtensions.Throws<ArgumentNullException>("second", () => first.Except(second));
|
||||
AssertExtensions.Throws<ArgumentNullException>("second", () => first.Except(second, new AnagramEqualityComparer()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user