Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vs): don't reload the profile observer on initial solution open (backport #19614) #19619

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading