-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix - local function - refactorings not available when selection is used #36592
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 - local function - refactorings not available when selection is used #36592
Conversation
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTreeExtensions.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/Shared/Extensions/SyntaxTreeExtensions.cs
Outdated
Show resolved
Hide resolved
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...res/CSharpTest/CodeActions/ConvertLocalFunctionToMethod/ConvertLocalFunctionToMethodTests.cs
Outdated
Show resolved
Hide resolved
|
Rework the fix with |
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
vo[|id Whatever()
{
}
|]I don't think you have to support that to begin with. |
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...res/CSharpTest/CodeActions/ConvertLocalFunctionToMethod/ConvertLocalFunctionToMethodTests.cs
Outdated
Show resolved
Hide resolved
Yes, this is the design of 'FullSpan'. The way tokens work in Roslyn is that the compiler does this:
This is a totally consistent view of hte world at the syntactic model level. Features can trust that this is exactly how tokens/nodes will be represented all the time. Now, given that consistency, features can write helpers accordingly that then map between what we want for the user and that syntactic representation that the parsers produce. |
|
@CyrusNajmabadi is it always true that parent's Span contains all children Spans? I.e can I be sure that when traversing the tree upwards the Spans will monotonously grow/stay the same? |
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
2301f69 to
c14307f
Compare
Yes. |
...res/CSharpTest/CodeActions/ConvertLocalFunctionToMethod/ConvertLocalFunctionToMethodTests.cs
Outdated
Show resolved
Hide resolved
...gs/ConvertLocalFunctionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
…tionToMethod/CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs Co-Authored-By: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
Co-Authored-By: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
|
Yep, figure that could be the issue as well (since I don't even have the file locally). Working on it ATM. |
9a924d8 to
51aef1c
Compare
|
Ok, after rebasing (and some fun with git & VS not liking that many changes while being open) I've found the code in question and it has empty Initialize which I suppose is the issue. Should I simply add pragmas ignore to ignore the two warnings? Or should I go with what the codefixes suggest? (I haven't looked into how the diagnosticssuppressor works so have no idea what option is the correct one). |
|
Following code is suggested by codefix: And what about concurrent exec? public sealed override void Initialize(AnalysisContext context)
{
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
}I'm pretty sure we want to neither REportDIagnostics (given what the comment above says |
|
@petrroll Thanks for the investigation. I think we should handle this as part of merge PR that merges master into release/dev16.3-preview1. @JoeRobich - are we seeing this build issue in the merge PR as well? If not, @petrroll it might be best to create a separate PR for this fix as it will make reviewing easier. Note that this is a change in compiler layer, so you would need 2 signoffs from the roslyn-compiler team. |
@petrroll I just added that feature into release\dev16.3-preview1 branch last week, and @sharwell separately moved our analyzer packages forward to 2.9.3 in master branch last week. The latter brought in the new analyzer that flags RS1025 and RS1026. I believe the correct fix is to just suppress this diagnostic for the |
|
As for the RS1015 it seems to me that it should be called with |
Sounds reasonable to me. |
|
Should I create a PR with fix for that or will you handle that? |
I was hoping this would be handled as part of regular merge PRs from master to release/dev16.3-preview1. @JoeRobich? |
WIP on fixing low-hanging fruits from #35180
Includes some new Helpers for determining whether current position/span is desirable for refactoring.