Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 8340365

Browse files
authored
Merge pull request #605 from github-for-unity/shana/kill-dead-code
Killing some unused code
2 parents cd73d5d + e8bacd8 commit 8340365

File tree

4 files changed

+3
-166
lines changed

4 files changed

+3
-166
lines changed

src/GitHub.Api/Events/RepositoryWatcher.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ private int ProcessEvents(Event[] fileEvents)
169169
var eventDirectory = new NPath(fileEvent.Directory);
170170
var fileA = eventDirectory.Combine(fileEvent.FileA);
171171

172-
NPath fileB = null;
173-
if (fileEvent.FileB != null)
174-
{
175-
fileB = eventDirectory.Combine(fileEvent.FileB);
176-
}
177-
178172
// handling events in .git/*
179173
if (fileA.IsChildOf(paths.DotGitPath))
180174
{

src/GitHub.Api/Tasks/TaskBase.cs

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ public interface ITask : IAsyncResult
3333
ITask Start(TaskScheduler scheduler);
3434
ITask Progress(Action<IProgress> progressHandler);
3535

36-
void Wait();
37-
bool Wait(int milliseconds);
3836
bool Successful { get; }
3937
string Errors { get; }
4038
Task Task { get; }
@@ -373,16 +371,6 @@ protected TaskBase GetTopMostTask(TaskBase ret, bool onlyCreatedState)
373371
return depends.GetTopMostTask(ret, onlyCreatedState);
374372
}
375373

376-
public virtual void Wait()
377-
{
378-
Task.Wait(Token);
379-
}
380-
381-
public virtual bool Wait(int milliseconds)
382-
{
383-
return Task.Wait(milliseconds, Token);
384-
}
385-
386374
protected virtual void Run(bool success)
387375
{
388376
}
@@ -443,8 +431,8 @@ protected Exception GetThrownException()
443431

444432
if (DependsOn.Task.Status == TaskStatus.Faulted)
445433
{
446-
var exception = DependsOn.Task.Exception;
447-
return exception?.InnerException ?? exception;
434+
var ex = DependsOn.Task.Exception;
435+
return ex?.InnerException ?? ex;
448436
}
449437
return DependsOn.GetThrownException();
450438
}
@@ -707,33 +695,6 @@ protected void RaiseOnData(TData data)
707695
}
708696
}
709697

