Don't overwrite debug settings the extension doesn't manage - #198
Open
CoreyShay wants to merge 1 commit into
Open
Don't overwrite debug settings the extension doesn't manage#198CoreyShay wants to merge 1 commit into
CoreyShay wants to merge 1 commit into
Conversation
When "Manage Working Directories" or "Manage Launch Application" is
enabled but a project has no WorkDir/LaunchApp item, the aggregation
returned an empty string instead of null. UpdateProjectConfig only skips
writing on null, so an empty <LocalDebuggerCommand /> and
<LocalDebuggerWorkingDirectory /> were written into the .vcxproj.user.
Those empty elements override the values inherited from the .vcxproj,
so the Command and Working Directory shown in the project property pages
were blanked on every launch and debugging failed until they were
entered again by hand. The same applied to the debug environment.
Distinguish the two cases:
- no item of that type exists => null => setting is not managed,
leave the project alone
- items exist but all unchecked => "" => user cleared it on purpose
This keeps the existing "uncheck to clear" behaviour intact while no
longer touching settings the extension was never asked to manage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With Manage Working Directories and/or Manage Launch Application enabled, the extension blanks the debugger
CommandandWorking Directoryof C/C++ projects that have noWorkDir/LaunchAppitem, which makes launching the project fail.Steps to reproduce:
.vcxprojwhoseCommand/Working Directoryare set in the.vcxproj(so they show non-bold, i.e. inherited, in the property pages).CommandandWorking Directoryare now empty, the project does not start, and Visual Studio asks you to check the debug settings. Re-entering them by hand does not help, they are cleared again on the next launch.Cause
GetWorkDirForProjectandGetLaunchAppForProjectstart withvar result = "";and return that empty string when the project has no item of the corresponding type.GetEnvVarsForProjectlikewise returns an empty dictionary.UpdateProjectConfigonly skips writing a value when it isnull, so the empty string is written through to the project, and an emptylands in the
.vcxproj.user. Those elements override the values inherited from the.vcxproj, so the effective values become empty.Fix
Distinguish the two cases that were previously conflated:
null""This preserves the existing uncheck-to-clear behaviour while no longer touching settings the extension was never asked to manage.
AggregateComamndLineItemsForProjectgained anincludeUncheckedflag so the "does an item of this type exist at all?" question can be answered without a second, differently-filtered tree walk. Only unchecked filtering is affected — the project-configuration and launch-profile filters still apply, so the result stays scoped to the active configuration.Note that flattening first and filtering on
IsCheckedafterwards is equivalent to the previous per-container filtering, becauseCmdContainer.UpdateCheckedStateonly reportsfalsewhen all children are unchecked.CreateCommandLineArgsForProjectis deliberately unchanged — returning""for arguments is correct there, since clearing arguments is the core feature.Tests
Four tests added to
ItemAggregationServiceTests:GetWorkDirForProject_ShouldReturnNull_WhenProjectHasNoWorkDirItemGetWorkDirForProject_ShouldReturnEmpty_WhenWorkDirItemIsUncheckedGetLaunchAppForProject_ShouldReturnNull_WhenProjectHasNoLaunchAppItemGetEnvVarsForProject_ShouldReturnNull_WhenProjectHasNoEnvVarItemFull suite: 39/39 passing.
Notes
GetEnvVarsForProjectcan now returnnull. The only other caller (ToolWindowViewModel) already null-checks its result.