Browse Source

Merge pull request #1374 from dotnet/dev/bartde/remove_dead_code

Remove some dead code.
Bart J.F. De Smet 5 years ago
parent
commit
38a0db6656

+ 0 - 28
Rx.NET/Source/src/System.Reactive/Internal/Helpers.cs

@@ -8,34 +8,6 @@ namespace System.Reactive
 {
     internal static class Helpers
     {
-        public static int? GetLength<T>(IEnumerable<T> source)
-        {
-            return source switch
-            {
-                T[] array => array.Length,
-                IList<T> list => list.Count,
-                _ => null
-            };
-        }
-
-        public static IObservable<T>? Unpack<T>(IObservable<T>? source)
-        {
-            bool hasOpt;
-
-            do
-            {
-                hasOpt = false;
-
-                if (source is IEvaluatableObservable<T> eval)
-                {
-                    source = eval.Eval();
-                    hasOpt = true;
-                }
-            } while (hasOpt);
-
-            return source;
-        }
-
         public static bool All(this bool[] values)
         {
             foreach (var value in values)

+ 19 - 1
Rx.NET/Source/src/System.Reactive/Internal/TailRecursiveSink.cs

@@ -90,7 +90,7 @@ namespace System.Reactive
 
                         try
                         {
-                            next = Helpers.Unpack(currentObservable);
+                            next = Unpack(currentObservable);
                         }
                         catch (Exception ex)
                         {
@@ -166,6 +166,24 @@ namespace System.Reactive
                     break;
                 }
             }
+
+            static IObservable<T>? Unpack<T>(IObservable<T>? source)
+            {
+                bool hasOpt;
+
+                do
+                {
+                    hasOpt = false;
+
+                    if (source is IEvaluatableObservable<T> eval)
+                    {
+                        source = eval.Eval();
+                        hasOpt = true;
+                    }
+                } while (hasOpt);
+
+                return source;
+            }
         }
 
         private void DisposeAll()

+ 0 - 63
Rx.NET/Source/src/System.Reactive/Internal/TaskExtensions.cs

@@ -6,44 +6,6 @@ namespace System.Threading.Tasks
 {
     internal static class TaskExtensions
     {
-        public static Task ContinueWithState<TState>(this Task task, Action<Task, TState> continuationAction, TState state)
-        {
-            return task.ContinueWith(
-                (t, tupleObject) =>
-                {
-                    var (closureAction, closureState) = ((Action<Task, TState>, TState))tupleObject!;
-
-                    closureAction(t, closureState);
-                },
-                (continuationAction, state));
-        }
-
-        public static Task ContinueWithState<TState>(this Task task, Action<Task, TState> continuationAction, TState state, CancellationToken cancellationToken)
-        {
-            return task.ContinueWith(
-                (t, tupleObject) =>
-                {
-                    var (closureAction, closureState) = ((Action<Task, TState>, TState))tupleObject!;
-
-                    closureAction(t, closureState);
-                },
-                (continuationAction, state),
-                cancellationToken);
-        }
-
-        public static Task ContinueWithState<TState>(this Task task, Action<Task, TState> continuationAction, TState state, TaskContinuationOptions continuationOptions)
-        {
-            return task.ContinueWith(
-                (t, tupleObject) =>
-                {
-                    var (closureAction, closureState) = ((Action<Task, TState>, TState))tupleObject!;
-
-                    closureAction(t, closureState);
-                },
-                (continuationAction, state),
-                continuationOptions);
-        }
-
         public static Task ContinueWithState<TState>(this Task task, Action<Task, TState> continuationAction, TState state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions)
         {
             return task.ContinueWith(
@@ -59,18 +21,6 @@ namespace System.Threading.Tasks
                 TaskScheduler.Default);
         }
 
-        public static Task ContinueWithState<TResult, TState>(this Task<TResult> task, Action<Task<TResult>, TState> continuationAction, TState state)
-        {
-            return task.ContinueWith(
-                (t, tupleObject) =>
-                {
-                    var (closureAction, closureState) = ((Action<Task<TResult>, TState>, TState))tupleObject!;
-
-                    closureAction(t, closureState);
-                },
-                (continuationAction, state));
-        }
-
         public static Task ContinueWithState<TResult, TState>(this Task<TResult> task, Action<Task<TResult>, TState> continuationAction, TState state, CancellationToken cancellationToken)
         {
             return task.ContinueWith(
@@ -84,19 +34,6 @@ namespace System.Threading.Tasks
                 cancellationToken);
         }
 
-        public static Task ContinueWithState<TResult, TState>(this Task<TResult> task, Action<Task<TResult>, TState> continuationAction, TState state, TaskContinuationOptions continuationOptions)
-        {
-            return task.ContinueWith(
-                (t, tupleObject) =>
-                {
-                    var (closureAction, closureState) = ((Action<Task<TResult>, TState>, TState))tupleObject!;
-
-                    closureAction(t, closureState);
-                },
-                (continuationAction, state),
-                continuationOptions);
-        }
-
         public static Task ContinueWithState<TResult, TState>(this Task<TResult> task, Action<Task<TResult>, TState> continuationAction, TState state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions)
         {
             return task.ContinueWith(