コード例 #1
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void OnInitialize()
        {
            RegisterEditorFactory(new RomEditorFactory());
            RegisterEditorFactory(new TzxEditorFactory());
            RegisterEditorFactory(new TapEditorFactory());

            // --- Let's create the ZX Spectrum virtual machine view model
            // --- that is used all around in tool windows
            CodeDiscoverySolution = new SolutionStructure();

            // --- Prepare for package shutdown
            _packageDteEvents = ApplicationObject.Events.DTEEvents;
            _packageDteEvents.OnBeginShutdown += () =>
            {
                Messenger.Default.Send(new PackageShutdownMessage());
            };
            _solutionEvents               = ApplicationObject.Events.SolutionEvents;
            _solutionEvents.Opened       += OnSolutionOpened;
            _solutionEvents.AfterClosing += OnSolutionClosed;

            // --- Create other helper objects
            CodeManager = new Z80CodeManager();
            ErrorList   = new ErrorListWindow();
            TaskList    = new TaskListWindow();
        }
コード例 #2
0
 public GenerateNuspecsTask(SolutionStructure solution, string configuration, string version, bool skipCoreProject)
 {
     _solution        = solution;
     _configuration   = configuration;
     _version         = version;
     _skipCoreProject = skipCoreProject;
 }
コード例 #3
0
        /// <summary>
        /// Initializes the members used by a solution
        /// </summary>
        private void OnSolutionOpened()
        {
            CheckCpsFiles();

            // --- Let's create the ZX Spectrum virtual machine view model
            // --- that is used all around in tool windows
            CodeDiscoverySolution = new SolutionStructure();
            CodeDiscoverySolution.CollectProjects();

            // --- Every time a new solution has been opened, initialize the
            // --- Spectrum virtual machine with all of its accessories
            var vm = MachineViewModel = CreateProjectMachine();

            // --- Set up the debug info provider
            DebugInfoProvider.Prepare();
            vm.DebugInfoProvider = DebugInfoProvider;

            // --- Prepare the virtual machine
            vm.PrepareStartupConfig();
            vm.MachineController.EnsureMachine();

            SolutionOpened?.Invoke(this, EventArgs.Empty);

            // --- Let initialize these tool windows even before showing up them
            GetToolWindow(typeof(SpectrumEmulatorToolWindow));
            GetToolWindow(typeof(AssemblerOutputToolWindow));
            GetToolWindow(typeof(MemoryToolWindow));
            GetToolWindow(typeof(DisassemblyToolWindow));
        }
コード例 #4
0
        public static SolutionStructure GetProjectStructureRecursive(DTE dte)
        {
            EnvDTE.Solution solution         = dte.Solution;
            EnvDTE.Projects solutionProjects = solution.Projects;

            List <Guid> guids = new List <Guid>();

            SolutionStructure projectStructure = new SolutionStructure();

            foreach (Project project in solutionProjects)
            {
                try
                {
                    if (project.Kind == EnvDTE.Constants.vsProjectKindUnmodeled)                     // not loaded
                    {
                        continue;
                    }

                    // check it's a c/c++ project
                    if (project.CodeModel != null)
                    {
                        if (project.CodeModel.Language != CodeModelLanguageConstants.vsCMLanguageVC)
                        {
                            continue;
                        }
                    }

                    if (project.Kind == "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}")
                    {
                        SolutionStructure.ProjectNode projectNode = new SolutionStructure.ProjectNode();
                        projectNode.Name    = project.Name;
                        projectNode.Project = project;
                        projectNode.Include = false;

                        projectStructure.Nodes.Add(projectNode);
                    }
                    else
                    {
                        SolutionStructure.Node folderNode = GetSubProjects(project);

                        if (folderNode != null)
                        {
                            projectStructure.Nodes.Add(folderNode);
                        }
                        else
                        {
                            Logging.Logging.LogWarning("Subnode was NULL");
                        }
                    }
                }
                catch (Exception e)
                {
                    Logging.Logging.LogError("Exception: " + e.Message);
                }
            }

            return(projectStructure);
        }
