Eli Arbel %!s(int64=9) %!d(string=hai) anos
pai
achega
62b7ef4fb6

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 3 - 0
Ix.NET/Source/Ix.NET.sln.DotSettings


+ 14 - 14
Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.Aggregates.cs

@@ -34,8 +34,8 @@ namespace System.Linq
                     acc = accumulator(acc, e.Current);
                 }
             }
-            var result = resultSelector(acc);
-            return result;
+
+            return resultSelector(acc);
         }
 
         public static Task<TAccumulate> Aggregate<TSource, TAccumulate>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, CancellationToken cancellationToken)
@@ -367,7 +367,7 @@ namespace System.Linq
                     return default(TSource);
                 }
 
-                TSource result = e.Current;
+                var result = e.Current;
                 if (!await e.MoveNext(cancellationToken).ConfigureAwait(false))
                 {
                     return result;
@@ -608,7 +608,7 @@ namespace System.Linq
             {
                 while (await e.MoveNext(cancellationToken).ConfigureAwait(false))
                 {
-                    int? v = e.Current;
+                    var v = e.Current;
                     if (v.HasValue)
                     {
                         long sum = v.GetValueOrDefault();
@@ -651,7 +651,7 @@ namespace System.Linq
                     throw new InvalidOperationException(Strings.NO_ELEMENTS);
                 }
 
-                long sum = e.Current;
+                var sum = e.Current;
                 long count = 1;
                 checked
                 {
@@ -680,10 +680,10 @@ namespace System.Linq
             {
                 while (await e.MoveNext(cancellationToken).ConfigureAwait(false))
                 {
-                    long? v = e.Current;
+                    var v = e.Current;
                     if (v.HasValue)
                     {
-                        long sum = v.GetValueOrDefault();
+                        var sum = v.GetValueOrDefault();
                         long count = 1;
                         checked
                         {
@@ -723,7 +723,7 @@ namespace System.Linq
                     throw new InvalidOperationException(Strings.NO_ELEMENTS);
                 }
 
-                double sum = e.Current;
+                var sum = e.Current;
                 long count = 1;
                 while (await e.MoveNext(cancellationToken).ConfigureAwait(false))
                 {
@@ -752,10 +752,10 @@ namespace System.Linq
             {
                 while (await e.MoveNext(cancellationToken).ConfigureAwait(false))
                 {
-                    double? v = e.Current;
+                    var v = e.Current;
                     if (v.HasValue)
                     {
-                        double sum = v.GetValueOrDefault();
+                        var sum = v.GetValueOrDefault();
                         long count = 1;
                         checked
                         {
@@ -821,7 +821,7 @@ namespace System.Linq
             {
                 while (await e.MoveNext(cancellationToken).ConfigureAwait(false))
                 {
-                    float? v = e.Current;
+                    var v = e.Current;
                     if (v.HasValue)
                     {
                         double sum = v.GetValueOrDefault();
@@ -864,7 +864,7 @@ namespace System.Linq
                     throw new InvalidOperationException(Strings.NO_ELEMENTS);
                 }
 
-                decimal sum = e.Current;
+                var sum = e.Current;
                 long count = 1;
                 while (await e.MoveNext(cancellationToken).ConfigureAwait(false))
                 {
@@ -890,10 +890,10 @@ namespace System.Linq
             {
                 while (await e.MoveNext(cancellationToken).ConfigureAwait(false))
                 {
-                    decimal? v = e.Current;
+                    var v = e.Current;
                     if (v.HasValue)
                     {
-                        decimal sum = v.GetValueOrDefault();
+                        var sum = v.GetValueOrDefault();
                         long count = 1;
                         while (await e.MoveNext(cancellationToken).ConfigureAwait(false))
                         {

+ 0 - 30
Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.Conversions.cs

@@ -10,36 +10,6 @@ namespace System.Linq
 {
     public static partial class AsyncEnumerable
     {
-        public static IAsyncEnumerable<TSource> AsAsyncEnumerable<TSource>(this IEnumerable<TSource> source)
-        {
-            if (source == null)
-                throw new ArgumentNullException(nameof(source));
-
-            return Create(() =>
-            {
-                var e = source.GetEnumerator();
-
-                return Create(
-                    ct =>
-                    {
-                        var res = false;
-                        try
-                        {
-                            res = e.MoveNext();
-                        }
-                        finally
-                        {
-                            if (!res)
-                                e.Dispose();
-                        }
-                        return res ? TaskExt.True : TaskExt.False;
-                    },
-                    () => e.Current,
-                    () => e.Dispose()
-                );
-            });
-        }
-
         public static IAsyncEnumerable<TSource> ToAsyncEnumerable<TSource>(this IEnumerable<TSource> source)
         {
             if (source == null)

+ 12 - 12
Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.Creation.cs

@@ -11,14 +11,14 @@ namespace System.Linq
 {
     public static partial class AsyncEnumerable
     {
-        static IAsyncEnumerable<T> Create<T>(Func<IAsyncEnumerator<T>> getEnumerator)
+        private static IAsyncEnumerable<T> Create<T>(Func<IAsyncEnumerator<T>> getEnumerator)
         {
             return new AnonymousAsyncEnumerable<T>(getEnumerator);
         }
 
-        class AnonymousAsyncEnumerable<T> : IAsyncEnumerable<T>
+        private class AnonymousAsyncEnumerable<T> : IAsyncEnumerable<T>
         {
-            Func<IAsyncEnumerator<T>> getEnumerator;
+            private Func<IAsyncEnumerator<T>> getEnumerator;
 
             public AnonymousAsyncEnumerable(Func<IAsyncEnumerator<T>> getEnumerator)
             {
@@ -31,7 +31,7 @@ namespace System.Linq
             }
         }
 
-        static IAsyncEnumerator<T> Create<T>(Func<CancellationToken, Task<bool>> moveNext, Func<T> current,
+        private static IAsyncEnumerator<T> Create<T>(Func<CancellationToken, Task<bool>> moveNext, Func<T> current,
             Action dispose, IDisposable enumerator)
         {
             return Create(async ct =>
@@ -56,16 +56,16 @@ namespace System.Linq
             }, current, dispose);
         }
 
-        static IAsyncEnumerator<T> Create<T>(Func<CancellationToken, Task<bool>> moveNext, Func<T> current, Action dispose)
+        private static IAsyncEnumerator<T> Create<T>(Func<CancellationToken, Task<bool>> moveNext, Func<T> current, Action dispose)
         {
             return new AnonymousAsyncEnumerator<T>(moveNext, current, dispose);
         }
 
-        static IAsyncEnumerator<T> Create<T>(Func<CancellationToken, TaskCompletionSource<bool>, Task<bool>> moveNext, Func<T> current, Action dispose)
+        private static IAsyncEnumerator<T> Create<T>(Func<CancellationToken, TaskCompletionSource<bool>, Task<bool>> moveNext, Func<T> current, Action dispose)
         {
             var self = default(IAsyncEnumerator<T>);
             self = new AnonymousAsyncEnumerator<T>(
-                ct =>
+                async ct =>
                 {
                     var tcs = new TaskCompletionSource<bool>();
 
@@ -75,10 +75,10 @@ namespace System.Linq
                         tcs.TrySetCanceled();
                     });
 
-                    var ctr = ct.Register(stop);
-
-                    var res = moveNext(ct, tcs).Finally(ctr.Dispose);
-                    return res;
+                    using (ct.Register(stop))
+                    {
+                        return await moveNext(ct, tcs);
+                    }
                 },
                 current,
                 dispose
@@ -86,7 +86,7 @@ namespace System.Linq
             return self;
         }
 
-        class AnonymousAsyncEnumerator<T> : IAsyncEnumerator<T>
+        private class AnonymousAsyncEnumerator<T> : IAsyncEnumerator<T>
         {
             private readonly Func<CancellationToken, Task<bool>> _moveNext;
             private readonly Func<T> _current;

+ 2 - 8
Ix.NET/Source/System.Interactive.Async/AsyncEnumerable.Single.cs

@@ -355,10 +355,7 @@ namespace System.Linq
                     {
                         if (await e.MoveNext(cts.Token).ConfigureAwait(false))
                         {
-                            if (predicate(e.Current))
-                            {
-                                return true;
-                            }
+                            return predicate(e.Current);
                         }
                         return false;
                     },
@@ -389,10 +386,7 @@ namespace System.Linq
                     {
                         if (await e.MoveNext(cts.Token).ConfigureAwait(false))
                         {
-                            if (predicate(e.Current, checked(index++)))
-                            {
-                                return true;
-                            }
+                            return predicate(e.Current, checked(index++));
                         }
                         return false;
                     },

+ 3 - 1
Ix.NET/Source/System.Interactive.Async/EmptyArray.cs

@@ -1,4 +1,6 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
 #if NO_ARRAY_EMPTY
 using System;
 using System.Collections.Generic;

+ 5 - 5
Ix.NET/Source/System.Interactive.Async/Grouping.cs

@@ -1,11 +1,13 @@
-using System;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
 using System.Collections;
 using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 
 namespace System.Linq.Internal
 {
+    /// Adapted from System.Linq.Grouping from .NET Framework
+    /// Source: https://github.com/dotnet/corefx/blob/b90532bc97b07234a7d18073819d019645285f1c/src/System.Linq/src/System/Linq/Grouping.cs#L64
     internal class Grouping<TKey, TElement> : IGrouping<TKey, TElement>, IList<TElement>
     {
         internal TKey _key;
@@ -126,6 +128,4 @@ namespace System.Linq.Internal
             }
         }
     }
-
-
 }

+ 3 - 2
Ix.NET/Source/System.Interactive.Async/Lookup.cs

@@ -1,8 +1,9 @@
-using System;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
 using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
 

+ 1 - 1
Ix.NET/Source/System.Interactive.Async/Strings.cs

@@ -7,6 +7,6 @@ namespace System.Linq
     {
         public static string NO_ELEMENTS = "Source sequence doesn't contain any elements.";
         public static string MORE_THAN_ONE_ELEMENT = "Source sequence contains more than one element.";
-        public static string NOT_SUPPORTED = "NOT SUPPORTED";
+        public static string NOT_SUPPORTED = "Specified method is not supported.";
     }
 }

+ 2 - 41
Ix.NET/Source/System.Interactive.Async/TaskExt.cs

@@ -1,24 +1,15 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
-using System;
 using System.Collections.Generic;
-using System.Linq;
 
 namespace System.Threading.Tasks
 {
     static class TaskExt
     {
-        public static readonly Task<bool> True = Return(true);
-        public static readonly Task<bool> False = Return(false);
+        public static readonly Task<bool> True = Task.FromResult(true);
+        public static readonly Task<bool> False = Task.FromResult(false);
         
-        public static Task<T> Return<T>(T value)
-        {
-            var tcs = new TaskCompletionSource<T>();
-            tcs.TrySetResult(value);
-            return tcs.Task;
-        }
-
         public static Task<T> Throw<T>(Exception exception)
         {
             var tcs = new TaskCompletionSource<T>();
@@ -26,36 +17,6 @@ namespace System.Threading.Tasks
             return tcs.Task;
         }
 
-        public static Task<R> Finally<R>(this Task<R> task, Action action)
-        {
-            var tcs = new TaskCompletionSource<R>();
-
-            task.ContinueWith(t =>
-            {
-                try
-                {
-                    action();
-                }
-                finally
-                {
-                    switch (t.Status)
-                    {
-                        case TaskStatus.Canceled:
-                            tcs.SetCanceled();
-                            break;
-                        case TaskStatus.Faulted:
-                            tcs.SetException(t.Exception.InnerException);
-                            break;
-                        case TaskStatus.RanToCompletion:
-                            tcs.SetResult(t.Result);
-                            break;
-                    }
-                }
-            }, TaskContinuationOptions.ExecuteSynchronously);
-
-            return tcs.Task;
-        }
-
         public static Task<V> Zip<T, U, V>(this Task<T> t1, Task<U> t2, Func<T, U, V> f)
         {
             var tcs = new TaskCompletionSource<V>();

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio