Ejemplo n.º 1
0
        public async void Start()
        {
            var project = _studio.GetDefaultProject();

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

            bool success = false;

            success = await _studio.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));

                _studio.CurrentPerspective = Perspective.Debugging;

                DebugSessionStarted?.Invoke(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 2
0
        public ProjectViewModel(ISolutionParentViewModel parent, IProject model)
            : base(parent, model)
        {
            studio = IoC.Get<IStudio>();
            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.CreateFromTask(async () => await studio.BuildAsync(model));

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

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

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

                studio.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.ShowDialogAsync();
            });

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

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