-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add windows explorer integration in settings #8010
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,6 +276,67 @@ public static bool AlwaysShowAllCommands | |
set => WriteBoolRegKey("AlwaysShowAllCommands", value); | ||
} | ||
|
||
public static bool EnableExplorerIntegration | ||
{ | ||
// TODO write getter - check if dll is registered | ||
// get => ReadBoolRegKey("AlwaysShowAllCommands", false); | ||
set => HandleShellIntegration(null, null, value); | ||
} | ||
|
||
private static void HandleShellIntegration(object sender = null, EventArgs e = null, bool register = false) | ||
{ | ||
const string GitExtensionsShellEx32Name = "GitExtensionsShellEx32.dll"; | ||
const string GitExtensionsShellEx64Name = "GitExtensionsShellEx64.dll"; | ||
Comment on lines
+288
to
+289
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move out to the class scope |
||
string path = Path.Combine(AppSettings.GetInstallDir(), GitExtensionsShellEx32Name); | ||
|
||
if (!File.Exists(path)) | ||
{ | ||
path = Assembly.GetExecutingAssembly().Location; | ||
path = Path.GetDirectoryName(path); | ||
path = Path.Combine(path, GitExtensionsShellEx32Name); | ||
} | ||
|
||
if (File.Exists(path)) | ||
{ | ||
try | ||
{ | ||
var pi = new ProcessStartInfo | ||
{ | ||
FileName = "regsvr32", | ||
Arguments = $"{(!register ? "/u " : "")}" + path.Quote(), | ||
Verb = "RunAs", | ||
UseShellExecute = false, | ||
|
||
// TODO confirmation window is not suppressed | ||
CreateNoWindow = true | ||
}; | ||
|
||
// TODO is IntPtr really the correct way to check architecture here? | ||
if (IntPtr.Size == 8) | ||
{ | ||
path = path.Replace(GitExtensionsShellEx32Name, GitExtensionsShellEx64Name); | ||
if (File.Exists(path)) | ||
{ | ||
pi.Arguments = $"{(!register ? "/u" : "")}" + path.Quote(); | ||
} | ||
} | ||
Comment on lines
+303
to
+322
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❗ Multiple string allocations for no reason. |
||
|
||
var process = Process.Start(pi); | ||
process.WaitForExit(); | ||
} | ||
catch (System.ComponentModel.Win32Exception) | ||
{ | ||
// User cancel operation, continue; | ||
} | ||
} | ||
else | ||
{ | ||
// MessageBox.Show(this, string.Format(_cantRegisterShellExtension.Text, CommonLogic.GitExtensionsShellEx32Name), Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
} | ||
|
||
// CheckSettings(); | ||
} | ||
|
||
public static bool ShowCurrentBranchInVisualStudio | ||
{ | ||
// This setting MUST be set to false by default, otherwise it will not work in Visual Studio without | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move out to own file, call it something like
ShellExtensionManager
:NB: don't make it static, to reduce risks of race conditions while testing. The implementation should be stateless (as far as our code is concerned), so there is no issue with creating multiple instances of the class.
We can later replace is with MEF DI.
Furthermore, I don't like the functionality of registering/unregestering being placed in AppSettings. It is not a settings, and it is unrelated to the app.
If there is an error while registering or unregistering the shell extensions there is no way to inform a user.
Please move checks and register/unregister to the settings page, where it belongs.