Remove VisualStudio reattach deadcode (#1677)

This commit is contained in:
Jakub Ławreszuk 2023-06-10 00:08:29 +02:00 коммит произвёл GitHub
Родитель d606ae8ca6
Коммит 7dd3c1aeee
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 59 добавлений и 577 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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());

Просмотреть файл

@ -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;

Просмотреть файл

@ -38,8 +38,6 @@
<ProjectReference Include="..\..\engine\Stride.SpriteStudio.Offline\Stride.SpriteStudio.Offline.csproj" />
<ProjectReference Include="..\..\engine\Stride.UI\Stride.UI.csproj" />
</ItemGroup>
<Import Project="..\..\tools\Stride.Core.VisualStudio\Stride.Core.VisualStudio.projitems" Label="Shared" />
<Import Project="..\..\shared\Stride.NuGetResolver\Stride.NuGetResolver.projitems" Label="Shared" />
<Import Project="$(StrideSdkTargets)" />
</Project>

Просмотреть файл

@ -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<IGameDebuggerHost>(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<IGameDebuggerHost>(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()

Просмотреть файл

@ -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<Process>());
var result = await picker.ShowModal();

Просмотреть файл

@ -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;
}
}
}

Просмотреть файл

@ -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];

Просмотреть файл

@ -1,7 +1,6 @@
<Project>
<Import Project="..\Stride.PrivacyPolicy\Stride.PrivacyPolicy.projitems" Label="Shared" Condition="Exists('..\Stride.PrivacyPolicy\Stride.PrivacyPolicy.projitems')" />
<Import Project="..\..\shared\Stride.Core.ShellHelper\Stride.Core.ShellHelper.projitems" Label="Shared" />
<Import Project="..\..\tools\Stride.Core.VisualStudio\Stride.Core.VisualStudio.projitems" Label="Shared" />
<Import Project="..\Stride.Editor.CrashReport\Stride.Editor.CrashReport.projitems" Label="Shared" />
<Import Project="..\..\targets\Stride.props" />
<PropertyGroup>

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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
{
/// <summary>
/// Post actions on a <see cref="Thread"/> having <see cref="ApartmentState.STA"/>.
/// </summary>
internal class STAContext : IDisposable
{
private readonly Thread thread;
private BlockingCollection<Task> tasks;
public STAContext()
{
tasks = new BlockingCollection<Task>();
thread = new Thread(() =>
{
foreach (var task in tasks.GetConsumingEnumerable())
{
task.RunSynchronously();
}
});
thread.IsBackground = true;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
public T Execute<T>(Func<T> func)
{
var task = new Task<T>(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;
}
}
}
}

Просмотреть файл

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>991e796a-d1d1-48b8-b9aa-95c2744fe112</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Stride.Core.VisualStudio</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)MessageFilter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)STAContext.cs" />
<Compile Include="$(MSBuildThisFileDirectory)VisualStudioDebugger.cs" />
<Compile Include="$(MSBuildThisFileDirectory)VisualStudioDTE.cs" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>991e796a-d1d1-48b8-b9aa-95c2744fe112</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Stride.Core.VisualStudio.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

Просмотреть файл

@ -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
{
/// <summary>
/// Helper class to locate Visual Studio instances.
/// </summary>
class VisualStudioDTE
{
#if STRIDE_RUNTIME_NETFW
public static IEnumerable<Process> GetActiveInstances()
{
return GetActiveDTEs().Select(x => x.ProcessId).Select(Process.GetProcessById);
}
public static DTE GetDTEByProcess(int processId)
{
return GetActiveDTEs().FirstOrDefault(x => x.ProcessId == processId).DTE;
}
/// <summary>
/// Gets the instances of active <see cref="EnvDTE.DTE"/>.
/// </summary>
/// <returns></returns>
internal static IEnumerable<Instance> 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<Process> GetActiveInstances()
{
return new Process[0];
}
#endif
}
}

Просмотреть файл

@ -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
{
/// <summary>
/// Helper class to attach Visual Studio instances to a process for debugging.
/// </summary>
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<EnvDTE.Process>().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<EnvDTE.Process>();
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<EnvDTE.Process>();
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<VisualStudioDTE.Instance, bool> 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
}
}

Просмотреть файл

@ -72,7 +72,6 @@
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
</ItemGroup>
<Import Project="..\Stride.Core.VisualStudio\Stride.Core.VisualStudio.projitems" Label="Shared" />
<Import Project="$(StrideSdkTargets)" />
<Target Name="LocateDevenv" AfterTargets="PrepareForBuild">
<!-- Compute and save VisualStudio path to a file so that it can be used when running the test. Note: ideally we should use a Task, but Visual Studio lock the files -->