コード例 #5
0
        /// <summary>
        /// Initializes the members used by a solution
        /// </summary>
        private void OnSolutionOpened()
        {
            CheckCpsFiles();

            // --- Let's create the ZX Spectrum virtual machine view model
            // --- that is used all around in tool windows
            CodeDiscoverySolution = new SolutionStructure();
            CodeDiscoverySolution.CollectProjects();

            // --- Every time a new solution has been opened, initialize the
            // --- Spectrum virtual machine with all of its accessories
            var spectrumConfig = CodeDiscoverySolution.CurrentProject.SpectrumConfiguration;
            var vm             = MachineViewModel = new MachineViewModel();

            vm.MachineController   = new MachineController();
            vm.ScreenConfiguration = spectrumConfig.Screen;

            // --- Create devices according to the project's Spectrum model
            var modelName = CodeDiscoverySolution.CurrentProject.ModelName;

            switch (modelName)
            {
            case SpectrumModels.ZX_SPECTRUM_128:
                vm.DeviceData = CreateSpectrum128Devices(spectrumConfig);
                break;

            case SpectrumModels.ZX_SPECTRUM_P3_E:
                vm.DeviceData = CreateSpectrumP3Devices(spectrumConfig);
                break;

            case SpectrumModels.ZX_SPECTRUM_NEXT:
                vm.DeviceData = CreateSpectrum48Devices(spectrumConfig);
                break;

            default:
                vm.DeviceData = CreateSpectrum48Devices(spectrumConfig);
                break;
            }

            vm.AllowKeyboardScan = true;
            vm.StackDebugSupport = new SimpleStackDebugSupport();
            vm.DisplayMode       = SpectrumDisplayMode.Fit;

            // --- Set up the debug info provider
            DebugInfoProvider.Prepare();
            vm.DebugInfoProvider = DebugInfoProvider;

            // --- Prepare the virtual machine
            vm.PrepareStartupConfig();
            vm.MachineController.EnsureMachine();
            SolutionOpened?.Invoke(this, EventArgs.Empty);

            // --- Let initializethese tool windows even before showing up them
            GetToolWindow(typeof(AssemblerOutputToolWindow));
            GetToolWindow(typeof(MemoryToolWindow));
            GetToolWindow(typeof(DisassemblyToolWindow));
        }
コード例 #6
0
        static public List <EnvDTE.Project> GetSolutionProjectList(DTE dte)
        {
            List <EnvDTE.Project> solutionProjects = new List <EnvDTE.Project>();

            try
            {
                SolutionStructure solutionStructure = GetProjectStructureRecursive(dte);

                Stack <SolutionStructure.Node> nodeStack = new Stack <Utility.SolutionUtility.SolutionStructure.Node>();
                foreach (SolutionStructure.Node node in solutionStructure.Nodes)
                {
                    nodeStack.Push(node);
                }

                while (nodeStack.Count > 0)
                {
                    Utility.SolutionUtility.SolutionStructure.Node node = nodeStack.Pop();

                    string name = node.Name;

                    if (node.GetNodeType() == Utility.SolutionUtility.SolutionStructure.Node.NodeType.PROJECT)
                    {
                        solutionProjects.Add(node.Project);
                    }
                    else if (node.GetNodeType() == Utility.SolutionUtility.SolutionStructure.Node.NodeType.FOLDER)
                    {
                        Utility.SolutionUtility.SolutionStructure.FolderNode folderNode = node as Utility.SolutionUtility.SolutionStructure.FolderNode;
                        foreach (Utility.SolutionUtility.SolutionStructure.Node subNode in folderNode.SubNodes)
                        {
                            nodeStack.Push(subNode);
                        }
                    }
                }

                return(solutionProjects);
            }
            catch (Exception e)
            {
                Logging.Logging.LogError("Exception: " + e.Message);

                return(new List <EnvDTE.Project>());
            }
        }
