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 issue where output path set in construction never updated the project update state #74791

Merged
merged 2 commits into from
Aug 17, 2024

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Aug 16, 2024

Resolves dotnet/vscode-csharp#7402

863962d added support to set the backing field for CompilationOutputAssemblyFilePath when creating the ProjectSystemProject. This had an issue where the project update state ever observed this value as it did not go through appropriate setter on CompilationOutputAssemblyFilePath which is responsible for updating that.

This caused us to later throw exceptions when attempting to remove that path as there was nothing to remove in the project update state.

I updated the code to instead update the path immediately after the ProjectSystemProject (and the corresponding solution) was created, which resolves the issue on the test project linked in the issue.

@dibarbet dibarbet requested a review from a team as a code owner August 16, 2024 21:28
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 16, 2024
Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved assuming testing with razor with and without cs devkit

@dibarbet
Copy link
Member Author

Approved assuming testing with razor with and without cs devkit

yup, seems to work in both cases

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test?

@@ -164,6 +163,10 @@ await ApplyChangeToWorkspaceAsync(w =>
onAfterUpdate: null);
}).ConfigureAwait(false);

// Set this value early after solution is created so it is available to Razor. This will get updated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why Razor is being commented here -- this is just doing the thing the API is asking us to do....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the early set was initially added for Razor here - 863962d

It does get set anyway later on when the cmdline is set.

@dibarbet dibarbet changed the title Fix issue where output path set in construction never updated the solution Fix issue where output path set in construction never updated the project update state Aug 16, 2024
@@ -164,6 +163,10 @@ await ApplyChangeToWorkspaceAsync(w =>
onAfterUpdate: null);
}).ConfigureAwait(false);

// Set this value early after solution is created so it is available to Razor. This will get updated
// when the command line is set, but we want a non-null value to be available as soon as possible.
project.CompilationOutputAssemblyFilePath = creationInfo.CompilationOutputAssemblyFilePath;
Copy link
Member

@JoeRobich JoeRobich Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this have essentially been the only change needed here?

_projectUpdateState = _projectUpdateState.WithProjectOutputPath(creationInfo.CompilationOutputAssemblyFilePath, creationInfo.ProjectId);

Copy link
Member Author

@dibarbet dibarbet Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly - but going through the same property setter as everything else feels safer.

@dibarbet dibarbet enabled auto-merge August 16, 2024 23:49
@dibarbet dibarbet merged commit 7d94086 into dotnet:main Aug 17, 2024
25 checks passed
@dibarbet dibarbet deleted the fix_early_set_output_path branch August 17, 2024 00:42
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 17, 2024
@dibarbet dibarbet modified the milestones: Next, 17.12 P2 Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LanguageServerProjectSystem Error while loading ...csproj
5 participants