Beispiel #1
0
        void HandleDocumentChanged(object sender, EventArgs e)
        {
            var document = Ide.IdeApp.Workbench.ActiveDocument;

            try {
                if (document == null || !document.IsFile || document.Project == null || document.Window.FindView <IDiffView> () >= 0)
                {
                    return;
                }

                var repo = VersionControlService.GetRepository(document.Project);
                if (repo == null)
                {
                    return;
                }

                var versionInfo = repo.GetVersionInfo(document.FileName, VersionInfoQueryFlags.IgnoreCache);
                if (!versionInfo.IsVersioned)
                {
                    return;
                }

                var item   = new VersionControlItem(repo, document.Project, document.FileName, false, null);
                var vcInfo = new VersionControlDocumentInfo(document.PrimaryView, item, item.Repository);
                TryAttachView <IDiffView> (document, vcInfo, DiffCommand.DiffViewHandlers);
                TryAttachView <IBlameView> (document, vcInfo, BlameCommand.BlameViewHandlers);
                TryAttachView <ILogView> (document, vcInfo, LogCommand.LogViewHandlers);
                TryAttachView <IMergeView> (document, vcInfo, MergeCommand.MergeViewHandlers);
            } catch (Exception ex) {
                // If a user is hitting this, it will show a dialog box every time they
                // switch to a document or open a document, so suppress the crash dialog
                // This bug *should* be fixed already, but it's hard to tell.
                LogReportingService.ReportUnhandledException(ex, false, true);
            }
        }
Beispiel #2
0
        void HandleException(Exception ex, bool willShutdown)
        {
            var original = LogReportingService.ReportCrashes;

            // Attempt to log the crash. If the user hasn't opted in, they will get prompted now to opt in/out.
            LogReportingService.ReportUnhandledException(ex);

            // If the user has just been prompted to enable crash reporting there is no need to display the
            // normal crash dialog this time round unless we are about to shut down.
            if (!original.HasValue && !willShutdown)
            {
                return;
            }


            string message;
            string title  = GettextCatalog.GetString("An unhandled exception has occurred.");
            var    report = LogReportingService.ReportCrashes;

            if (report.HasValue && report.Value)
            {
                message = GettextCatalog.GetString("Details of this crash have been automatically submitted for analysis.");
            }
            else
            {
                message = GettextCatalog.GetString("Details of this crash have not been submitted as error reporting is disabled.");
            }

            if (willShutdown)
            {
                message += GettextCatalog.GetString(" MonoDevelop will now close.");
            }
            MessageService.ShowException(ex, message, title);
        }