コード例 #7
0
        /// <summary>
        /// Initializes the members used by a solution
        /// </summary>
        private async void OnSolutionOpened()
        {
            try
            {
                CheckCpsFiles();
                await Task.Delay(2000);

                // --- Let's create the ZX Spectrum virtual machine view model
                // --- that is used all around in tool windows
                CodeDiscoverySolution = new SolutionStructure();
                CodeDiscoverySolution.CollectProjects();


                // --- Every time a new solution has been opened, initialize the
                // --- Spectrum virtual machine with all of its accessories
                var vm = MachineViewModel = CreateProjectMachine();

                // --- Create an expression evaluation context and bind the machine with it
                DebugEvaluationContext = new SymbolAwareSpectrumEvaluationContext(vm.SpectrumVm);

                // --- Set up the debug info provider
                DebugInfoProvider.Prepare();
                vm.DebugInfoProvider = DebugInfoProvider;

                SolutionOpened?.Invoke(this, EventArgs.Empty);

                // --- Let initialize these tool windows even before showing up them
                GetToolWindow(typeof(SpectrumEmulatorToolWindow));
                GetToolWindow(typeof(AssemblerOutputToolWindow));
                GetToolWindow(typeof(MemoryToolWindow));
                GetToolWindow(typeof(DisassemblyToolWindow));
                GetToolWindow(typeof(WatchToolWindow));
            }
            catch (Exception e)
            {
                if (!(GetService(typeof(SVsActivityLog)) is IVsActivityLog log))
                {
                    return;
                }
                log.LogEntry((uint)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR,
                             "OnSolutionOpen", $"Exception raised: {e}");
            }
        }
