Skip to content

Conversation

@davidwengier
Copy link
Member

Fixes an issue Andrew found in speedometer tests. When opening files and modifying them, before we migrate the document to the "real" project, things get out of sync.

Also matches some stacks on PRISM, but I think this bug was only introduced in the last two weeks, so I don't think its the only cause thats for sure.

@davidwengier davidwengier requested a review from a team as a code owner May 9, 2024 06:35
@davidwengier
Copy link
Member Author

Worth noting, both of these changes fix the issue at hand, but I feel like the existing behaviour in both cases is just objectively wrong, and only used to work because we guessed a project, and I think guessing is objectively wrong too.

new HostDocument(DocumentFilePath2, "C:/path/to/document2.cshtml"), CreateEmptyTextLoader());
});

using var listener = _projectManager.ListenToNotifications();
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need this listener?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't, thank you. Left over from copy-and-paste

new HostDocument(DocumentFilePath1, "other/document1.cshtml"), CreateTextLoader(SourceText.From("Hello")));
});

using var listener = _projectManager.ListenToNotifications();
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need this listener?

Copy link
Contributor

@alexgav alexgav left a comment

Choose a reason for hiding this comment

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

:shipit:

@davidwengier davidwengier enabled auto-merge May 9, 2024 20:42
newTargetPath = newTargetPath[projectDirectory.Length..];
}

var newHostDocument = new HostDocument(documentSnapshot.FilePath, newTargetPath, documentSnapshot.FileKind);
Copy link
Contributor

@maryamariyan maryamariyan May 9, 2024

Choose a reason for hiding this comment

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

I see that using the other HostDocument ctor may cause the logic to set FileKind to change, hopefully that's okay. (will no longer be null)

public HostDocument(string filePath, string targetPath)
: this(filePath, targetPath, fileKind: null)
{
}
public HostDocument(string filePath, string targetPath, string? fileKind)
{
FilePath = filePath ?? throw new ArgumentNullException(nameof(filePath));
TargetPath = targetPath ?? throw new ArgumentNullException(nameof(targetPath));
FileKind = fileKind ?? FileKinds.GetFileKindFromFilePath(filePath);
}

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 other constructor determines the file kind from the file path, and it seemed unnecessary to do that if we already know the file kind. If the file kind didn't match the file path (ie, somehow we had a .razor file with a kind of "mvc") then the previous code would have "fixed" it, whereas the current code will keep it, but I honestly don't know which of those situations is right or wrong.

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.

7 participants