Beispiel #3
0
        protected override void Run()
        {
//			var pid = Process.GetCurrentProcess ().Id;
//			var directory = new DirectoryInfo (LogReportingService.CrashLogDirectory);
//
//			if (Platform.IsMac) {
//				var crashmonitor = Path.Combine (PropertyService.EntryAssemblyPath, "MonoDevelopLogAgent.app");
//				Process.Start (new ProcessStartInfo ("open", string.Format ("-a {0} -n --args -pid {1} -log {2} -session {3}", crashmonitor, pid, directory.FullName, SystemInformation.SessionUuid)) {
//					UseShellExecute = false,
//				});
//			}

            LogReportingService.ShouldEnableReporting = () => {
                var title = GettextCatalog.GetString("A crash has just occurred");
                var part1 = GettextCatalog.GetString("Details of this crash, along with anonymous installation " +
                                                     "information, can be uploaded to Xamarin to help diagnose the issue. " +
                                                     "Do you wish to automatically upload this information for this and future crashes?");
                var part2 = GettextCatalog.GetString("This setting can be changed in the 'Log Agent' section of the MonoDevelop preferences.");

                var result = MessageService.AskQuestion(
                    title,
                    string.Format("{0}{1}{1}{2}", part1, Environment.NewLine, part2),
                    AlertButton.No, AlertButton.Yes);

                return(result == AlertButton.Yes);
            };

            // Process cached crash reports if there are any and uploading is enabled
            LogReportingService.ProcessCache();
        }
        protected override void Run()
        {
            // Process cached crash reports if there are any and uploading is enabled
            LogReportingService.ProcessCache();

            // Attach a handler for when exceptions need to be processed
            LogReportingService.UnhandledErrorOccured = (enabled, ex, willShutdown) => {
                AlertButton[] buttons = null;
                string        message = null;
                string        title   = GettextCatalog.GetString("An error has occurred");

                if (enabled.HasValue)
                {
                    if (enabled.Value)
                    {
                        message = GettextCatalog.GetString("Details of this error have been automatically submitted for analysis.");
                    }
                    else
                    {
                        message = GettextCatalog.GetString("Details of this error have not been submitted as error reporting is disabled.");
                    }
                    if (willShutdown)
                    {
                        message += GettextCatalog.GetString(" MonoDevelop will now close.");
                    }

                    buttons = new [] { AlertButton.Ok };
                }
                else
                {
                    var part1 = GettextCatalog.GetString("Details of this error, along with anonymous installation " +
                                                         "information, can be uploaded to Xamarin to help diagnose the issue. " +
                                                         "Do you wish to automatically upload this information for this and future crashes?");
                    var part2 = GettextCatalog.GetString("This setting can be changed in the 'Log Agent' section of the MonoDevelop preferences.");
                    message = string.Format("{0}{1}{1}{2}", part1, Environment.NewLine, part2);
                    buttons = new [] { AlertButton.Never, AlertButton.ThisTimeOnly, AlertButton.Always };
                }

                var result = MessageService.ShowException(ex, message, title, buttons);
                if (enabled.HasValue)
                {
                    // In this case we will not change the value
                    return(enabled);
                }
                else if (result == AlertButton.Always)
                {
                    return(true);
                }
                else if (result == AlertButton.Never)
                {
                    return(false);
                }
                else
                {
                    // The user has decided to submit this one only
                    return(null);
                }
            };
        }
Beispiel #5
0
        void HandleException(Exception ex, bool willShutdown)
        {
            // Log the crash to the MonoDevelop.log file first:
            LoggingService.LogError(string.Format("An unhandled exception has occured. Terminating MonoDevelop? {0}", willShutdown), ex);

            // Pass it off to the reporting service now.
            LogReportingService.ReportUnhandledException(ex, willShutdown);
        }
        protected override void Run()
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                // Process cached crash reports if there are any and uploading is enabled
                LogReportingService.ProcessCache();
            });

            // Attach a handler for when exceptions need to be processed
            LogReportingService.UnhandledErrorOccured = (enabled, ex, willShutdown) =>
            {
                var doNotSend  = new AlertButton(GettextCatalog.GetString("Do _Not Send"));
                var sendOnce   = new AlertButton(GettextCatalog.GetString("_Send This Time"));
                var alwaysSend = new AlertButton(GettextCatalog.GetString("_Always Send"));

                string message = null;
                string title   = willShutdown
            ? GettextCatalog.GetString("A fatal error has occurred")
            : GettextCatalog.GetString("An error has occurred");

                if (!ShouldPromptToOptIn && enabled.GetValueOrDefault())
                {
                    message = GettextCatalog.GetString(
                        "Details of this error have been automatically sent to Xamarin for analysis.");
                    if (willShutdown)
                    {
                        message += GettextCatalog.GetString(" {0} will now close.", BrandingService.ApplicationName);
                    }
                    MessageService.ShowException(ex, message, title, AlertButton.Ok);
                    return(enabled);
                }

                message = GettextCatalog.GetString(
                    "Details of errors, along with anonymous installation information, can be sent to Xamarin to " +
                    "help improve {0}. Do you wish to send this information?", BrandingService.ApplicationName);
                var result = MessageService.ShowException(ex, message, title, doNotSend, sendOnce, alwaysSend);

                if (result == sendOnce)
                {
                    return(null);
                }
                else if (result == alwaysSend)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
        }