コード例 #8
0
        protected override void RegisterTasks()
        {
            //// ----------------------------------------------------------------------------------------------------------------------------
            var initTask = Task(
                "Init the workflow",
                context =>
            {
                IDirectory currentDirectory = WorkDirectory.Closest(dir => dir.Name.Equals("src", StringComparison.InvariantCultureIgnoreCase));

                if (currentDirectory == null)
                {
                    throw new Exception("Could not find Src directory " + WorkDirectory);
                }

                IDirectory artifacts = currentDirectory.Parent / "Artifacts";
                artifacts.EnsureExists();
                artifacts.Files.IncludeByExtension("nupkg", "nuspec").DeleteAll();

                IDirectory mergedBin = currentDirectory.Parent / "bin" / "Merged";
                mergedBin.EnsureExists();

                var solutionStructure = new SolutionStructure(currentDirectory.Parent);

                IFile versionNumberFile = solutionStructure.Src / "version.txt";

                return(new
                {
                    Version = versionNumberFile.Exists ? versionNumberFile.ReadAllText().Trim() : "1.0.0.0",
                    Configuration = "Release",
                    Solution = solutionStructure,
                    SkipCoreProject = context.Environment.IsMono
                }.AsTaskResult());
            });

            //// ----------------------------------------------------------------------------------------------------------------------------

            var generateCommonAssemblyInfo = Task(
                "Generate common assembly info",
                from data in initTask
                select new GenerateAssemblyInfo(data.Solution.Src / "CommonAssemblyInfo.cs")
            {
                Attributes =
                {
                    _ => new AssemblyProductAttribute("CrystalQuartz"),
                    _ => new AssemblyVersionAttribute(data.Version),
                    _ => new AssemblyFileVersionAttribute(data.Version)
                }
            });

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildClient = Task(
                "BuildClient",
                from data in initTask
                select new CompileClientAssets(data.Solution, data.Version).AsSubflow());

            //// ----------------------------------------------------------------------------------------------------------------------------

            var copyGhPagesAssets = Task(
                "CopyAssetsToGhPagesArtifacts",
                from data in initTask
                select c =>
            {
                (data.Solution.Root / "_gh-pages-assets").AsDirectory().SearchFilesRecursively().CopyRelativelyTo(data.Solution.Artifacts / "gh-pages");
            });

            //// ----------------------------------------------------------------------------------------------------------------------------

            var restoreNugetPackages = Task(
                "RestoreNugetPackages",
                from data in initTask
                select new ExecTask
            {
                ToolPath  = data.Solution.Src / ".nuget" / "NuGet.exe",
                Arguments = "restore " + (data.Solution.Src / "CrystalQuartz.sln").AsFile().AbsolutePath + " -Verbosity quiet"
            }.AsTask());

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildSolution = Task(
                "Build solution",
                from data in initTask
                select new CustomMsBuildTask
            {
                ProjectFile = data.Solution.Src / "CrystalQuartz.sln",
                Switches    =
                {
                    MsBuildSwitch.Configuration(data.Configuration),
                    MsBuildSwitch.VerbosityQuiet()
                }
            }

                .AsTask(),

                DependsOn(restoreNugetPackages),
                DependsOn(generateCommonAssemblyInfo),
                DependsOn(buildClient));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildCoreSolution = Task(
                "Build Core projects",
                from data in initTask
                select new ExecTask
            {
                ToolPath  = "dotnet",
                Arguments = "build " + (data.Solution.Src / "CrystalQuartz.AspNetCore" / "CrystalQuartz.AspNetCore.csproj") + " --verbosity quiet --configuration " + data.Configuration
            }

                .AsTask(),

                DependsOn(buildSolution),
                DependsOn(restoreNugetPackages),
                DependsOn(generateCommonAssemblyInfo),
                DependsOn(buildClient));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var cleanArtifacts = Task(
                "Clean artifacts",
                from data in initTask
                select _ => data.Solution.Artifacts.Files.IncludeByExtension("nupkg", "nuspec").DeleteAll());

            //// ----------------------------------------------------------------------------------------------------------------------------

            var mergeBinaries = Task(
                "MergeBinaries",

                from data in initTask
                select new MergeBinariesTask(data.Solution, data.Configuration, data.SkipCoreProject).AsSubflow(),

                DependsOn(buildSolution),
                DependsOn(buildCoreSolution));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var generateNuspecs = Task(
                "GenerateNuspecs",
                from data in initTask
                select new GenerateNuspecsTask(data.Solution, data.Configuration, data.Version + "-beta", data.SkipCoreProject),

                DependsOn(cleanArtifacts),
                DependsOn(mergeBinaries));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildPackages = Task(
                "BuildPackages",
                from data in initTask
                select ForEach(data.Solution.Artifacts.Files.IncludeByExtension(".nuspec")).Do(
                    nuspec => new GeneratePackageTask(nuspec)
            {
                WorkDirectory = data.Solution.Artifacts,
                ToolPath      = data.Solution.Src / ".nuget" / "NuGet.exe"
            },
                    nuspec => string.Format("Generate NuGet package for {0}", nuspec.NameWithoutExtension)),

                DependsOn(generateNuspecs));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildDocs = Task(
                "BuildDocs",
                from data in initTask
                select new CompileDocsTask(data.Solution, data.Version).AsSubflow(),

                DependsOn(buildClient));

            //// ----------------------------------------------------------------------------------------------------------------------------

            Task(
                "DevBuild",
                () => { },

                Default(),
                DependsOn(buildClient),
                DependsOn(buildPackages),
                DependsOn(copyGhPagesAssets),
                DependsOn(buildDocs));

            //// ----------------------------------------------------------------------------------------------------------------------------
            ///
            Task(
                "CiBuild",
                () => { },

                DependsOn(buildPackages),
                DependsOn(copyGhPagesAssets),
                DependsOn(buildDocs));

            //// ----------------------------------------------------------------------------------------------------------------------------

            Task(
                "PushPackages",

                from data in initTask
                select
                ForEach(data.Solution.Artifacts.Files.IncludeByExtension("nupkg")).Do(
                    package => new ExecTask
            {
                WorkDirectory = data.Solution.Artifacts,
                ToolPath      = data.Solution.Src / ".nuget" / "NuGet.exe",
                Arguments     = "push " + package.AbsolutePath + " -Source https://api.nuget.org/v3/index.json -NonInteractive"
            },
                    package => "Push" + package.NameWithoutExtension),

                DependsOn(buildPackages));
        }
