public void Setup()
        {
            _repositoryDescriptionProvider = Substitute.For <IRepositoryDescriptionProvider>();
            _repositoryDescriptionProvider.Get(Arg.Any <string>()).Returns(ShortName);

            _appTitleGenerator = new AppTitleGenerator(_repositoryDescriptionProvider);
        }
        public void Generate_should_include_debug_suffix([Values(null, "invalid")] string buildSha)
        {
            string buildBranch = "build_branch";

            AppTitleGenerator.Initialise(buildSha, buildBranch);
            var title = _appTitleGenerator.Generate("a", true, null);

            title.Should().Be($"{ShortName} (no branch) - Git Extensions");
        }
示例#3
0
        public void Generate_should_include_debug_suffix([Values(null, "invalid")] string buildSha)
        {
            string buildBranch = "build_branch";

            AppTitleGenerator.Initialise(buildSha, buildBranch);
            string title = _appTitleGenerator.Generate("a", true, null);

            title.Should().Be($"{MockRepositoryDescriptionProvider.ShortName} (no branch) - {AppSettings.ApplicationName} [DEBUG]");
        }
        public void Generate_should_include_build_suffix()
        {
            string buildSha    = "1234567812345678123456781234567812345678";
            string buildBranch = "build_branch";

            AppTitleGenerator.Initialise(buildSha, buildBranch);
            var title = _appTitleGenerator.Generate("a", true, null);

            title.Should().Be($"{ShortName} (no branch) - Git Extensions @{buildSha.Substring(0, 8)} [{buildBranch}]");
        }
示例#5
0
        public void Generate_should_include_build_suffix()
        {
            string buildSha    = "1234567812345678123456781234567812345678";
            string buildBranch = "build_branch";

            AppTitleGenerator.Initialise(buildSha, buildBranch);
            string title = _appTitleGenerator.Generate("a", true, null);

            title.Should().Be($"{MockRepositoryDescriptionProvider.ShortName} (no branch) - {AppSettings.ApplicationName} {buildSha.Substring(0, 8)} ({buildBranch})");
        }
示例#6
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();
        }
示例#7
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();
        }
示例#8
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();
        }