Example #1
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            HighDpiMouseCursors.Enable();

            try
            {
                if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => ReportBug((Exception)e.ExceptionObject);
                    Application.ThreadException += (s, e) => ReportBug(e.Exception);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException != null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            // This is done here so these values can be used in the GitGui project but this project is the authority of the values.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
        public void GitVersion_is_good()
        {
            var gitString = UserEnvironmentInformation.GetGitVersionInfo("2.21.0.windows.1", new GitVersion("2.18.0"),
                                                                         new GitVersion("2.21.0"));

            Assert.AreEqual("2.21.0.windows.1", gitString);
        }
        public void GitVersion_is_not_supported()
        {
            var gitString = UserEnvironmentInformation.GetGitVersionInfo("1.6.5.windows.1", new GitVersion("2.18.0"),
                                                                         new GitVersion("2.21.0"));

            Assert.AreEqual("1.6.5.windows.1 (minimum: 2.18.0, please update!)", gitString);
        }
        public void GitVersion_is_unknown_then_return_all_data()
        {
            var gitString = UserEnvironmentInformation.GetGitVersionInfo(null, new GitVersion("2.18.0"),
                                                                         new GitVersion("2.21.0"));

            Assert.AreEqual("- (minimum: 2.18.0, recommended: 2.21.0)", gitString);
        }
Example #5
0
        public void CreateInstanceOfClass()
        {
            UserEnvironmentInformation.Initialise("", false);
            var translatableTypes = TranslationUtil.GetTranslatableTypes();

            var problems = new List <(string typeName, Exception exception)>();

            foreach (var types in translatableTypes.Values)
            {
                var translation = new TranslationFile();

                foreach (var type in types)
                {
                    try
                    {
                        var obj = (ITranslate)TranslationUtil.CreateInstanceOfClass(type);

                        obj.AddTranslationItems(translation);
                        obj.TranslateItems(translation);
                    }
                    catch (Exception ex)
                    {
                        problems.Add((type.FullName, ex));
                    }
                }
            }

            if (problems.Count != 0)
            {
                Assert.Fail(string.Join(
                                "\n\n--------\n\n",
                                problems.Select(p => $"Problem with type {p.typeName}\n\n{p.exception}")));
            }
        }
        public void GitVersion_is_old_but_supported()
        {
            var gitString = UserEnvironmentInformation.GetGitVersionInfo("2.20.1.windows.1", new GitVersion("2.18.0"),
                                                                         new GitVersion("2.21.0"));

            Assert.AreEqual("2.20.1.windows.1 (recommended: 2.21.0 or later)", gitString);
        }
Example #7
0
        private static void ShowNBug(IWin32Window?owner, Exception exception, bool isTerminating)
        {
            var envInfo = UserEnvironmentInformation.GetInformation();

            using var form = new GitUI.NBugReports.BugReportForm();
            var result = form.ShowDialog(owner, exception, envInfo);

            if (isTerminating || result == DialogResult.Abort)
            {
                Environment.Exit(-1);
            }
        }
        public EnvironmentInfo()
        {
            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime || GitModuleForm.IsUnitTestActive)
            {
                UserEnvironmentInformation.Initialise(
                    "9999999999999999999999999999999999abcdef", true);
            }

            InitializeComponent();

            environmentIssueInfo.Text = UserEnvironmentInformation.GetInformation().Replace("- ", "");
        }
Example #9
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            HighDpiMouseCursors.Enable();

            try
            {
                NBug.Settings.UIMode = NBug.Enums.UIMode.Full;

                // Uncomment the following after testing to see that NBug is working as configured
                NBug.Settings.ReleaseMode = true;
                NBug.Settings.ExitApplicationImmediately = false;
                NBug.Settings.WriteLogToDisk             = false;
                NBug.Settings.MaxQueuedReports           = 10;
                NBug.Settings.StopReportingAfter         = 90;
                NBug.Settings.SleepBeforeSend            = 30;
                NBug.Settings.StoragePath   = NBug.Enums.StoragePath.WindowsTemp;
                NBug.Settings.GetSystemInfo = () =>
                {
                    // if the error happens before we had a chance to init the environment information
                    // the call to GetInformation() will fail. A double Initialise() call is safe.
                    UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);
                    return(UserEnvironmentInformation.GetInformation());
                };

                if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
                    Application.ThreadException += NBug.Handler.ThreadException;
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException != null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            // This is done here so these values can be used in the GitGui project but this project is the authority of the values.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
        private static void ShowNBug(IWin32Window?owner, Exception exception, bool isExternalOperation, bool isTerminating)
        {
            using BugReportForm form = new();
            DialogResult result = form.ShowDialog(owner, new SerializableException(exception),
                                                  UserEnvironmentInformation.GetInformation(),
                                                  canIgnore: !isTerminating,
                                                  showIgnore: isExternalOperation,
                                                  focusDetails: exception is UserExternalOperationException);

            if (isTerminating || result == DialogResult.Abort)
            {
                Environment.Exit(-1);
            }
        }
