Skip to content

Specialcase restore#8449

Closed
Forgind wants to merge 2 commits intodotnet:mainfrom
Forgind:specialcase-restore
Closed

Specialcase restore#8449
Forgind wants to merge 2 commits intodotnet:mainfrom
Forgind:specialcase-restore

Conversation

@Forgind
Copy link
Copy Markdown
Contributor

@Forgind Forgind commented Feb 15, 2023

Fixes #

Context

Changes Made

Testing

Notes

Copy link
Copy Markdown
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

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

Overall looks good to go - I have just couple minor comments for considering.

A oneliner description of the PR intent would be nice as well ;-)

finishedProjects++;
UpdateFooter();

if (restoringProjects > 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry I'm not very familiar with the the build events sequencing - is this the proper place? Or would the TargetFinished (for Restore target) be actually a better place?

Comment on lines +236 to +237
TerminalBufferLine? line = null; // TerminalBuffer.WriteNewLineAfterMidpoint($"{e.ProjectFile} is blocked by the MSBuild task.");
if (line is not null)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should the commented code be uncommented, or should all this be actually completely removed?

Comment on lines +247 to +251
if (!TerminalBuffer.IsRestoring)
{
if (blockedProjects.TryGetValue(e.ProjectFile, out int lineId))
if (e.TaskName.Equals("MSBuild"))
{
TerminalBuffer.DeleteLine(lineId);
if (projects.TryGetValue(e.BuildEventContext!.ProjectInstanceId, out ProjectNode? node))
if (blockedProjects.TryGetValue(e.ProjectFile, out int lineId))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: This looks like the condition should be just combined to get more compact and less indented code

return;
}
// Get project id
int id = e.BuildEventContext!.ProjectInstanceId;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know this is just copied, but I'd be more defensive here

int id = (e.?BuildEventContext ?? BuildEventContext.Invalid).ProjectInstanceId;

Copy link
Copy Markdown
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

I didn't finish the full review because I tried this out and it doesn't look like it's working:

image

Note that RestoreTask is running but it's not in "restore mode".

UpdateFooter();
ShouldRerender = true,
};
projects[id] = node;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why allocate new over mutating the existing one in the reentrance case?

projects[id] = node;
UpdateFooter();

if (e.TargetNames?.Contains("Restore") == true)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's worth it to explicitly specify OrdinalIgnoreCase here even if netfx makes us do it the ugly way

Suggested change
if (e.TargetNames?.Contains("Restore") == true)
if (e.TargetNames?.IndexOf("Restore", StringComparison.OrdinalIgnoreCase) > 0)

if (e.TargetNames?.Contains("Restore") == true)
{
TerminalBuffer.IsRestoring = true;
restoringProjects++;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand this counter--I expected something more like "remember the ID of the first project that starts Restore and be done when that project instance completes". Does that not work in some circumstance?

Comment on lines +121 to +122
$"MSBuild - Restore in progress - {FinishedProjects} finished projects" :
$"MSBuild - Build in progress - {FinishedProjects} finished projects";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Future item: I'd like the entrypoint project listed here, so the text becomes something like Restoring foo.csproj or Building bar.sln.

@rainersigwald rainersigwald modified the milestones: VS 17.6, VS 17.7 Mar 28, 2023
@rainersigwald
Copy link
Copy Markdown
Member

@Forgind should we close this since #8619 already has a special case?

@Forgind Forgind closed this Apr 4, 2023
@Forgind Forgind deleted the specialcase-restore branch April 4, 2023 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants