コード例 #1
0
        public async void Start()
        {
            var project = _shell.GetDefaultProject();

            if (project == null)
            {
                OnEndSession();
                _console.WriteLine("No Default project set. Please set a default project before debugging.");
                return;
            }

            bool success = false;

            success = await _shell.BuildAsync(project);

            if (!success)
            {
                OnEndSession();
                return;
            }

            if (project.Debugger2 == null)
            {
                OnEndSession();
                _console.WriteLine("No Debug adaptor is set for default project.");
                return;
            }

            var debugger2 = project.Debugger2 as IDebugger2;

            if (await debugger2.InstallAsync(IoC.Get <IConsole>(), project))
            {
                _session = debugger2.CreateSession(project);

                _session.TargetUnhandledException += _session_TargetStopped;
                _session.TargetStopped            += _session_TargetStopped;
                _session.TargetHitBreakpoint      += _session_TargetStopped;
                _session.TargetSignaled           += _session_TargetStopped;
                _session.TargetInterrupted        += _session_TargetStopped;
                _session.TargetExited             += _session_TargetExited;
                _session.TargetStarted            += _session_TargetStarted;
                _session.TargetReady += _session_TargetReady;

                _session.Breakpoints = Breakpoints;

                _session.Run(debugger2.GetDebuggerStartInfo(project), debugger2.GetDebuggerSessionOptions(project));

                _shell.CurrentPerspective = Perspective.Debug;

                DebugSessionStarted?.Invoke(this, EventArgs.Empty);
            }
        }
コード例 #2
0
        public ProjectViewModel(ISolutionParentViewModel parent, IProject model)
            : base(parent, model)
        {
            shell = IoC.Get <IShell>();

            Items = new ObservableCollection <ProjectItemViewModel>();

            Items.BindCollections(model.Items, p => { return(ProjectItemViewModel.Create(p)); }, (pivm, p) => pivm.Model == p);

            ConfigureCommand = ReactiveCommand.Create(() =>
            {
                if (configuration == null)
                {
                    configuration = new ProjectConfigurationDialogViewModel(model, () =>
                    {
                        configuration = null;
                    });

                    shell.AddDocument(configuration, false);
                }
                else
                {
                    shell.SelectedDocument = configuration;
                }
                //shell.ModalDialog.ShowDialog();
            });

            DebugCommand = ReactiveCommand.Create(() =>
            {
                //shell.Debug(model);
            });

            BuildCommand = ReactiveCommand.Create(async() => await shell.BuildAsync(model));

            CleanCommand = ReactiveCommand.Create(() => shell.Clean(model));

            ManageReferencesCommand = ReactiveCommand.Create(() => { });

            SetProjectCommand = ReactiveCommand.Create(() =>
            {
                model.Solution.StartupProject = model;
                model.Solution.Save();

                shell.InvalidateCodeAnalysis();

                var root = this.FindRoot();

                if (root != null)
                {
                    root.VisitChildren(solutionItem =>
                    {
                        solutionItem.RaisePropertyChanged(nameof(FontWeight));
                    });
                }
            });

            OpenInExplorerCommand = ReactiveCommand.Create(() => Platform.OpenFolderInExplorer(Model.CurrentDirectory));

            NewItemCommand = ReactiveCommand.Create(() =>
            {
                shell.ModalDialog = new NewItemDialogViewModel(model);
                shell.ModalDialog.ShowDialog();
            });

            RemoveCommand = ReactiveCommand.Create(() =>
            {
                shell.CloseDocumentsForProject(Model);
                Model.Solution.RemoveItem(Model);
                Model.Solution.Save();
            });

            DevConsoleCommand = ReactiveCommand.Create(() =>
            {
                PlatformSupport.LaunchShell(Model.CurrentDirectory, Model.ToolChain?.BinDirectory, Model.Debugger2?.BinDirectory);
            });
        }