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
Bug in Move Type to Namespace refactoring - usings not added for namespaces in same file #50672
Comments
PR-Merge: #30896 (comment) It works if all types are fully qualified |
Should be fairly easy to fix, we can take this in 16.10. Marking help wanted in case anyone wants to take it before I get to it. |
Thanks for your response. I'm not sure how easy or difficult it is to fix. But the issue seems to be that partially qualified names are not handled correctly. |
@bernd5 agreed in some cases it could be complex, but not too bad. We can find references in current doc, fully qualify, add using to the new namespace, and use simplifier to remove unnecessary qualifications and namespace. References outside current doc should already be fixed |
Btw.: is it possible to access those refactorings from the public roslyn API surface? |
Yes. You can use VS's ISuggestedActionsSourceProvider to query for Roslyn's provider that exposes our code fix and code refactoring provideers (ISuggestedActionsSource). You can call |
Do you know where to find the implementation of the "move namespace" SuggestionAction? I want to move some classes (ClassDeclarationSyntax / ITypeSymbol) to a different namespace. |
@bernd5 what are you trying to do? That code doesn't have a public API. |
I have a huge library with a massive amount of types. If certain criteria are met I would like to move some of them to another namespace. |
Even the API / rewriter is not public - I could imagine to use the assembly :-). |
This is not a supported scenario. You could certainly look at teh code we've written and copy/paste for your own needs as appropriate. But we don't expose out individual APIs to accomplish this stuff (primarily because these APIs change all the time and we don't want to be locked into supporting something forever that limits our ability to respond to changes/issues in an efficient fashion). |
Version Used: Visual Studio 16.9.0 Preview 3.0
Sample Code:
Steps to Reproduce:
Foo
to NamespaceSomething.Else
Expected Behavior:
Working Code
Actual Behavior:
Compile Error
Code after refatoring:
Expected Code:
The text was updated successfully, but these errors were encountered: