-
Notifications
You must be signed in to change notification settings - Fork 199
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
Add component source mapping #9672
Draft
jjonescz
wants to merge
8
commits into
dotnet:main
Choose a base branch
from
jjonescz:7213-ComponentMapping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+76
−9
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b4d8345
Add component mapping
jjonescz 4f409a1
Use in razor span mapping service
jjonescz 65e6d16
Use in razor document mapping service
jjonescz 84a83b7
Rename to GeneratedOnlyMappings
jjonescz 79f2331
Fixup more usages
jjonescz ae0914c
Merge branch 'main' into 7213-ComponentMapping
jjonescz cd8cf20
Fix spell check endpoint
jjonescz b751e89
Fixup symbols test
jjonescz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me a little nervous, as it would be surprising if spell check was the only endpoint that needed special handling of 0-length spans. eg does renaming a component error? Are there any diagnostics that could be reported on the typename, and therefore does the diagnostics endpoints have to be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what renaming a component should do even today (like renaming a file in VS doesn't update component type references even without this PR), but it doesn't error with this PR. Although it's probably slightly broken since in some cases (renaming type reference from C#), the
.razor
is updated to contain the new name at the beginning of the file. Do you know where that should be fixed?Diagnostics on the typename (e.g., when deriving from a static class) seem to be reported just fine on the first character of the razor file (even if the file is completely empty).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maryamariyan has good insight onto what renaming behavior is/should be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For rename initiated from a Razor file, things would go through document mapping service, and we could add a bool flag for whether we want to consider generated only mappings. Could pass in false for that in spell check too, etc.
The problem is renames initiated in C# code, which are handled entirely in Roslyn using the SpanMappingService to change where edits occur. The problem there is that sometimes we want that service to consider generated only spans, eg in Go To Def and Go To All search results, but sometimes we don't, like rename. Sadly the current API doesn't let us know what operation is happening.
Maybe we just leave it like this and see if anyone complains? We could, presumably on the tooling side, follow up with an API change in Roslyn perhaps, to add a flag to the span mapping service to indicate if the operation is going to perform an edit, or is just data retrieval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, I would be inclined not to break the experience like this, but it seems like a tooling's call :D
The alternative is I guess to first do the API change and only then merge this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled down the branch and gave this a try, and Go To Def from a Razor file works, Go To Def from a C# file works, but then shows an error (Roslyn issue we can file once this is in), and All-In-One search navigation works, but the filename still shows the generated file:
The latter is presumably because there is no
#line
. Would it be a problem to add that in future?All-in-all, from my testing, this PR doesn't make anything worse, and does fix a couple of gaps, so I have no problem with it going in. There might be oddities going on with rename making edits that then get overwritten or something, but it doesn't surface as any user facing problems, so its okay by me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reproducible even in
main
, so probably an orthogonal issue. It happens when you go to def from C# to a def of a C# class that's defined in razor (like a nested class, e.g.,@code { public class MyNestedClass { } }
that you can reference from a C# like_ = new MyComponent.MyNestedClass();
).I will look into that, thanks.
I'm not sure if you've seen this:
Test1.razor
referenced from another, e.g.,<LayoutView Layout="@(typeof(Test1))" />
.Test1
reference in thetypeof
.Example
.Test1.razor
, the wordExample
is writtenThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, yeah. I didn't notice that because I was just renaming
SurveyPrompt
toSurveyPrompt1
, and didn't notice that that had caused a1
to be added to the start of the document. That's not good.From a quick look, my suggestion for adding an element of why a span is being asked for won't work either, as it looks like Rename just uses Find All Refs to get refs to rename.