Skip to content

Commit

Permalink
Merge pull request #19619 from unoplatform/mergify/bp/release/stable/…
Browse files Browse the repository at this point in the history
…5.6/pr-19614

fix(vs): don't reload the profile observer on initial solution open (backport #19614)
  • Loading branch information
jeromelaban authored Mar 2, 2025
2 parents e9dac7c + 9c61ce2 commit af21183
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/Uno.UI.RemoteControl.VS/DebuggerHelper/ProfilesObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ internal class ProfilesObserver : IDisposable
private readonly Func<string?, string, Task> _onDebugFrameworkChanged;
private readonly Func<string?, string, Task> _onDebugProfileChanged;
private Func<Task> _onStartupProjectChanged;
private object[] _existingStartupProjects = [];


private string? _lastActiveDebugProfile;
private string? _lastActiveDebugFramework;
Expand Down Expand Up @@ -82,9 +84,6 @@ AsyncPackage asyncPackage
_ = ObserveStartupProjectAsync();
}

object[]? _existingStartupProjects = [];


private async Task ObserveStartupProjectAsync()
{
while (!_isDisposed)
Expand All @@ -99,7 +98,12 @@ private void TryUpdateSolution()
{
if (_dte.Solution.SolutionBuild.StartupProjects is object[] newStartupProjects)
{
if (!newStartupProjects.SequenceEqual(_existingStartupProjects))
if (_existingStartupProjects.Length == 0)
{
// We're starting up, no need to re-create the observer
_existingStartupProjects = newStartupProjects;
}
else if (!newStartupProjects.SequenceEqual(_existingStartupProjects))
{
_debugLog("Startup projects have changed, reloading observer");

Expand All @@ -114,6 +118,15 @@ private void TryUpdateSolution()
_ = ObserveProfilesAsync();
}
}
else
{
if (_existingStartupProjects.Length > 0)
{
_ = _onStartupProjectChanged();
}

_existingStartupProjects = [];
}
}

public async Task ObserveProfilesAsync()
Expand Down
6 changes: 6 additions & 0 deletions src/Uno.UI.RemoteControl.VS/EntryPoint.ActiveProfileSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ previousTargetFrameworkIdentifier is WasmTargetFrameworkIdentifier

private async Task OnStartupProjectChangedAsync()
{
if (_dte.Solution.SolutionBuild.StartupProjects is null)
{
// The user unloaded all projects, we need to reset the state
_isFirstProfileTfmChange = true;
}

if (!await EnsureProjectUserSettingsAsync() && _debuggerObserver is not null)
{
_debugAction?.Invoke($"The user setting is not yet initialized, aligning framework and profile");
Expand Down

0 comments on commit af21183

Please sign in to comment.