diff --git a/src/GitHub.Api/Authentication/ICredentialManager.cs b/src/GitHub.Api/Authentication/ICredentialManager.cs index 190d22d2b..10fe6964a 100644 --- a/src/GitHub.Api/Authentication/ICredentialManager.cs +++ b/src/GitHub.Api/Authentication/ICredentialManager.cs @@ -14,7 +14,7 @@ interface ICredential : IDisposable interface ICredentialManager { Task Load(UriString host); - Task Save(ICredential credential); + Task Save(ICredential cred); Task Delete(UriString host); bool HasCredentials(); ICredential CachedCredentials { get; } diff --git a/src/GitHub.Api/Git/GitCredentialManager.cs b/src/GitHub.Api/Git/GitCredentialManager.cs index f55350a9c..8cccd3809 100644 --- a/src/GitHub.Api/Git/GitCredentialManager.cs +++ b/src/GitHub.Api/Git/GitCredentialManager.cs @@ -97,11 +97,11 @@ public async Task Load(UriString host) return credential; } - public async Task Save(ICredential credential) + public async Task Save(ICredential cred) { - Logger.Trace("Save: {0}", credential.Host); + this.credential = cred; - this.credential = credential; + Logger.Trace("Save: {0}", credential.Host); if (!await LoadCredentialHelper()) return; diff --git a/src/GitHub.Api/IO/FileSystem.cs b/src/GitHub.Api/IO/FileSystem.cs index 9f990de45..4c9920da3 100644 --- a/src/GitHub.Api/IO/FileSystem.cs +++ b/src/GitHub.Api/IO/FileSystem.cs @@ -14,15 +14,19 @@ public FileSystem() { } - public FileSystem(string currentDirectory) + /// + /// Initialize the filesystem object with the path passed in set as the current directory + /// + /// Current directory + public FileSystem(string directory) { - this.currentDirectory = currentDirectory; + this.currentDirectory = directory; } - public void SetCurrentDirectory(string currentDirectory) + public void SetCurrentDirectory(string directory) { - Debug.Assert(Path.IsPathRooted(currentDirectory)); - this.currentDirectory = currentDirectory; + Debug.Assert(Path.IsPathRooted(directory)); + this.currentDirectory = directory; } public bool FileExists(string filename) diff --git a/src/GitHub.Api/NewTaskSystem/ConcurrentExclusiveInterleave.cs b/src/GitHub.Api/NewTaskSystem/ConcurrentExclusiveInterleave.cs index 8cdb61e2c..37982e141 100644 --- a/src/GitHub.Api/NewTaskSystem/ConcurrentExclusiveInterleave.cs +++ b/src/GitHub.Api/NewTaskSystem/ConcurrentExclusiveInterleave.cs @@ -391,8 +391,8 @@ protected override IEnumerable GetScheduledTasks() /// The task to be executed. internal void ExecuteTask(Task task) { - var processingTaskOnCurrentThread = this.processingTaskOnCurrentThread.Value; - if (!processingTaskOnCurrentThread) this.processingTaskOnCurrentThread.Value = true; + var isProcessingTaskOnCurrentThread = this.processingTaskOnCurrentThread.Value; + if (!isProcessingTaskOnCurrentThread) this.processingTaskOnCurrentThread.Value = true; //try //{ TryExecuteTask(task); @@ -403,7 +403,7 @@ internal void ExecuteTask(Task task) // throw; //} - if (!processingTaskOnCurrentThread) this.processingTaskOnCurrentThread.Value = false; + if (!isProcessingTaskOnCurrentThread) this.processingTaskOnCurrentThread.Value = false; } /// Gets the maximum concurrency level this scheduler is able to support. diff --git a/src/GitHub.Api/NewTaskSystem/TaskBase.cs b/src/GitHub.Api/NewTaskSystem/TaskBase.cs index 1aef74c77..70c3707a5 100644 --- a/src/GitHub.Api/NewTaskSystem/TaskBase.cs +++ b/src/GitHub.Api/NewTaskSystem/TaskBase.cs @@ -10,7 +10,7 @@ interface ITask : IAsyncResult ITask Catch(Action handler); ITask Catch(Func handler); ITask Finally(Action handler); - ITask Finally(Action continuation, TaskAffinity affinity = TaskAffinity.Concurrent); + ITask Finally(Action actionToContinueWith, TaskAffinity affinity = TaskAffinity.Concurrent); ITask Defer(Func continueWith, TaskAffinity affinity = TaskAffinity.Concurrent, bool always = false); ITask Start(); ITask Start(TaskScheduler scheduler); @@ -157,22 +157,22 @@ public ITask Finally(Action handler) return this; } - public ITask Finally(Action continuation, TaskAffinity affinity = TaskAffinity.Concurrent) + public ITask Finally(Action actionToContinueWith, TaskAffinity affinity = TaskAffinity.Concurrent) { - Guard.ArgumentNotNull(continuation, "continuation"); - var ret = Then(new ActionTask(Token, continuation) { Affinity = affinity, Name = "Finally" }, true); + Guard.ArgumentNotNull(actionToContinueWith, nameof(actionToContinueWith)); + var ret = Then(new ActionTask(Token, actionToContinueWith) { Affinity = affinity, Name = "Finally" }, true); DependsOn?.SetFaultHandler(ret); ret.ContinuationIsFinally = true; return ret; } - internal virtual ITask Finally(T continuation) + internal virtual ITask Finally(T taskToContinueWith) where T : TaskBase { - Guard.ArgumentNotNull(continuation, "continuation"); + Guard.ArgumentNotNull(taskToContinueWith, nameof(taskToContinueWith)); + continuation = (TaskBase)(object)taskToContinueWith; + continuationAlways = true; continuation.SetDependsOn(this); - this.continuation = (TaskBase)(object)continuation; - this.continuationAlways = true; DependsOn?.SetFaultHandler((TaskBase)(object)continuation); return continuation; } diff --git a/src/GitHub.Api/Platform/Settings.cs b/src/GitHub.Api/Platform/Settings.cs index 78689d6cd..e83e6f8c9 100644 --- a/src/GitHub.Api/Platform/Settings.cs +++ b/src/GitHub.Api/Platform/Settings.cs @@ -111,16 +111,16 @@ public override void Rename(string oldKey, string newKey) SaveToCache(cachePath); } - private void LoadFromCache(string cachePath) + private void LoadFromCache(string path) { - logger.Trace("LoadFromCache: {0}", cachePath); + logger.Trace("LoadFromCache: {0}", path); - EnsureCachePath(cachePath); + EnsureCachePath(path); - if (!fileExists(cachePath)) + if (!fileExists(path)) return; - var data = readAllText(cachePath, Encoding.UTF8); + var data = readAllText(path, Encoding.UTF8); try { @@ -135,21 +135,21 @@ private void LoadFromCache(string cachePath) if (cacheData == null) { // cache is corrupt, remove - fileDelete(cachePath); + fileDelete(path); return; } } - private bool SaveToCache(string cachePath) + private bool SaveToCache(string path) { - logger.Trace("SaveToCache: {0}", cachePath); + logger.Trace("SaveToCache: {0}", path); - EnsureCachePath(cachePath); + EnsureCachePath(path); try { var data = SimpleJson.SerializeObject(cacheData); - writeAllText(cachePath, data); + writeAllText(path, data); } catch (Exception ex) { @@ -160,12 +160,12 @@ private bool SaveToCache(string cachePath) return true; } - private void EnsureCachePath(string cachePath) + private void EnsureCachePath(string path) { - if (fileExists(cachePath)) + if (fileExists(path)) return; - var di = Path.GetDirectoryName(cachePath); + var di = Path.GetDirectoryName(path); if (!dirExists(di)) dirCreate(di); } diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationManager.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationManager.cs index aa096fb93..0e93f28e0 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationManager.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationManager.cs @@ -34,9 +34,9 @@ protected override void InitializeUI() { Logger.Trace("Restarted {0}", Environment.Repository); ProjectWindowInterface.Initialize(Environment.Repository); - var view = Window.GetWindow(); - if (view != null) - view.Initialize(this); + var window = Window.GetWindow(); + if (window != null) + window.Initialize(this); } protected override void SetProjectToTextSerialization() diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs index 2306b4901..ad6e3e3b1 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs @@ -23,7 +23,7 @@ class AuthenticationView : Subview [NonSerialized] private bool need2fa; [NonSerialized] private bool busy; - [NonSerialized] private string message; + [NonSerialized] private string errorMessage; [NonSerialized] private bool enterPressed; [NonSerialized] private string password = ""; @@ -148,7 +148,7 @@ private void OnGUILogin() } GUILayout.EndHorizontal(); - ShowMessage(message, Styles.ErrorLabel); + ShowErrorMessage(); GUILayout.Space(Styles.BaseSpacing + 3); @@ -182,7 +182,7 @@ private void OnGUI2FA() GUILayout.EndHorizontal(); GUILayout.Space(Styles.BaseSpacing); - ShowMessage(message, Styles.ErrorLabel); + ShowErrorMessage(); GUILayout.Space(Styles.BaseSpacing); @@ -214,7 +214,7 @@ private void DoRequire2fa(string msg) Logger.Trace("Strating 2FA - Message:\"{0}\"", msg); need2fa = true; - message = msg; + errorMessage = msg; busy = false; Redraw(); } @@ -223,7 +223,7 @@ private void DoResult(bool success, string msg) { Logger.Trace("DoResult - Success:{0} Message:\"{1}\"", success, msg); - message = msg; + errorMessage = msg; busy = false; if (success == true) @@ -236,11 +236,11 @@ private void DoResult(bool success, string msg) } } - private void ShowMessage(string message, GUIStyle style) + private void ShowErrorMessage() { - if (message != null) + if (errorMessage != null) { - GUILayout.Label(message, style); + GUILayout.Label(errorMessage, Styles.ErrorLabel); } } }