diff --git a/build/Stride.sln b/build/Stride.sln index a31a91113..bf9210651 100644 --- a/build/Stride.sln +++ b/build/Stride.sln @@ -263,8 +263,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.Core.Presentation.Qu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.Code.Tests", "..\sources\tools\Stride.Code.Tests\Stride.Code.Tests.csproj", "{3C855DB2-EEA3-415C-A0A8-C834DEC40531}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Stride.Core.VisualStudio", "..\sources\tools\Stride.Core.VisualStudio\Stride.Core.VisualStudio.shproj", "{991E796A-D1D1-48B8-B9AA-95C2744FE112}" -EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Stride.Core.Assets.Yaml", "..\sources\assets\Stride.Core.Assets.Yaml\Stride.Core.Assets.Yaml.shproj", "{FB9ED2C4-94A0-4004-A498-3F29A9D5BB5D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.Navigation", "..\sources\engine\Stride.Navigation\Stride.Navigation.csproj", "{FBE1FA7B-E699-4BB2-9C8F-41F4C9F3F088}" @@ -336,41 +334,6 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stride.Engine.NoAssets.Tests.Windows", "..\sources\engine\Stride.Engine.NoAssets.Tests\Stride.Engine.NoAssets.Tests.Windows.csproj", "{1C94168A-3C0D-4C6B-883B-91627D2EF3A1}" EndProject Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{00b72ed7-00e9-47f7-868d-8162027cd068}*SharedItemsImports = 13 - ..\sources\assets\Stride.Core.Assets.Yaml\Stride.Core.Assets.Yaml.projitems*{1e54a9a2-4439-4444-ae57-6d2ed3c0dc47}*SharedItemsImports = 5 - ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{1e54a9a2-4439-4444-ae57-6d2ed3c0dc47}*SharedItemsImports = 5 - ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{2fc40214-a4aa-45dc-9c93-72ed800c40b0}*SharedItemsImports = 5 - ..\sources\editor\Stride.Editor.CrashReport\Stride.Editor.CrashReport.projitems*{2fca2d8b-b10f-4dca-9847-4221f74ba586}*SharedItemsImports = 5 - ..\sources\editor\Stride.PrivacyPolicy\Stride.PrivacyPolicy.projitems*{2fca2d8b-b10f-4dca-9847-4221f74ba586}*SharedItemsImports = 5 - ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{2fca2d8b-b10f-4dca-9847-4221f74ba586}*SharedItemsImports = 5 - ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{2fca2d8b-b10f-4dca-9847-4221f74ba586}*SharedItemsImports = 5 - ..\sources\tools\Stride.Core.VisualStudio\Stride.Core.VisualStudio.projitems*{2fca2d8b-b10f-4dca-9847-4221f74ba586}*SharedItemsImports = 5 - ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{39ae9c77-e94b-404f-8768-b6261b3c1e0e}*SharedItemsImports = 5 - ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{3a3cb33c-64d9-4948-86c1-0d86320d23c3}*SharedItemsImports = 13 - ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{50d1a3bb-4b41-4ef5-8d2f-3618a3b6c698}*SharedItemsImports = 5 - ..\sources\tools\Stride.Core.VisualStudio\Stride.Core.VisualStudio.projitems*{50d1a3bb-4b41-4ef5-8d2f-3618a3b6c698}*SharedItemsImports = 5 - ..\sources\editor\Stride.Core.MostRecentlyUsedFiles\Stride.Core.MostRecentlyUsedFiles.projitems*{5863574d-7a55-49bc-8e65-babb74d8e66e}*SharedItemsImports = 5 - ..\sources\tools\Stride.Core.VisualStudio\Stride.Core.VisualStudio.projitems*{5bfe4386-3c42-4118-96c8-4b68441f1661}*SharedItemsImports = 5 - ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{75d71310-ecf7-4592-9e35-3fe540040982}*SharedItemsImports = 5 - ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{75d71310-ecf7-4592-9e35-3fe540040982}*SharedItemsImports = 5 - ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{77e2fcc0-4ca6-436c-be6f-9418cb807d45}*SharedItemsImports = 5 - ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{77e2fcc0-4ca6-436c-be6f-9418cb807d45}*SharedItemsImports = 5 - ..\sources\engine\Stride.Shared\Refactor\Stride.Refactor.projitems*{7af4b563-aad3-42ff-b91e-84b9d34d904a}*SharedItemsImports = 5 - ..\sources\editor\Stride.PrivacyPolicy\Stride.PrivacyPolicy.projitems*{950badd0-ad5a-4f58-87ec-4adaecbea89b}*SharedItemsImports = 13 - ..\sources\tools\Stride.Core.VisualStudio\Stride.Core.VisualStudio.projitems*{991e796a-d1d1-48b8-b9aa-95c2744fe112}*SharedItemsImports = 13 - ..\sources\editor\Stride.Core.MostRecentlyUsedFiles\Stride.Core.MostRecentlyUsedFiles.projitems*{9ac6d791-811e-4d6a-b08e-93f0093ef268}*SharedItemsImports = 13 - ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{a5dc820b-9554-45b6-9677-6a2f902e7787}*SharedItemsImports = 5 - ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{a5dc820b-9554-45b6-9677-6a2f902e7787}*SharedItemsImports = 5 - ..\sources\editor\Stride.Editor.CrashReport\Stride.Editor.CrashReport.projitems*{ab574f65-1402-4476-9314-74dcdaf19097}*SharedItemsImports = 13 - ..\sources\engine\Stride.Shared\Refactor\Stride.Refactor.projitems*{b33e576f-2279-4bfc-a438-d9b84343b56b}*SharedItemsImports = 13 - ..\sources\engine\Stride.Shared\Refactor\Stride.Refactor.projitems*{c121a566-555e-42b9-9b0a-1696529a9088}*SharedItemsImports = 5 - ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{e136b568-3e3f-498f-a8b4-2877b7768560}*SharedItemsImports = 5 - ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{e25e7778-0b2f-4a0b-bcd6-1de95320b531}*SharedItemsImports = 5 - ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{e8b3553f-a79f-4e50-b75b-acee771c320c}*SharedItemsImports = 5 - ..\sources\engine\Stride.Shared\Refactor\Stride.Refactor.projitems*{fb06c76a-6bb7-40be-9afa-fec13b045fb5}*SharedItemsImports = 5 - ..\sources\assets\Stride.Core.Assets.Yaml\Stride.Core.Assets.Yaml.projitems*{fb9ed2c4-94a0-4004-a498-3f29a9d5bb5d}*SharedItemsImports = 13 - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|Mixed Platforms = Debug|Mixed Platforms @@ -1629,7 +1592,6 @@ Global {53782603-3096-40C2-ABD3-F8F311BAE4BE} = {4C142567-C42B-40F5-B092-798882190209} {E8C458AE-7B42-4DCE-B326-7F3A9065EA19} = {52AE329E-B588-40D0-A578-8D0DB1BD83E5} {3C855DB2-EEA3-415C-A0A8-C834DEC40531} = {1AE1AC60-5D2F-4CA7-AE20-888F44551185} - {991E796A-D1D1-48B8-B9AA-95C2744FE112} = {E4508D15-6503-4A29-ADC4-27B3A5E99545} {FB9ED2C4-94A0-4004-A498-3F29A9D5BB5D} = {A2A4342E-024B-4063-B10C-1DA96CA3046D} {FBE1FA7B-E699-4BB2-9C8F-41F4C9F3F088} = {4C142567-C42B-40F5-B092-798882190209} {1AC5A693-3CC4-4450-AA76-70DA4F0C29DF} = {A7ED9F01-7D78-4381-90A6-D50E51C17250} @@ -1658,4 +1620,35 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {FF877973-604D-4EA7-B5F5-A129961F9EF2} EndGlobalSection + GlobalSection(SharedMSBuildProjectFiles) = preSolution + ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{00b72ed7-00e9-47f7-868d-8162027cd068}*SharedItemsImports = 13 + ..\sources\assets\Stride.Core.Assets.Yaml\Stride.Core.Assets.Yaml.projitems*{1e54a9a2-4439-4444-ae57-6d2ed3c0dc47}*SharedItemsImports = 5 + ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{1e54a9a2-4439-4444-ae57-6d2ed3c0dc47}*SharedItemsImports = 5 + ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{2fc40214-a4aa-45dc-9c93-72ed800c40b0}*SharedItemsImports = 5 + ..\sources\editor\Stride.Editor.CrashReport\Stride.Editor.CrashReport.projitems*{2fca2d8b-b10f-4dca-9847-4221f74ba586}*SharedItemsImports = 5 + ..\sources\editor\Stride.PrivacyPolicy\Stride.PrivacyPolicy.projitems*{2fca2d8b-b10f-4dca-9847-4221f74ba586}*SharedItemsImports = 5 + ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{2fca2d8b-b10f-4dca-9847-4221f74ba586}*SharedItemsImports = 5 + ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{2fca2d8b-b10f-4dca-9847-4221f74ba586}*SharedItemsImports = 5 + ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{39ae9c77-e94b-404f-8768-b6261b3c1e0e}*SharedItemsImports = 5 + ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{3a3cb33c-64d9-4948-86c1-0d86320d23c3}*SharedItemsImports = 13 + ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{50d1a3bb-4b41-4ef5-8d2f-3618a3b6c698}*SharedItemsImports = 5 + ..\sources\editor\Stride.Core.MostRecentlyUsedFiles\Stride.Core.MostRecentlyUsedFiles.projitems*{5863574d-7a55-49bc-8e65-babb74d8e66e}*SharedItemsImports = 5 + ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{75d71310-ecf7-4592-9e35-3fe540040982}*SharedItemsImports = 5 + ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{75d71310-ecf7-4592-9e35-3fe540040982}*SharedItemsImports = 5 + ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{77e2fcc0-4ca6-436c-be6f-9418cb807d45}*SharedItemsImports = 5 + ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{77e2fcc0-4ca6-436c-be6f-9418cb807d45}*SharedItemsImports = 5 + ..\sources\engine\Stride.Shared\Refactor\Stride.Refactor.projitems*{7af4b563-aad3-42ff-b91e-84b9d34d904a}*SharedItemsImports = 5 + ..\sources\editor\Stride.PrivacyPolicy\Stride.PrivacyPolicy.projitems*{950badd0-ad5a-4f58-87ec-4adaecbea89b}*SharedItemsImports = 13 + ..\sources\editor\Stride.Core.MostRecentlyUsedFiles\Stride.Core.MostRecentlyUsedFiles.projitems*{9ac6d791-811e-4d6a-b08e-93f0093ef268}*SharedItemsImports = 13 + ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{a5dc820b-9554-45b6-9677-6a2f902e7787}*SharedItemsImports = 5 + ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{a5dc820b-9554-45b6-9677-6a2f902e7787}*SharedItemsImports = 5 + ..\sources\editor\Stride.Editor.CrashReport\Stride.Editor.CrashReport.projitems*{ab574f65-1402-4476-9314-74dcdaf19097}*SharedItemsImports = 13 + ..\sources\engine\Stride.Shared\Refactor\Stride.Refactor.projitems*{b33e576f-2279-4bfc-a438-d9b84343b56b}*SharedItemsImports = 13 + ..\sources\engine\Stride.Shared\Refactor\Stride.Refactor.projitems*{c121a566-555e-42b9-9b0a-1696529a9088}*SharedItemsImports = 5 + ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{e136b568-3e3f-498f-a8b4-2877b7768560}*SharedItemsImports = 5 + ..\sources\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems*{e25e7778-0b2f-4a0b-bcd6-1de95320b531}*SharedItemsImports = 5 + ..\sources\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems*{e8b3553f-a79f-4e50-b75b-acee771c320c}*SharedItemsImports = 5 + ..\sources\engine\Stride.Shared\Refactor\Stride.Refactor.projitems*{fb06c76a-6bb7-40be-9afa-fec13b045fb5}*SharedItemsImports = 5 + ..\sources\assets\Stride.Core.Assets.Yaml\Stride.Core.Assets.Yaml.projitems*{fb9ed2c4-94a0-4004-a498-3f29a9d5bb5d}*SharedItemsImports = 13 + EndGlobalSection EndGlobal diff --git a/sources/assets/Stride.Core.Assets.CompilerApp/PackageBuilder.cs b/sources/assets/Stride.Core.Assets.CompilerApp/PackageBuilder.cs index dfc0d3085..03a8bade9 100644 --- a/sources/assets/Stride.Core.Assets.CompilerApp/PackageBuilder.cs +++ b/sources/assets/Stride.Core.Assets.CompilerApp/PackageBuilder.cs @@ -441,14 +441,6 @@ namespace Stride.Core.Assets.CompilerApp var address = "Stride/CompilerApp/PackageBuilderApp/" + Guid.NewGuid(); var arguments = $"--slave=\"{address}\" --build-path=\"{builderOptions.BuildDirectory}\""; - using (var debugger = VisualStudioDebugger.GetAttached()) - { - if (debugger != null) - { - arguments += $" --reattach-debugger={debugger.ProcessId}"; - } - } - // Start ServiceWire pipe for communication with process var processBuilderRemote = new ProcessBuilderRemote(assemblyContainer, commandContext, command); var host = new NpHost(address,null,null, new StrideServiceWireSerializer()); diff --git a/sources/assets/Stride.Core.Assets.CompilerApp/PackageBuilderApp.cs b/sources/assets/Stride.Core.Assets.CompilerApp/PackageBuilderApp.cs index 15517637a..5502b61ce 100644 --- a/sources/assets/Stride.Core.Assets.CompilerApp/PackageBuilderApp.cs +++ b/sources/assets/Stride.Core.Assets.CompilerApp/PackageBuilderApp.cs @@ -146,22 +146,6 @@ namespace Stride.Core.Assets.CompilerApp } } }, - { - "reattach-debugger=", "Reattach to a Visual Studio debugger", v => - { - int debuggerProcessId; - if (!string.IsNullOrEmpty(v) && int.TryParse(v, out debuggerProcessId)) - { - if (!Debugger.IsAttached) - { - using (var debugger = VisualStudioDebugger.GetByProcess(debuggerProcessId)) - { - debugger?.Attach(); - } - } - } - } - }, }; TextWriterLogListener fileLogListener = null; diff --git a/sources/assets/Stride.Core.Assets.CompilerApp/Stride.Core.Assets.CompilerApp.csproj b/sources/assets/Stride.Core.Assets.CompilerApp/Stride.Core.Assets.CompilerApp.csproj index a7f85b928..329992967 100644 --- a/sources/assets/Stride.Core.Assets.CompilerApp/Stride.Core.Assets.CompilerApp.csproj +++ b/sources/assets/Stride.Core.Assets.CompilerApp/Stride.Core.Assets.CompilerApp.csproj @@ -38,8 +38,6 @@ - - \ No newline at end of file diff --git a/sources/editor/Stride.GameStudio/Debugging/DebugHost.cs b/sources/editor/Stride.GameStudio/Debugging/DebugHost.cs index a17d86b7c..0eba71add 100644 --- a/sources/editor/Stride.GameStudio/Debugging/DebugHost.cs +++ b/sources/editor/Stride.GameStudio/Debugging/DebugHost.cs @@ -23,45 +23,35 @@ namespace Stride.GameStudio.Debugging { var gameHostAssembly = typeof(GameDebuggerTarget).Assembly.Location; - using (var debugger = debuggerProcess != null ? VisualStudioDebugger.GetByProcess(debuggerProcess.Id) : null) + var address = "Stride/Debugger/" + Guid.NewGuid(); + var arguments = $"--host=\"{address}\""; + + var startInfo = new ProcessStartInfo { - var address = "Stride/Debugger/" + Guid.NewGuid(); - var arguments = $"--host=\"{address}\""; + FileName = gameHostAssembly, + Arguments = arguments, + WorkingDirectory = workingDirectory, + CreateNoWindow = true, + UseShellExecute = false, + RedirectStandardOutput = true, + RedirectStandardError = true, + }; - // Child process should wait for a debugger to be attached - if (debugger != null) - arguments += " --wait-debugger-attach"; + // Start ServiceWire pipe + var gameDebuggerHost = new GameDebuggerHost(logger); + ServiceHost = new NpHost(address, null, null); + ServiceHost.AddService(gameDebuggerHost); + ServiceHost.Open(); - var startInfo = new ProcessStartInfo - { - FileName = gameHostAssembly, - Arguments = arguments, - WorkingDirectory = workingDirectory, - CreateNoWindow = true, - UseShellExecute = false, - RedirectStandardOutput = true, - RedirectStandardError = true, - }; + var process = new Process { StartInfo = startInfo }; + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); - // Start ServiceWire pipe - var gameDebuggerHost = new GameDebuggerHost(logger); - ServiceHost = new NpHost(address, null, null); - ServiceHost.AddService(gameDebuggerHost); - ServiceHost.Open(); + // Make sure proces will be killed if our process is finished unexpectedly + attachedChildProcessJob = new AttachedChildProcessJob(process); - var process = new Process { StartInfo = startInfo }; - process.Start(); - process.BeginOutputReadLine(); - process.BeginErrorReadLine(); - - // Make sure proces will be killed if our process is finished unexpectedly - attachedChildProcessJob = new AttachedChildProcessJob(process); - - // Attach debugger - debugger?.AttachToProcess(process.Id); - - GameHost = gameDebuggerHost; - } + GameHost = gameDebuggerHost; } public void Stop() diff --git a/sources/editor/Stride.GameStudio/Debugging/StrideDebugService.cs b/sources/editor/Stride.GameStudio/Debugging/StrideDebugService.cs index 97db1fb91..1310cd671 100644 --- a/sources/editor/Stride.GameStudio/Debugging/StrideDebugService.cs +++ b/sources/editor/Stride.GameStudio/Debugging/StrideDebugService.cs @@ -162,8 +162,8 @@ namespace Stride.GameStudio.Debugging if (process == null) { - // If not, let the user pick an instance - var picker = new DebuggerPickerWindow(VisualStudioDTE.GetActiveInstances()); + // If not, let the user pick an instance (Todo) + var picker = new DebuggerPickerWindow(Array.Empty()); var result = await picker.ShowModal(); diff --git a/sources/editor/Stride.GameStudio/GameStudioViewModel.cs b/sources/editor/Stride.GameStudio/GameStudioViewModel.cs index 72e4b7b28..d89f10a94 100644 --- a/sources/editor/Stride.GameStudio/GameStudioViewModel.cs +++ b/sources/editor/Stride.GameStudio/GameStudioViewModel.cs @@ -80,7 +80,7 @@ namespace Stride.GameStudio protected override void RestartAndCreateNewSession() { - restartArguments = "/NewProject" + GetCommonArguments(); + restartArguments = "/NewProject"; CloseAndRestart(); } @@ -100,7 +100,7 @@ namespace Stride.GameStudio if (sessionPath == null) return; - restartArguments = $"\"{sessionPath.ToWindowsPath()}\"" + GetCommonArguments(); + restartArguments = $"\"{sessionPath.ToWindowsPath()}\""; await CloseAndRestart(); } @@ -145,20 +145,5 @@ namespace Stride.GameStudio e.Ignore(); } } - - private static string GetCommonArguments() - { - var arguments = ""; - - using (var debugger = VisualStudioDebugger.GetAttached()) - { - if (debugger != null) - { - arguments += $" /Reattach {debugger.ProcessId}"; - } - } - - return arguments; - } } } diff --git a/sources/editor/Stride.GameStudio/Program.cs b/sources/editor/Stride.GameStudio/Program.cs index ca209fda1..c055c0784 100644 --- a/sources/editor/Stride.GameStudio/Program.cs +++ b/sources/editor/Stride.GameStudio/Program.cs @@ -115,18 +115,6 @@ namespace Stride.GameStudio renderDocManager = new RenderDocManager(); renderDocManager.Initialize(); } - else if (args[i] == "/Reattach") - { - var debuggerProcessId = int.Parse(args[++i]); - - if (!System.Diagnostics.Debugger.IsAttached) - { - using (var debugger = VisualStudioDebugger.GetByProcess(debuggerProcessId)) - { - debugger?.Attach(); - } - } - } else if (args[i] == "/RecordEffects") { GameStudioBuilderService.GlobalEffectLogPath = args[++i]; diff --git a/sources/editor/Stride.GameStudio/Stride.GameStudio.csproj b/sources/editor/Stride.GameStudio/Stride.GameStudio.csproj index ace4a5d11..8dabff3f4 100644 --- a/sources/editor/Stride.GameStudio/Stride.GameStudio.csproj +++ b/sources/editor/Stride.GameStudio/Stride.GameStudio.csproj @@ -1,7 +1,6 @@ - diff --git a/sources/tools/Stride.Core.VisualStudio/MessageFilter.cs b/sources/tools/Stride.Core.VisualStudio/MessageFilter.cs deleted file mode 100644 index 664dc6496..000000000 --- a/sources/tools/Stride.Core.VisualStudio/MessageFilter.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) -// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -namespace Stride.Core.VisualStudio -{ - // Avoid COMException "Application is busy (RPC_E_CALL_REJECTED 0x80010001)" - // https://msdn.microsoft.com/en-us/library/ms228772.aspx - // Note: It requires STAThread - class MessageFilter : IOleMessageFilter - { - // - // Class containing the IOleMessageFilter - // thread error-handling functions. - - // Start the filter. - public static void Register() - { - IOleMessageFilter newFilter = new MessageFilter(); - IOleMessageFilter oldFilter = null; - CoRegisterMessageFilter(newFilter, out oldFilter); - } - - // Done with the filter, close it. - public static void Revoke() - { - IOleMessageFilter oldFilter = null; - CoRegisterMessageFilter(null, out oldFilter); - } - - // - // IOleMessageFilter functions. - // Handle incoming thread requests. - int IOleMessageFilter.HandleInComingCall(int dwCallType, - System.IntPtr hTaskCaller, int dwTickCount, System.IntPtr - lpInterfaceInfo) - { - //Return the flag SERVERCALL_ISHANDLED. - return 0; - } - - // Thread call was rejected, so try again. - int IOleMessageFilter.RetryRejectedCall(System.IntPtr - hTaskCallee, int dwTickCount, int dwRejectType) - { - if (dwRejectType == 2) - // flag = SERVERCALL_RETRYLATER. - { - // Retry the thread call immediately if return >=0 & - // <100. - return 99; - } - // Too busy; cancel call. - return -1; - } - - int IOleMessageFilter.MessagePending(System.IntPtr hTaskCallee, - int dwTickCount, int dwPendingType) - { - //Return the flag PENDINGMSG_WAITDEFPROCESS. - return 2; - } - - // Implement the IOleMessageFilter interface. - [DllImport("Ole32.dll")] - private static extern int - CoRegisterMessageFilter(IOleMessageFilter newFilter, out - IOleMessageFilter oldFilter); - } - - [ComImport(), Guid("00000016-0000-0000-C000-000000000046"), - InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - interface IOleMessageFilter - { - [PreserveSig] - int HandleInComingCall( - int dwCallType, - IntPtr hTaskCaller, - int dwTickCount, - IntPtr lpInterfaceInfo); - - [PreserveSig] - int RetryRejectedCall( - IntPtr hTaskCallee, - int dwTickCount, - int dwRejectType); - - [PreserveSig] - int MessagePending( - IntPtr hTaskCallee, - int dwTickCount, - int dwPendingType); - } -} diff --git a/sources/tools/Stride.Core.VisualStudio/STAContext.cs b/sources/tools/Stride.Core.VisualStudio/STAContext.cs deleted file mode 100644 index ec82c7a8b..000000000 --- a/sources/tools/Stride.Core.VisualStudio/STAContext.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) -// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. -using System; -using System.Collections.Concurrent; -using System.Threading; -using System.Threading.Tasks; - -namespace Stride.Core.VisualStudio -{ - /// - /// Post actions on a having . - /// - internal class STAContext : IDisposable - { - private readonly Thread thread; - private BlockingCollection tasks; - - public STAContext() - { - tasks = new BlockingCollection(); - - thread = new Thread(() => - { - foreach (var task in tasks.GetConsumingEnumerable()) - { - task.RunSynchronously(); - } - }); - - thread.IsBackground = true; - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - public T Execute(Func func) - { - var task = new Task(func); - - tasks.Add(task); - task.Wait(); - return task.Result; - } - - public void Execute(Action action) - { - var task = new Task(action); - - tasks.Add(task); - task.Wait(); - } - - public void Dispose() - { - if (tasks != null) - { - tasks.CompleteAdding(); - - thread.Join(); - - tasks.Dispose(); - tasks = null; - } - } - } -} diff --git a/sources/tools/Stride.Core.VisualStudio/Stride.Core.VisualStudio.projitems b/sources/tools/Stride.Core.VisualStudio/Stride.Core.VisualStudio.projitems deleted file mode 100644 index fce18c9a3..000000000 --- a/sources/tools/Stride.Core.VisualStudio/Stride.Core.VisualStudio.projitems +++ /dev/null @@ -1,17 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 991e796a-d1d1-48b8-b9aa-95c2744fe112 - - - Stride.Core.VisualStudio - - - - - - - - \ No newline at end of file diff --git a/sources/tools/Stride.Core.VisualStudio/Stride.Core.VisualStudio.shproj b/sources/tools/Stride.Core.VisualStudio/Stride.Core.VisualStudio.shproj deleted file mode 100644 index c391cb3d5..000000000 --- a/sources/tools/Stride.Core.VisualStudio/Stride.Core.VisualStudio.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - 991e796a-d1d1-48b8-b9aa-95c2744fe112 - 14.0 - - - - - - - - diff --git a/sources/tools/Stride.Core.VisualStudio/VisualStudioDTE.cs b/sources/tools/Stride.Core.VisualStudio/VisualStudioDTE.cs deleted file mode 100644 index f3cc6ddc1..000000000 --- a/sources/tools/Stride.Core.VisualStudio/VisualStudioDTE.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) -// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Runtime.InteropServices.ComTypes; -#if STRIDE_RUNTIME_NETFW -using EnvDTE; -#endif -using Process = System.Diagnostics.Process; - -namespace Stride.Core.VisualStudio -{ - /// - /// Helper class to locate Visual Studio instances. - /// - class VisualStudioDTE - { -#if STRIDE_RUNTIME_NETFW - public static IEnumerable GetActiveInstances() - { - return GetActiveDTEs().Select(x => x.ProcessId).Select(Process.GetProcessById); - } - - public static DTE GetDTEByProcess(int processId) - { - return GetActiveDTEs().FirstOrDefault(x => x.ProcessId == processId).DTE; - } - - /// - /// Gets the instances of active . - /// - /// - internal static IEnumerable GetActiveDTEs() - { - IRunningObjectTable rot; - if (GetRunningObjectTable(0, out rot) == 0) - { - IEnumMoniker enumMoniker; - rot.EnumRunning(out enumMoniker); - - var moniker = new IMoniker[1]; - while (enumMoniker.Next(1, moniker, IntPtr.Zero) == 0) - { - IBindCtx bindCtx; - CreateBindCtx(0, out bindCtx); - string displayName; - moniker[0].GetDisplayName(bindCtx, null, out displayName); - - // Check if it's Visual Studio - if (displayName.StartsWith("!VisualStudio")) - { - object obj; - rot.GetObject(moniker[0], out obj); - - // Cast as DTE - var dte = obj as DTE; - if (dte != null) - { - yield return new Instance - { - DTE = dte, - ProcessId = int.Parse(displayName.Split(':')[1]) - }; - } - } - } - } - } - - public struct Instance - { - public DTE DTE; - - public int ProcessId; - } - - [DllImport("ole32.dll")] - private static extern void CreateBindCtx(int reserved, out IBindCtx ppbc); - - [DllImport("ole32.dll")] - private static extern int GetRunningObjectTable(int reserved, out IRunningObjectTable prot); -#else - public static IEnumerable GetActiveInstances() - { - return new Process[0]; - } -#endif - } -} diff --git a/sources/tools/Stride.Core.VisualStudio/VisualStudioDebugger.cs b/sources/tools/Stride.Core.VisualStudio/VisualStudioDebugger.cs deleted file mode 100644 index 1b51d7d47..000000000 --- a/sources/tools/Stride.Core.VisualStudio/VisualStudioDebugger.cs +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) -// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Runtime.InteropServices.ComTypes; -#if STRIDE_RUNTIME_NETFW -using EnvDTE; -#endif - -namespace Stride.Core.VisualStudio -{ - /// - /// Helper class to attach Visual Studio instances to a process for debugging. - /// - internal class VisualStudioDebugger : IDisposable - { -#if STRIDE_RUNTIME_NETFW - private readonly STAContext context; - private readonly DTE dte; -#endif - - public int ProcessId { get; private set; } - -#if STRIDE_RUNTIME_NETFW - private VisualStudioDebugger(STAContext context, DTE dte, int processId) - { - this.context = context; - this.dte = dte; - this.ProcessId = processId; - } - - public static VisualStudioDebugger GetByProcess(int processId) - { - var context = new STAContext(); - - var instance = GetFirstOrDefaultDTE(context, x => x.ProcessId == processId); - - if (instance.DTE == null) - { - context.Dispose(); - return null; - } - - return new VisualStudioDebugger(context, instance.DTE, instance.ProcessId); - } - - public static VisualStudioDebugger GetAttached() - { - if (!System.Diagnostics.Debugger.IsAttached) - return null; - - var context = new STAContext(); - - var instance = GetFirstOrDefaultDTE(context, x => - { - // Try multiple time, as DTE might report it is busy - var debugger = x.DTE.Debugger; - if (debugger.DebuggedProcesses == null) - return false; - - return debugger.DebuggedProcesses.OfType().Any(debuggedProcess => debuggedProcess.ProcessID == System.Diagnostics.Process.GetCurrentProcess().Id); - }); - - if (instance.DTE == null) - { - context.Dispose(); - return null; - } - - return new VisualStudioDebugger(context, instance.DTE, instance.ProcessId); - } - - public void AttachToProcess(int processId) - { - context.Execute(() => - { - // Make this DTE attach the newly created process - MessageFilter.Register(); - var processes = dte.Debugger.LocalProcesses.OfType(); - var process = processes.FirstOrDefault(x => x.ProcessID == processId); - process?.Attach(); - MessageFilter.Revoke(); - }); - } - - public void DetachFromProcess(int processId) - { - context.Execute(() => - { - // Make this DTE attach the newly created process - MessageFilter.Register(); - var processes = dte.Debugger.LocalProcesses.OfType(); - var process = processes.FirstOrDefault(x => x.ProcessID == processId); - process?.Detach(); - MessageFilter.Revoke(); - }); - } - - public void Attach() - { - AttachToProcess(System.Diagnostics.Process.GetCurrentProcess().Id); - } - - public void Detach() - { - DetachFromProcess(System.Diagnostics.Process.GetCurrentProcess().Id); - } - - public void Dispose() - { - context.Dispose(); - } - - private static VisualStudioDTE.Instance GetFirstOrDefaultDTE(STAContext context, Func predicate) - { - return context.Execute(() => - { - // Locate all Visual Studio DTE - var dtes = VisualStudioDTE.GetActiveDTEs().ToArray(); - - // Find DTE - MessageFilter.Register(); - var result = dtes.FirstOrDefault(predicate); - MessageFilter.Revoke(); - - return result; - }); - } -#else - public static VisualStudioDebugger GetByProcess(int processId) - { - return null; - } - - public static VisualStudioDebugger GetAttached() - { - return null; - } - - public void Attach() - { - throw new PlatformNotSupportedException("EnvDTE is not supported with this runtime"); - } - - public void Detach() - { - throw new PlatformNotSupportedException("EnvDTE is not supported with this runtime"); - } - - public void AttachToProcess(int processId) - { - throw new PlatformNotSupportedException("EnvDTE is not supported with this runtime"); - } - - public void Dispose() - { - throw new PlatformNotSupportedException("EnvDTE is not supported with this runtime"); - } -#endif - } -} diff --git a/sources/tools/Stride.VisualStudio.Package.Tests/Stride.VisualStudio.Package.Tests.csproj b/sources/tools/Stride.VisualStudio.Package.Tests/Stride.VisualStudio.Package.Tests.csproj index 6d9ec396b..d7b7c15dd 100644 --- a/sources/tools/Stride.VisualStudio.Package.Tests/Stride.VisualStudio.Package.Tests.csproj +++ b/sources/tools/Stride.VisualStudio.Package.Tests/Stride.VisualStudio.Package.Tests.csproj @@ -72,7 +72,6 @@ true -