コード例 #9
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            // --- Background initialization part
            Default = this;

            // --- Prepare project system extension files
            CheckCpsFiles();

            Z80AsmLanguage = new Z80AsmLanguageService(this);

            // --- Special providers for the ZX Spectrum virtual machine
            DebugInfoProvider = new VsIntegratedSpectrumDebugInfoProvider();
            SpectrumMachine.Reset();
            SpectrumMachine.RegisterDefaultProviders();
            SpectrumMachine.RegisterProvider <IRomProvider>(() => new PackageRomProvider());
            SpectrumMachine.RegisterProvider <IBeeperProvider>(() => new AudioWaveProvider());
            SpectrumMachine.RegisterProvider <ISoundProvider>(() => new AudioWaveProvider(AudioProviderType.Psg));
            SpectrumMachine.RegisterProvider <ITapeLoadProvider>(() => new VsIntegratedTapeLoadProvider());
            SpectrumMachine.RegisterProvider <ITapeSaveProvider>(() => new VsIntegratedTapeSaveProvider());
            SpectrumMachine.RegisterProvider <IKempstonProvider>(() => new KempstonProvider());
            SpectrumMachine.RegisterProvider <ISpectrumDebugInfoProvider>(() => DebugInfoProvider);
            SpectrumMachine.RegisterStackDebugSupport(new SimpleStackDebugSupport());

            // --- Initialize other services
            BreakpointChangeWatcher = new BreakpointChangeWatcher();
            BreakpointChangeWatcher.Start();

            // --- Main thread initialization part
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            // --- Initialize the package here
            InitializeCommands();

            // --- Register custom editors
            RegisterEditorFactory(new RomEditorFactory());
            RegisterEditorFactory(new TzxEditorFactory());
            RegisterEditorFactory(new TapEditorFactory());

            // --- Manage the solution and its events
            Solution = new SolutionStructure();
            Solution.ActiveProjectChanged += OnActiveProjectChanged;
            ErrorList = new ErrorListWindow();
            TaskList  = new TaskListWindow();

            // --- Create view models
            EmulatorViewModel    = new EmulatorViewModel();
            SpectrumViewModel    = new SpectrumEmulatorToolWindowViewModel();
            KeyboardToolModel    = new KeyboardToolWindowViewModel();
            RegistersViewModel   = new RegistersToolWindowViewModel();
            MemoryViewModel      = new MemoryToolWindowViewModel();
            DisassemblyViewModel = new DisassemblyToolWindowViewModel();
            StackViewModel       = new StackToolWindowViewModel();
            BasicListViewModel   = new BasicListToolWindowViewModel();
            WatchViewModel       = new WatchToolWindowViewModel();

            // --- Prepare the provider for debugging
            DebugInfoProvider.Prepare();

            // --- Prepare language services
            Z80AsmClassifierProvider.AttachToPackage();
            Z80AsmViewTaggerProvider.AttachToPackage();
            Log("SpectNetIdePackage initialized.");
        }
コード例 #10
0
 public MergeBinariesTask(SolutionStructure solution, string configuration, bool skipCore)
 {
     _solution      = solution;
     _configuration = configuration;
     _skipCore      = skipCore;
 }
コード例 #11
0
 public MergeBinariesTask(SolutionStructure solution, string configuration)
 {
     _solution      = solution;
     _configuration = configuration;
 }
コード例 #12
0
 public GenerateNuspecsTask(SolutionStructure solution, string configuration, string version)
 {
     _solution      = solution;
     _configuration = configuration;
     _version       = version;
 }
コード例 #13
0
 public CompileClientAssets(SolutionStructure solution, string version)
 {
     _solution = solution;
     _version  = version;
 }
コード例 #14
0
 public CompileDocsTask(SolutionStructure solution, string version)
 {
     _solution = solution;
     _version  = version;
 }