mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 05:35:00 +00:00
code_style: remove all IDE warnings
This commit is contained in:
parent
24ca3eaf8c
commit
f4eca45754
79 changed files with 1462 additions and 1378 deletions
|
@ -15,8 +15,8 @@ namespace SourceGit.Native
|
|||
{
|
||||
class Terminal
|
||||
{
|
||||
public string FilePath { get; set; } = string.Empty;
|
||||
public string OpenArgFormat { get; set; } = string.Empty;
|
||||
public string FilePath { get; set; }
|
||||
public string OpenArgFormat { get; set; }
|
||||
|
||||
public Terminal(string exec, string fmt)
|
||||
{
|
||||
|
@ -115,12 +115,15 @@ namespace SourceGit.Native
|
|||
}
|
||||
|
||||
var proc = Process.Start(_xdgOpenPath, $"\"{file}\"");
|
||||
proc.WaitForExit();
|
||||
if (proc != null)
|
||||
{
|
||||
proc.WaitForExit();
|
||||
|
||||
if (proc.ExitCode != 0)
|
||||
App.RaiseException("", $"Failed to open \"{file}\"");
|
||||
if (proc.ExitCode != 0)
|
||||
App.RaiseException("", $"Failed to open \"{file}\"");
|
||||
|
||||
proc.Close();
|
||||
proc.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private string FindExecutable(string filename)
|
||||
|
@ -177,7 +180,7 @@ namespace SourceGit.Native
|
|||
return File.Exists(path) ? path : FindExecutable("fleet");
|
||||
}
|
||||
|
||||
private string _xdgOpenPath = string.Empty;
|
||||
private string _xdgOpenPath = null;
|
||||
private Terminal _terminal = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,10 @@ namespace SourceGit.Native
|
|||
File.WriteAllText(tmp, builder.ToString());
|
||||
|
||||
var proc = Process.Start("osascript", $"\"{tmp}\"");
|
||||
proc.Exited += (o, e) => File.Delete(tmp);
|
||||
if (proc != null)
|
||||
proc.Exited += (_, _) => File.Delete(tmp);
|
||||
else
|
||||
File.Delete(tmp);
|
||||
}
|
||||
|
||||
public void OpenWithDefaultEditor(string file)
|
||||
|
|
|
@ -48,20 +48,16 @@ namespace SourceGit.Native
|
|||
public static Models.Shell GetShell()
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
return (_backend as Windows).Shell;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Models.Shell.Default;
|
||||
}
|
||||
return (_backend as Windows)!.Shell;
|
||||
|
||||
return Models.Shell.Default;
|
||||
}
|
||||
|
||||
public static bool SetShell(Models.Shell shell)
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
var windows = _backend as Windows;
|
||||
var windows = (_backend as Windows)!;
|
||||
if (windows.Shell != shell)
|
||||
{
|
||||
windows.Shell = shell;
|
||||
|
|
|
@ -73,8 +73,8 @@ namespace SourceGit.Native
|
|||
v.dwOSVersionInfoSize = (uint)Marshal.SizeOf<RTL_OSVERSIONINFOEX>();
|
||||
if (RtlGetVersion(ref v) == 0 && (v.dwMajorVersion < 10 || v.dwBuildNumber < 22000))
|
||||
{
|
||||
Window.WindowStateProperty.Changed.AddClassHandler<Window>((w, e) => ExtendWindowFrame(w));
|
||||
Window.LoadedEvent.AddClassHandler<Window>((w, e) => ExtendWindowFrame(w));
|
||||
Window.WindowStateProperty.Changed.AddClassHandler<Window>((w, _) => ExtendWindowFrame(w));
|
||||
Control.LoadedEvent.AddClassHandler<Window>((w, _) => ExtendWindowFrame(w));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,9 +85,9 @@ namespace SourceGit.Native
|
|||
Microsoft.Win32.RegistryView.Registry64);
|
||||
|
||||
var git = reg.OpenSubKey("SOFTWARE\\GitForWindows");
|
||||
if (git != null)
|
||||
if (git != null && git.GetValue("InstallPath") is string installPath)
|
||||
{
|
||||
return Path.Combine(git.GetValue("InstallPath") as string, "bin", "git.exe");
|
||||
return Path.Combine(installPath, "bin", "git.exe");
|
||||
}
|
||||
|
||||
var builder = new StringBuilder("git.exe", 259);
|
||||
|
@ -137,7 +137,13 @@ namespace SourceGit.Native
|
|||
switch (Shell)
|
||||
{
|
||||
case Models.Shell.Default:
|
||||
var binDir = Path.GetDirectoryName(OS.GitExecutable);
|
||||
if (string.IsNullOrEmpty(OS.GitExecutable))
|
||||
{
|
||||
App.RaiseException(workdir, $"Can NOT found bash.exe");
|
||||
return;
|
||||
}
|
||||
|
||||
var binDir = Path.GetDirectoryName(OS.GitExecutable)!;
|
||||
var bash = Path.Combine(binDir, "bash.exe");
|
||||
if (!File.Exists(bash))
|
||||
{
|
||||
|
@ -175,28 +181,23 @@ namespace SourceGit.Native
|
|||
|
||||
public void OpenInFileManager(string path, bool select)
|
||||
{
|
||||
var fullpath = string.Empty;
|
||||
string fullpath;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
fullpath = new FileInfo(path).FullName;
|
||||
|
||||
// For security reason, we never execute a file.
|
||||
// Instead, we open the folder and select it.
|
||||
select = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fullpath = new DirectoryInfo(path).FullName;
|
||||
fullpath = new DirectoryInfo(path!).FullName;
|
||||
}
|
||||
|
||||
if (select)
|
||||
{
|
||||
// The fullpath here may be a file or a folder.
|
||||
OpenFolderAndSelectFile(fullpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The fullpath here is always a folder.
|
||||
Process.Start(new ProcessStartInfo(fullpath)
|
||||
{
|
||||
UseShellExecute = true,
|
||||
|
@ -362,7 +363,7 @@ namespace SourceGit.Native
|
|||
if (sublime != null)
|
||||
{
|
||||
var icon = sublime.GetValue("DisplayIcon") as string;
|
||||
return Path.Combine(Path.GetDirectoryName(icon), "subl.exe");
|
||||
return Path.Combine(Path.GetDirectoryName(icon)!, "subl.exe");
|
||||
}
|
||||
|
||||
// Sublime Text 3
|
||||
|
@ -370,7 +371,7 @@ namespace SourceGit.Native
|
|||
if (sublime3 != null)
|
||||
{
|
||||
var icon = sublime3.GetValue("DisplayIcon") as string;
|
||||
return Path.Combine(Path.GetDirectoryName(icon), "subl.exe");
|
||||
return Path.Combine(Path.GetDirectoryName(icon)!, "subl.exe");
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue