-
Notifications
You must be signed in to change notification settings - Fork 196
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
Including @using for Out-of-Scope Razor Component References #10651
Changes from 17 commits
0471dbf
1b6e035
cba6cf1
cf33fd7
019d6a4
dcee923
6e8d2aa
17479d4
2c4b709
5bab548
83703f6
33c66f4
b170f2a
5b7e0c6
3d9614c
d83031b
1c239a1
cd677c7
851fb45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -27,7 +27,8 @@ | |||||||
|
||||||||
namespace Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.Razor; | ||||||||
|
||||||||
internal sealed class ExtractToNewComponentCodeActionResolver( | ||||||||
internal sealed class ExtractToComponentCodeActionResolver | ||||||||
( | ||||||||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
IDocumentContextFactory documentContextFactory, | ||||||||
LanguageServerFeatureOptions languageServerFeatureOptions) : IRazorCodeActionResolver | ||||||||
{ | ||||||||
|
@@ -44,7 +45,7 @@ internal sealed class ExtractToNewComponentCodeActionResolver( | |||||||
return null; | ||||||||
} | ||||||||
|
||||||||
var actionParams = JsonSerializer.Deserialize<ExtractToNewComponentCodeActionParams>(data.GetRawText()); | ||||||||
var actionParams = JsonSerializer.Deserialize<ExtractToComponentCodeActionParams>(data.GetRawText()); | ||||||||
if (actionParams is null) | ||||||||
{ | ||||||||
return null; | ||||||||
|
@@ -90,7 +91,15 @@ internal sealed class ExtractToNewComponentCodeActionResolver( | |||||||
} | ||||||||
|
||||||||
var componentName = Path.GetFileNameWithoutExtension(componentPath); | ||||||||
var newComponentContent = text.GetSubTextString(new TextSpan(actionParams.ExtractStart, actionParams.ExtractEnd - actionParams.ExtractStart)).Trim(); | ||||||||
var newComponentContent = string.Empty; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use a StringBuilder, not just concatenate strings, and use a pooled one at that. |
||||||||
|
||||||||
newComponentContent += string.Join(Environment.NewLine, actionParams.usingDirectives); | ||||||||
if (actionParams.usingDirectives.Count > 0) | ||||||||
{ | ||||||||
newComponentContent += Environment.NewLine + Environment.NewLine; // Ensure there's a newline after the dependencies if any exist. | ||||||||
} | ||||||||
|
||||||||
newComponentContent += text.GetSubTextString(new CodeAnalysis.Text.TextSpan(actionParams.ExtractStart, actionParams.ExtractEnd - actionParams.ExtractStart)).Trim(); | ||||||||
|
||||||||
var start = componentDocument.Source.Text.Lines.GetLinePosition(actionParams.ExtractStart); | ||||||||
var end = componentDocument.Source.Text.Lines.GetLinePosition(actionParams.ExtractEnd); | ||||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Close but this is still wrong because this will be true for statements where a variable has
using
in the name (and worth adding a test for that case). I think this is correct but I'm coding in github so 🤷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.
Ahhh, you're right