Exemplo n.º 1
0
        private static async void OpenWithGameStudioMenuCommand_Callback(object sender, EventArgs e)
        {
            var dte = (DTE2)ServiceProvider.GetService(typeof(SDTE));

            var solutionFile = dte.Solution?.FileName;

            // Is there any active solution?
            if (solutionFile == null)
            {
                return;
            }

            // Locate GameStudio
            var packageInfo = await StrideCommandsProxy.FindStrideSdkDir(solutionFile, "Stride.GameStudio");

            if (packageInfo.LoadedVersion == null || packageInfo.SdkPaths.Count == 0)
            {
                return;
            }

            var mainExecutable = packageInfo.SdkPaths.First(x => Path.GetFileName(x) == "Stride.GameStudio.exe");

            if (mainExecutable == null)
            {
                throw new InvalidOperationException("Could not locate GameStudio process");
            }
            if (Process.Start(mainExecutable, $"\"{solutionFile}\"") == null)
            {
                throw new InvalidOperationException("Could not start GameStudio process");
            }
        }
Exemplo n.º 2
0
        private void solutionEventsListener_BeforeSolutionClosed()
        {
            // Disable UIContext (this will hide Stride menus)
            UpdateCommandVisibilityContext(false);

            StrideCommandsProxy.CloseSolution();
        }
Exemplo n.º 3
0
        protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
        {
            try
            {
                return(System.Threading.Tasks.Task.Run(() =>
                {
                    var remoteCommands = StrideCommandsProxy.GetProxy();
                    return remoteCommands.GenerateShaderKeys(inputFileName, inputFileContent);
                }).Result);
            }
            catch (Exception ex)
            {
                GeneratorError(4, ex.ToString(), 0, 0);

                return(null);
            }
        }
Exemplo n.º 4
0
        private void AnalyzeAndGoToDefinition()
        {
            int line;
            int column;

            TextView.GetCaretPos(out line, out column);

            IVsTextLines buffer;

            TextView.GetBuffer(out buffer);

            var span = new TextSpan();

            buffer.GetLastLineIndex(out span.iEndLine, out span.iEndIndex);

            string text;

            buffer.GetLineText(span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex, out text);

            try
            {
                var remoteCommands = StrideCommandsProxy.GetProxy();
                if (remoteCommands == null)
                {
                    return;
                }
                var location = new RawSourceSpan()
                {
                    File   = this.Source.GetFilePath(),
                    Column = column + 1,
                    Line   = line + 1
                };
                var projectFile = langService.LocateProject(location.File);
                var result      = langService.AnalyzeAndGoToDefinition(projectFile, text, location);
                langService.OutputAnalysisAndGotoLocation(result, TextView);
            }
            catch (Exception)
            {
                // TODO handle errors
            }
        }
Exemplo n.º 5
0
        private async System.Threading.Tasks.Task InitializeCommandProxy()
        {
            // Initialize the command proxy from the current solution's package
            var dte          = (DTE)GetService(typeof(DTE));
            var solutionPath = dte.Solution.FullName;

            // Get General Output pane (for error logging)
            var generalOutputPane = GetGeneralOutputPane();

            try
            {
                StrideCommandsProxy.SetSolution(solutionPath);
                var stridePackageInfo = await StrideCommandsProxy.FindStrideSdkDir(solutionPath);

                StrideCommandsProxy.SetPackageInfo(stridePackageInfo);
                if (stridePackageInfo.LoadedVersion is null)
                {
                    return;
                }

                // Enable UIContext depending on wheter it is a Stride project. This will show or hide Stride menus.
                var isStrideSolution = stridePackageInfo.LoadedVersion != null;
                UpdateCommandVisibilityContext(isStrideSolution);

                // If a package is associated with the solution, check if the correct version was found
                if (stridePackageInfo.ExpectedVersion != null && stridePackageInfo.ExpectedVersion != stridePackageInfo.LoadedVersion)
                {
                    if (stridePackageInfo.ExpectedVersion < StrideCommandsProxy.MinimumVersion)
                    {
                        // The package version is deprecated
                        generalOutputPane.OutputStringThreadSafe($"Could not initialize Stride extension for package with version {stridePackageInfo.ExpectedVersion}. Versions earlier than {StrideCommandsProxy.MinimumVersion} are not supported. Loading latest version {stridePackageInfo.LoadedVersion} instead.\r\n");
                        generalOutputPane.Activate();
                    }
                    else if (stridePackageInfo.LoadedVersion is null)
                    {
                        // No version found
                        generalOutputPane.OutputStringThreadSafe("Could not find Stride SDK directory.");
                        generalOutputPane.Activate();

                        // Don't try to create any services
                        return;
                    }
                    else
                    {
                        // The package version was not found
                        generalOutputPane.OutputStringThreadSafe($"Could not find SDK directory for Stride version {stridePackageInfo.ExpectedVersion}. Loading latest version {stridePackageInfo.LoadedVersion} instead.\r\n");
                        generalOutputPane.Activate();
                    }
                }

                // Preinitialize the parser in a separate thread
                var thread = new System.Threading.Thread(
                    () =>
                {
                    try
                    {
                        StrideCommandsProxy.GetProxy();
                    }
                    catch (Exception ex)
                    {
                        generalOutputPane.OutputStringThreadSafe($"Error Initializing Stride Language Service: {ex.InnerException ?? ex}\r\n");
                        generalOutputPane.Activate();
                    }
                });
                thread.Start();
            }
            catch (Exception ex)
            {
                // Do not crash VS Plugin if something fails
                generalOutputPane.OutputStringThreadSafe($"Error initializing Stride command proxy: {ex}\r\n");
                generalOutputPane.Activate();

                return;
            }
        }
 public RawShaderNavigationResult AnalyzeAndGoToDefinition(string projectFile, string text, RawSourceSpan span)
 {
     return(StrideCommandsProxy.GetProxy()?.AnalyzeAndGoToDefinition(projectFile, text, span) ?? new RawShaderNavigationResult());
 }
