-
It's looking very easy but I've not found the solution (: I've tried the next ways:
But both ways throw exception when child node (Class) is renamed after parent node (Namespace). |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 17 replies
-
You'll likely need to acquire 'classSymbol' after the first rename has happened. Solutions/compilations/symbols are all snapshots and aren't going to be valid against a different Solution snapshot. |
Beta Was this translation helpful? Give feedback.
-
I'm making CodeRefactoringProvider. I'm getting all symbols within span and then renaming them.
|
Beta Was this translation helpful? Give feedback.
-
The alternate way is to make each rename independently against the original solution. Then determine the changes that were made (there's a helper for this), and then merge all the changes to end up with one total change to make to the solution to get to the end result. This is similar to how batch fixing works. We just try to run all the fixes against the original solution. And we attempt to merge the changes. |
Beta Was this translation helpful? Give feedback.
-
Also, just as an FYI, thse discussions may be better suited to discord.gg/csharp (#roslyn channel). |
Beta Was this translation helpful? Give feedback.
-
Ahaha,
@CyrusNajmabadi P.S. Unfortunately, discussions are not very comfortable. Answers and replies are very similar in style. |
Beta Was this translation helpful? Give feedback.
Ahaha,
DescendantTokens
returns nodes in parent-child order, so I just need to useReverse
function to get child-parent order.