Skip to content

Commit

Permalink
Merge pull request #18356 from unoplatform/dev/jela/17-12-reload
Browse files Browse the repository at this point in the history
fix: Don't reload projects when moving to all TFMs but wasm
  • Loading branch information
jeromelaban authored Oct 4, 2024
2 parents a2e3205 + a3d8370 commit 7474c70
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Uno.UI.RemoteControl.VS/EntryPoint.ActiveProfileSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,21 @@ private async Task TryReloadTargetAsync(string? previousFramework, string newFra
(
previousFramework is not null
&& GetTargetFrameworkIdentifier(previousFramework) is { } previousTargetFrameworkIdentifier
&& (previousTargetFrameworkIdentifier is WasmTargetFrameworkIdentifier or DesktopTargetFrameworkIdentifier or Windows10TargetFrameworkIdentifier
|| targetFrameworkIdentifier is WasmTargetFrameworkIdentifier or DesktopTargetFrameworkIdentifier or Windows10TargetFrameworkIdentifier)
&& (
(
// 17.12 or later properly supports having their TFM anywhere in the
// TFMs lists, except Wasm.
GetVisualStudioReleaseVersion() >= new Version(17, 12)
&& (
previousTargetFrameworkIdentifier is WasmTargetFrameworkIdentifier
|| targetFrameworkIdentifier is WasmTargetFrameworkIdentifier))

|| (
// 17.11 or earlier needs reloading most TFMs
GetVisualStudioReleaseVersion() < new Version(17, 12)
&& (previousTargetFrameworkIdentifier is WasmTargetFrameworkIdentifier or DesktopTargetFrameworkIdentifier or Windows10TargetFrameworkIdentifier
|| targetFrameworkIdentifier is WasmTargetFrameworkIdentifier or DesktopTargetFrameworkIdentifier or Windows10TargetFrameworkIdentifier))
)
)
)
)
Expand Down
41 changes: 41 additions & 0 deletions src/Uno.UI.RemoteControl.VS/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using EnvDTE;
using EnvDTE80;
using Microsoft.Build.Evaluation;
using Microsoft.Internal.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Uno.UI.RemoteControl.Messaging.IdeChannel;
using Uno.UI.RemoteControl.VS.DebuggerHelper;
using Uno.UI.RemoteControl.VS.Helpers;
Expand Down Expand Up @@ -47,6 +49,7 @@ public partial class EntryPoint : IDisposable
private int _msBuildLogLevel;
private System.Diagnostics.Process? _process;
private SemaphoreSlim _processGate = new(1);
private IServiceProvider? _visualStudioServiceProvider;

private int _remoteControlServerPort;
private string? _remoteControlConfigCookie;
Expand Down Expand Up @@ -529,6 +532,44 @@ public void Dispose()
}
}

protected IServiceProvider VisualStudioServiceProvider
{
get
{
ThreadHelper.ThrowIfNotOnUIThread();

if (_visualStudioServiceProvider == null)
{
_visualStudioServiceProvider = _dte as IServiceProvider;
if (_visualStudioServiceProvider == null)
{
var serviceProvider = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider?)((_dte is Microsoft.VisualStudio.OLE.Interop.IServiceProvider) ? _dte : null);
_visualStudioServiceProvider = (IServiceProvider)new Microsoft.VisualStudio.Shell.ServiceProvider(serviceProvider);
}
}
return _visualStudioServiceProvider;
}
}

private Version? GetVisualStudioReleaseVersion()
{
ThreadHelper.ThrowIfNotOnUIThread();

if (VisualStudioServiceProvider?.GetService(typeof(SVsShell)) is IVsShell service)
{
if (service.GetProperty(-9068, out var releaseVersion) != 0)
{
return null;
}
if (releaseVersion is string releaseVersionAsText && Version.TryParse(releaseVersionAsText.Split(' ')[0], out var result))
{
return result;
}
}

return null;
}

private class Logger(EntryPoint entryPoint) : ILogger
{
public void Debug(string message) => entryPoint._debugAction?.Invoke(message);
Expand Down

0 comments on commit 7474c70

Please sign in to comment.