////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public override bool CanLaunch(DebugLaunchOptions launchOptions)
        {
            LoggingUtils.PrintFunction();

            IDebugLauncher debugLauncher = null;

            try
            {
                debugLauncher = GetDebugLauncher(ServiceProvider);

                return(debugLauncher.CanLaunch((int)launchOptions));
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                string description = string.Format("'CanLaunch' failed:\n[Exception]{0}", e.Message);

#if DEBUG
                description += "\n[Exception] Stack trace:\n" + e.StackTrace;
#endif

                if (debugLauncher != null)
                {
                    LoggingUtils.RequireOk(debugLauncher.GetConnectionService().LaunchDialogUpdate(description, true));
                }

                VsShellUtilities.ShowMessageBox(ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }

            return(false);
        }
Example #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private async Task <int> HandleExceptionDialog(Exception e, IDebugLauncher debugLauncher)
        {
            LoggingUtils.HandleException(e);

            string description = string.Format(CultureInfo.InvariantCulture, "[{0}] {1}", e.GetType(), e.Message);

            description += "\nStack trace:\n" + e.StackTrace;

            await debugLauncher?.GetConnectionService().LaunchDialogUpdate(description, true);

            return(VsShellUtilities.ShowMessageBox(ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST));
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public override IDebugLaunchSettings [] QueryDebugTargets(DebugLaunchOptions launchOptions)
        {
            LoggingUtils.PrintFunction();

            IDebugLauncher debugLauncher = null;

            try
            {
                debugLauncher = GetDebugLauncher(ServiceProvider);

                debugLauncher.PrepareLaunch();

                DebugLaunchSettings debugLaunchSettings;

                Dictionary <string, string> projectProperties = DebuggerProperties.ProjectPropertiesToDictionary();

                projectProperties.Add("ConfigurationGeneral.ProjectDir", Path.GetDirectoryName(DebuggerProperties.GetConfiguredProject().UnconfiguredProject.FullPath));

                LaunchConfiguration launchConfig = debugLauncher.GetLaunchConfigurationFromProjectProperties(projectProperties);

                LaunchProps [] launchProps = debugLauncher.GetLaunchPropsFromProjectProperties(projectProperties);

                if (launchOptions.HasFlag(DebugLaunchOptions.NoDebug))
                {
                    debugLaunchSettings = (DebugLaunchSettings)debugLauncher.StartWithoutDebugging((int)launchOptions, launchConfig, launchProps, projectProperties);
                }
                else
                {
                    debugLaunchSettings = (DebugLaunchSettings)debugLauncher.StartWithDebugging((int)launchOptions, launchConfig, launchProps, projectProperties);
                }

                return(new IDebugLaunchSettings [] { debugLaunchSettings });
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                string description = string.Format("'QueryDebugTargets' failed:\n[Exception]{0}", e.Message);

#if DEBUG
                description += "\n[Exception] Stack trace:\n" + e.StackTrace;
#endif

                if (debugLauncher != null)
                {
                    LoggingUtils.RequireOk(debugLauncher.GetConnectionService().LaunchDialogUpdate(description, true));
                }

                VsShellUtilities.ShowMessageBox(ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }

            return(null);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void HandleExceptionDialog(Exception e, IDebugLauncher debugLauncher)
        {
            LoggingUtils.HandleException(e);

            string description = string.Format("[{0}] {1}", e.GetType(), e.Message);

            description += "\nStack trace:\n" + e.StackTrace;

            if (debugLauncher != null)
            {
                LoggingUtils.RequireOk(debugLauncher.GetConnectionService().LaunchDialogUpdate(description, true));
            }

            VsShellUtilities.ShowMessageBox(ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    private void HandleExceptionDialog (Exception e, IDebugLauncher debugLauncher)
    {
      LoggingUtils.HandleException(e);

      string description = string.Format(CultureInfo.InvariantCulture, "[{0}] {1}", e.GetType(), e.Message);

      description += "\nStack trace:\n" + e.StackTrace;

      if (debugLauncher != null)
      {
        LoggingUtils.RequireOk(debugLauncher.GetConnectionService().LaunchDialogUpdate(description, true));
      }

      VsShellUtilities.ShowMessageBox(ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
    }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public IEnumerable <IDebugLaunchSettings> PrepareLaunch(DebugLaunchOptions launchOptions, IDictionary <string, string> projectProperties)
        {
            LoggingUtils.PrintFunction();

            IDebugLauncher debugLauncher = null;

            try
            {
                debugLauncher = GetDebugLauncher(ServiceProvider);

                debugLauncher.PrepareLaunch();

                DebugLaunchSettings debugLaunchSettings = null;

                Project startupProject = GetStartupSolutionProject(ServiceProvider, (Dictionary <string, string>)projectProperties);

                if (startupProject == null)
                {
                    throw new InvalidOperationException("Could not find solution startup project.");
                }

                LoggingUtils.Print("Launcher startup project: " + startupProject.Name + " (" + startupProject.FullName + ")");

                LaunchConfiguration launchConfig = debugLauncher.GetLaunchConfigurationFromProjectProperties(projectProperties, startupProject);

                LaunchProps [] launchProps = debugLauncher.GetLaunchPropsFromProjectProperties(projectProperties, startupProject);

                if (launchOptions.HasFlag(DebugLaunchOptions.NoDebug))
                {
                    debugLaunchSettings = (DebugLaunchSettings)debugLauncher.StartWithoutDebugging((int)launchOptions, launchConfig, launchProps, projectProperties);
                }
                else
                {
                    debugLaunchSettings = (DebugLaunchSettings)debugLauncher.StartWithDebugging((int)launchOptions, launchConfig, launchProps, projectProperties);
                }

                if (debugLaunchSettings == null)
                {
                    throw new InvalidOperationException("Could not evaluate valid launch settings.");
                }

                return(new IDebugLaunchSettings [] { debugLaunchSettings });
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                string description = string.Format("'PrepareLaunch' failed:\n[Exception] {0}", e.Message);

#if DEBUG
                description += "\n[Exception] Stack trace:\n" + e.StackTrace;
#endif

                if (debugLauncher != null)
                {
                    LoggingUtils.RequireOk(debugLauncher.GetConnectionService().LaunchDialogUpdate(description, true));
                }

                VsShellUtilities.ShowMessageBox(ServiceProvider, description, "Android++ Debugger", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }

            return(null);
        }