Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -744,11 +744,9 @@ namespace System.Linq
if (list != null)
return list [index];
#if NET_4_5
var readOnlyList = source as IReadOnlyList<TSource>;
if (readOnlyList != null)
return readOnlyList[index];
#endif
return source.ElementAt (index, Fallback.Throw);
}
@@ -768,11 +766,9 @@ namespace System.Linq
if (list != null)
return index < list.Count ? list [index] : default (TSource);
#if NET_4_5
var readOnlyList = source as IReadOnlyList<TSource>;
if (readOnlyList != null)
return index < readOnlyList.Count ? readOnlyList [index] : default (TSource);
#endif
return source.ElementAt (index, Fallback.Default);
}
@@ -2765,14 +2761,14 @@ namespace System.Linq
{
Check.Source (source);
if (count <= 0)
return EmptyOf<TSource>.Instance;
return CreateTakeIterator (source, count);
}
static IEnumerable<TSource> CreateTakeIterator<TSource> (IEnumerable<TSource> source, int count)
{
if (count <= 0)
yield break;
int counter = 0;
foreach (TSource element in source) {
yield return element;
@@ -3073,7 +3069,6 @@ namespace System.Linq
#endregion
#if NET_4_0
#region Zip
public static IEnumerable<TResult> Zip<TFirst, TSecond, TResult> (this IEnumerable<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
@@ -3098,7 +3093,6 @@ namespace System.Linq
}
#endregion
#endif
#region Where

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
namespace System.Linq
{
@@ -38,4 +37,3 @@ namespace System.Linq
}
}
#endif

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System.Linq.Expressions;
@@ -40,4 +39,3 @@ namespace System.Linq
}
}
#endif

View File

@@ -26,7 +26,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
namespace System.Linq
{
@@ -38,4 +37,3 @@ namespace System.Linq
}
}
#endif

View File

@@ -27,7 +27,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_0
using System.Collections;
using System.Collections.Generic;
@@ -98,4 +97,3 @@ namespace System.Linq
}
}
#endif

View File

@@ -30,11 +30,7 @@
using System.Collections.Generic;
namespace System.Linq {
#if NET_4_0
public interface IGrouping<out TKey, out TElement> : IEnumerable<TElement>
#else
public interface IGrouping<TKey, TElement> : IEnumerable<TElement>
#endif
{
TKey Key { get; }
}

View File

@@ -28,11 +28,7 @@
//
namespace System.Linq {
#if NET_4_0
public interface IOrderedQueryable<out T> : IOrderedQueryable, IQueryable<T>
#else
public interface IOrderedQueryable<T> : IOrderedQueryable, IQueryable<T>
#endif
{
}
}

View File

@@ -25,11 +25,7 @@ using System.Collections.Generic;
namespace System.Linq {
#if NET_4_0
public interface IQueryable<out T> : IQueryable, IEnumerable<T>
#else
public interface IQueryable<T> : IQueryable, IEnumerable<T>
#endif
{
}
}

View File

@@ -1,60 +0,0 @@
//
// ParallelQuery.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2010 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq.Parallel.QueryNodes;
namespace System.Linq
{
// Only returned after OrderBy and ThenBy.
public class OrderedParallelQuery<TSource> : ParallelQuery<TSource>
{
QueryOrderByNode<TSource> node;
internal OrderedParallelQuery (QueryOrderByNode<TSource> node)
: base (node)
{
this.node = node;
}
internal new QueryOrderByNode<TSource> Node {
get {
return node;
}
}
public override IEnumerator<TSource> GetEnumerator ()
{
return base.GetEnumerator ();
}
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,38 +0,0 @@
//
// ParallelExecutionMode.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2010 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
namespace System.Linq
{
public enum ParallelExecutionMode
{
Default = 0,
ForceParallelism = 1
}
}
#endif

View File

@@ -1,40 +0,0 @@
//
// ParallelMergeOptions.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2010 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
namespace System.Linq
{
public enum ParallelMergeOptions
{
Default = 0,
NotBuffered,
AutoBuffered,
FullyBuffered
}
}
#endif

View File

@@ -1,127 +0,0 @@
//
// ParallelQuery.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2010 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq.Parallel;
using System.Linq.Parallel.QueryNodes;
namespace System.Linq
{
public class ParallelQuery : IEnumerable
{
ParallelExecutionMode execMode = ParallelExecutionMode.Default;
ParallelMergeOptions mergeOptions = ParallelMergeOptions.Default;
internal ParallelQuery ()
{
}
internal ParallelMergeOptions MergeOptions {
get {
return mergeOptions;
}
set {
mergeOptions = value;
}
}
internal ParallelExecutionMode ExecMode {
get {
return execMode;
}
set {
execMode = value;
}
}
IEnumerator IEnumerable.GetEnumerator ()
{
return GetEnumeratorTrick ();
}
// Trick to get the correct IEnumerator from ParallelQuery<TSource>
internal virtual IEnumerator GetEnumeratorTrick ()
{
return null;
}
internal virtual ParallelQuery<object> TypedQuery {
get {
return null;
}
}
}
public class ParallelQuery<TSource> : ParallelQuery, IEnumerable<TSource>, IEnumerable
{
QueryBaseNode<TSource> node;
internal ParallelQuery (QueryBaseNode<TSource> node)
{
this.node = node;
}
internal QueryBaseNode<TSource> Node {
get {
return node;
}
}
public virtual IEnumerator<TSource> GetEnumerator ()
{
return GetEnumeratorInternal ();
}
IEnumerator IEnumerable.GetEnumerator ()
{
return (IEnumerator)GetEnumeratorInternal ();
}
IEnumerator<TSource> GetEnumeratorInternal ()
{
return new ParallelQueryEnumerator<TSource> (node);
}
internal override IEnumerator GetEnumeratorTrick ()
{
return (IEnumerator)GetEnumeratorInternal ();
}
internal override ParallelQuery<object> TypedQuery {
get {
return new ParallelQuery<object> (new QueryCastNode<TSource> (node));
}
}
}
}
#endif

View File

@@ -1603,7 +1603,6 @@ namespace System.Linq {
#endregion
#if NET_4_0
#region Zip
public static IQueryable<TResult> Zip<TFirst, TSecond, TResult> (this IQueryable<TFirst> source1, IEnumerable<TSecond> source2, Expression<Func<TFirst, TSecond, TResult>> resultSelector)
@@ -1620,6 +1619,5 @@ namespace System.Linq {
}
#endregion
#endif
}
}