Example #11
0
        private static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // If an error happens before we had a chance to init the environment information
            // the call to GetInformation() from BugReporter.ShowNBug() will fail.
            // There's no perf hit calling Initialise() multiple times.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            ThemeModule.Load();
            Application.ApplicationExit += (s, e) => ThemeModule.Unload();

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);

                if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => BugReporter.Report((Exception)e.ExceptionObject, e.IsTerminating);
                    Application.ThreadException += (s, e) => BugReporter.Report(e.Exception, isTerminating: false);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException != null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            // This is done here so these values can be used in the GitGui project but this project is the authority of the values.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);
            AppTitleGenerator.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.Branch);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
Example #12
0
        private static void ReportBug(Exception ex)
        {
            // if the error happens before we had a chance to init the environment information
            // the call to GetInformation() will fail. A double Initialise() call is safe.
            UserEnvironmentInformation.Initialise(VsrInfo.Sha, VsrInfo.IsDirty);
            var envInfo = UserEnvironmentInformation.GetInformation();

            using (var form = new GitUI.NBugReports.BugReportForm())
            {
                var result = form.ShowDialog(ex, envInfo);
                if (result == DialogResult.Abort)
                {
                    Environment.Exit(-1);
                }
            }
        }
Example #13
0
        private static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // TODO: VSR - removed this because it was failing after switching to x64
            // ThemeModule.Load();
            // Application.ApplicationExit += (s, e) => ThemeModule.Unload();

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(VsrInfo.IsDirty);

                if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => ReportBug((Exception)e.ExceptionObject);
                    Application.ThreadException += (s, e) => ReportBug(e.Exception);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException != null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            // This is done here so these values can be used in the GitGui project but this project is the authority of the values.
            UserEnvironmentInformation.Initialise(VsrInfo.Sha, VsrInfo.IsDirty);
            AppTitleGenerator.Initialise(VsrInfo.Sha, VsrInfo.Branch);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
Example #14
0
        private static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // If an error happens before we had a chance to init the environment information
            // the call to GetInformation() from BugReporter.ShowNBug() will fail.
            // There's no perf hit calling Initialise() multiple times.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            AppSettings.SetDocumentationBaseUrl(ThisAssembly.Git.Branch);

#if SUPPORT_THEMES
            ThemeModule.Load();
            Application.ApplicationExit += (s, e) => ThemeModule.Unload();

            SystemEvents.UserPreferenceChanged += (s, e) =>
            {
                // Whenever a user changes monitor scaling (e.g. 100%->125%) unload and
                // reload the theme, and repaint all forms
                if (e.Category == UserPreferenceCategory.Desktop || e.Category == UserPreferenceCategory.VisualStyle)
                {
                    ThemeModule.ReloadWin32ThemeData();
                    foreach (Form form in Application.OpenForms)
                    {
                        form.BeginInvoke((MethodInvoker)(() => form.Invalidate()));
                    }
                }
            };
#endif

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);

                // If you want to suppress the BugReportInvoker when debugging and exit quickly, uncomment the condition:
                ////if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => BugReportInvoker.Report((Exception)e.ExceptionObject, e.IsTerminating);
                    Application.ThreadException += (s, e) => BugReportInvoker.Report(e.Exception, isTerminating: false);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException is not null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            AppTitleGenerator.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.Branch);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
Example #15
0
        public EnvironmentInfo()
        {
            InitializeComponent();

            environmentIssueInfo.Text = UserEnvironmentInformation.GetInformation().Replace("-", "");
        }
Example #16
0
 private static void IssuesItem_Click(object sender, EventArgs e)
 {
     UserEnvironmentInformation.CopyInformation();
     Process.Start(@"https://github.com/gitextensions/gitextensions/issues");
 }
 private void copyButton_Click(object sender, EventArgs e)
 {
     UserEnvironmentInformation.CopyInformation();
 }
 public void RunCommandBasedOnArgument_about()
 {
     UserEnvironmentInformation.Initialise("1234567", isDirty: true);
     RunCommandBasedOnArgument <FormAbout>(new string[] { "ge.exe", "about" });
 }
Example #19
0
 private static void IssuesItem_Click(object sender, EventArgs e)
 {
     UserEnvironmentInformation.CopyInformation();
     OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/issues");
 }