"Generate method" refactoring enabled if method name is equal to imported type.#23693
"Generate method" refactoring enabled if method name is equal to imported type.#23693jinujoseph merged 5 commits intodotnet:masterfrom
Conversation
| Friend Const BC30108 As String = "BC30108" ' error BC30108: 'Foo' is a type and cannot be used as an expression. | ||
| Friend Const BC30109 As String = "BC30109" ' error BC30109: 'Foo' is a class type and cannot be used as an expression. | ||
| Friend Const BC30110 As String = "BC30110" ' error BC30110: 'Foo' is a structure type and cannot be used as an expression. | ||
| Friend Const BC30111 As String = "BC30111" ' error BC30111: 'Foo' is an interface type and cannot be used as an expression. |
There was a problem hiding this comment.
Thanks for checking all these cases. It would have been easy to miss one.
Note: do we need a case for if 'Foo' is a delegate type?
There was a problem hiding this comment.
I see that you added one. Awesome!
| { | ||
| public void M1() | ||
| { | ||
| [|Foo|](); |
There was a problem hiding this comment.
Fyi: Foo can't be used in the codebase. You can easily rename this to Goo though.
| "Imports System | ||
| Class C | ||
| Sub Bar() | ||
| [|Foo|]() |
There was a problem hiding this comment.
Note: for VB we probably do not want to offer generate-method if you've just written Foo without parens. In that case, it's just not that likely htat you were attempting to create a method with that name, but were instead trying to reference the type.
If that's hte current behavior, great. Just please add a test. If that isn't the behavior, then we should add a check to have that behavior.
|
Thanks for the PR. I just hit this recently and it was super annoying :) |
|
@zaytsev-victor: Could you merge in the latest master? |
# Conflicts: # src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs
|
@DustinCampbell done. |
|
@dotnet-bot Test this please |
|
test windows_debug_vs-integration_prtest |
Fixes #16975
Ask Mode template not completed
Customer scenario
What does the customer do to get into this situation, and why do we think this
is common enough to address for this release. (Granted, sometimes this will be
obvious "Open project, VS crashes" but in general, I need to understand how
common a scenario is)
Bugs this fixes
(either VSO or GitHub links)
Workarounds, if any
Also, why we think they are insufficient for RC vs. RC2, RC3, or RTW
Risk
This is generally a measure our how central the affected code is to adjacent
scenarios and thus how likely your fix is to destabilize a broader area of code
Performance impact
(with a brief justification for that assessment (e.g. "Low perf impact because no extra allocations/no complexity changes" vs. "Low")
Is this a regression from a previous update?
Root cause analysis
How did we miss it? What tests are we adding to guard against it in the future?
How was the bug found?
(E.g. customer reported it vs. ad hoc testing)
Test documentation updated?
If this is a new non-compiler feature or a significant improvement to an existing feature, update https://github.com/dotnet/roslyn/wiki/Manual-Testing once you know which release it is targeting.