710-
static class TaskBaseExtensions
711-
{
712-
public static T Schedule<T>(this T task, ITaskManager taskManager)
713-
where T : ITask
714-
{
715-
return taskManager.Schedule(task);
716-
}
717-
718-
public static T ScheduleUI<T>(this T task, ITaskManager taskManager)
719-
where T : ITask
720-
{
721-
return taskManager.ScheduleUI(task);
722-
}
723-
724-
public static T ScheduleExclusive<T>(this T task, ITaskManager taskManager)
725-
where T : ITask
726-
{
727-
return taskManager.ScheduleExclusive(task);
728-
}
729-
730-
public static T ScheduleConcurrent<T>(this T task, ITaskManager taskManager)
731-
where T : ITask
732-
{
733-
return taskManager.ScheduleConcurrent(task);
734-
}
735-
}
736-
737698
public enum TaskAffinity
738699
{
739700
Concurrent,

src/GitHub.Api/Tasks/TaskExtensions.cs

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,11 @@
11
using GitHub.Logging;
22
using System;
3-
using System.Threading;
43
using System.Threading.Tasks;
54

65
namespace GitHub.Unity
76
{
87
static class TaskExtensions
98
{
10-
private static Task completedTask;
11-
12-
public static Task CompletedTask
13-
{
14-
get
15-
{
16-
if (completedTask == null)
17-
{
18-
completedTask = TaskEx.FromResult(true);
19-
}
20-
return completedTask;
21-
}
22-
}
23-
24-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "task")]
25-
public static void Forget(this Task task)
26-
{
27-
}
28-
29-
public static async Task SafeAwait(this Task source, Action<Exception> handler = null)
30-
{
31-
try
32-
{
33-
await source;
34-
}
35-
catch (Exception ex)
36-
{
37-
LogHelper.GetLogger().Error(ex);
38-
if (handler == null)
39-
throw;
40-
handler(ex);
41-
}
42-
}
43-
44-
public static async Task<T> SafeAwait<T>(this Task<T> source, Func<Exception, T> handler = null)
45-
{
46-
try
47-
{
48-
return await source;
49-
}
50-
catch (Exception ex)
51-
{
52-
LogHelper.GetLogger().Error(ex);
53-
if (handler == null)
54-
throw;
55-
return handler(ex);
56-
}
57-
}
58-
599
public static async Task StartAwait(this ITask source, Action<Exception> handler = null)
6010
{
6111
try
@@ -86,41 +36,6 @@ public static async Task<T> StartAwait<T>(this ITask<T> source, Func<Exception,
8636
}
8737
}
8838

89-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "task")]
90-
public static void Forget(this ITask task)
91-
{
92-
task.Task.Forget();
93-
}
94-
95-
//http://stackoverflow.com/a/29491927
96-
public static Action<T> Debounce<T>(this Action<T> func, int milliseconds = 300)
97-
{
98-
var last = 0;
99-
return arg =>
100-
{
101-
var current = Interlocked.Increment(ref last);
102-
TaskEx.Delay(milliseconds).ContinueWith(task =>
103-
{
104-
if (current == last) func(arg);
105-
task.Dispose();
106-
});
107-
};
108-
}
109-
110-
public static Action Debounce(this Action func, int milliseconds = 300)
111-
{
112-
var last = 0;
113-
return () =>
114-
{
115-
var current = Interlocked.Increment(ref last);
116-
TaskEx.Delay(milliseconds).ContinueWith(task =>
117-
{
118-
if (current == last) func();
119-
task.Dispose();
120-
});
121-
};
122-
}
123-
12439
public static ITask Then(this ITask task, Action continuation, TaskAffinity affinity = TaskAffinity.Concurrent, TaskRunOptions runOptions = TaskRunOptions.OnSuccess)
12540
{
12641
Guard.ArgumentNotNull(continuation, "continuation");
@@ -133,13 +48,6 @@ public static ITask Then(this ITask task, Action<bool> continuation, TaskAffinit
13348
return task.Then(new ActionTask(task.Token, continuation) { Affinity = affinity, Name = "Then" }, runOptions);
13449
}
13550

136-
public static ITask Then<T>(this ITask task, ActionTask<T> nextTask, T valueForNextTask, TaskAffinity affinity = TaskAffinity.Concurrent, TaskRunOptions runOptions = TaskRunOptions.OnSuccess)
137-
{
138-
Guard.ArgumentNotNull(nextTask, nameof(nextTask));
139-
nextTask.PreviousResult = valueForNextTask;
140-
return task.Then(nextTask, runOptions);
141-
}
142-
14351
public static ITask Then<T>(this ITask<T> task, Action<bool, T> continuation, TaskAffinity affinity = TaskAffinity.Concurrent, TaskRunOptions runOptions = TaskRunOptions.OnSuccess)
14452
{
14553
Guard.ArgumentNotNull(continuation, "continuation");
@@ -164,11 +72,6 @@ public static ITask<T> Then<T>(this ITask task, Task<T> continuation, TaskAffini
16472
return task.Then(cont, runOptions);
16573
}
16674

167-
public static ITask<T> Then<T>(this ITask task, Func<Task<T>> continuation, TaskAffinity affinity = TaskAffinity.Concurrent, TaskRunOptions runOptions = TaskRunOptions.OnSuccess)
168-
{
169-
return task.Then(continuation(), affinity, runOptions);
170-
}
171-
17275
public static ITask ThenInUI(this ITask task, Action continuation, TaskRunOptions runOptions = TaskRunOptions.OnSuccess)
17376
{
17477
return task.Then(continuation, TaskAffinity.UI, runOptions);
@@ -184,11 +87,6 @@ public static ITask ThenInUI<T>(this ITask<T> task, Action<bool, T> continuation
18487
return task.Then(continuation, TaskAffinity.UI, runOptions);
18588
}
18689

187-
public static ITask<T> ThenInUI<T>(this ITask task, Func<bool, T> continuation, TaskRunOptions runOptions = TaskRunOptions.OnSuccess)
188-
{
189-
return task.Then(continuation, TaskAffinity.UI, runOptions);
190-
}
191-
19290
public static ITask<TRet> ThenInUI<T, TRet>(this ITask<T> task, Func<bool, T, TRet> continuation, TaskRunOptions runOptions = TaskRunOptions.OnSuccess)
19391
{
19492
return task.Then(continuation, TaskAffinity.UI, runOptions);
@@ -200,27 +98,11 @@ public static ITask FinallyInUI<T>(this T task, Action<bool, Exception> continua
20098
return task.Finally(continuation, TaskAffinity.UI);
20199
}
202100

203-
public static ITask FinallyInUI<T>(this T task, Action continuation)
204-
where T : ITask
205-
{
206-
return task.Finally((s, e) => continuation(), TaskAffinity.UI);
207-
}
208-
209101
public static ITask FinallyInUI<T>(this ITask<T> task, Action<bool, Exception, T> continuation)
210102
{
211103
return task.Finally(continuation, TaskAffinity.UI);
212104
}
213105

214-
public static ITask<T> FinallyInUI<T>(this ITask<T> task, Func<T> continuation)
215-
{
216-
return task.Finally((s, e, r) => continuation(), TaskAffinity.UI);
217-
}
218-
219-
public static ITask<T> FinallyInUI<T>(this ITask<T> task, Func<bool, Exception, T, T> continuation)
220-
{
221-
return task.Finally(continuation, TaskAffinity.UI);
222-
}
223-
224106
public static Task<T> StartAsAsync<T>(this ITask<T> task)
225107
{
226108
var tcs = new TaskCompletionSource<T>();

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public override void OnGUI()
6868
{
6969
isBusy = true;
7070
Manager.InitializeRepository()
71-
.FinallyInUI(() => isBusy = false)
71+
.FinallyInUI((s, e) => isBusy = false)
7272
.Start();
7373
}
7474
}

0 commit comments

Comments
 (0)