Exemplo n.º 7
0
        private async System.Threading.Tasks.Task InitializeCommandProxy()
        {
            // Initialize the command proxy from the current solution's package
            var dte          = (DTE)GetService(typeof(DTE));
            var solutionPath = dte.Solution.FullName;

            var stridePackageInfo = await StrideCommandsProxy.FindStrideSdkDir(solutionPath);

            if (stridePackageInfo.LoadedVersion == null)
            {
                return;
            }
            StrideCommandsProxy.InitializeFromSolution(solutionPath, stridePackageInfo);

            // Get General Output pane (for error logging)
            var generalOutputPane = GetGeneralOutputPane();

            // Enable UIContext depending on wheter it is a Stride project. This will show or hide Stride menus.
            var isStrideSolution = stridePackageInfo.LoadedVersion != null;

            UpdateCommandVisibilityContext(isStrideSolution);

            // If a package is associated with the solution, check if the correct version was found
            if (stridePackageInfo.ExpectedVersion != null && stridePackageInfo.ExpectedVersion != stridePackageInfo.LoadedVersion)
            {
                if (stridePackageInfo.ExpectedVersion < StrideCommandsProxy.MinimumVersion)
                {
                    // The package version is deprecated
                    generalOutputPane.OutputStringThreadSafe($"Could not initialize Stride extension for package with version {stridePackageInfo.ExpectedVersion}. Versions earlier than {StrideCommandsProxy.MinimumVersion} are not supported. Loading latest version {stridePackageInfo.LoadedVersion} instead.\r\n");
                    generalOutputPane.Activate();
                }
                else if (stridePackageInfo.LoadedVersion == null)
                {
                    // No version found
                    generalOutputPane.OutputStringThreadSafe("Could not find Stride SDK directory.");
                    generalOutputPane.Activate();

                    // Don't try to create any services
                    return;
                }
                else
                {
                    // The package version was not found
                    generalOutputPane.OutputStringThreadSafe($"Could not find SDK directory for Stride version {stridePackageInfo.ExpectedVersion}. Loading latest version {stridePackageInfo.LoadedVersion} instead.\r\n");
                    generalOutputPane.Activate();
                }
            }

            // Initialize the build monitor, that will display BuildEngine results in the Build Output pane.
            buildLogPipeGenerator = new BuildLogPipeGenerator(this);

            try
            {
                // Start PackageBuildMonitorRemote in a separate app domain
                if (buildMonitorDomain != null)
                {
                    AppDomain.Unload(buildMonitorDomain);
                }

                buildMonitorDomain = StrideCommandsProxy.CreateStrideDomain();
                StrideCommandsProxy.InitializeFromSolution(solutionPath, stridePackageInfo, buildMonitorDomain);
                var remoteCommands = StrideCommandsProxy.CreateProxy(buildMonitorDomain);
                remoteCommands.StartRemoteBuildLogServer(new BuildMonitorCallback(), buildLogPipeGenerator.LogPipeUrl);
            }
            catch (Exception e)
            {
                generalOutputPane.OutputStringThreadSafe($"Error loading Stride SDK: {e}\r\n");
                generalOutputPane.Activate();

                // Unload domain right away
                AppDomain.Unload(buildMonitorDomain);
                buildMonitorDomain = null;
            }

            // Preinitialize the parser in a separate thread
            var thread = new System.Threading.Thread(
                () =>
            {
                try
                {
                    StrideCommandsProxy.GetProxy();
                }
                catch (Exception ex)
                {
                    generalOutputPane.OutputStringThreadSafe($"Error Initializing Stride Language Service: {ex.InnerException ?? ex}\r\n");
                    generalOutputPane.Activate();
                    errorListProvider?.Tasks.Add(new ErrorTask(ex.InnerException ?? ex));
                }
            });

            thread.Start();
        }