Replies: 1 comment
-
You cannot rename the original definition of the symbol, because it's external.
In this case, you should rename the identifier at call sites instead. You may manually replicate of the implementation of renamer, and keep the rename of callers only. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I need to rename the methods and properties used in my solution that come from a third-party library. Because the methods and properties exposed by the third-party library are not always stable and may undergo disruptive or incompatible changes.
Here is my approach:
In step 1, I use
syntaxRoot.DescendandNodes().OfType<IndentifierNameSyntax>()
to find them and collect their symbol, here's my code:In step 2, I use SQLite to read all the names of the APIs before and after modification. But this doesn't really affect the outcome, we can simply understand that based on the original name, a new name is generated.
However, I am encountering an exception when executing step 3, Here's my code:
Based on my understanding, this should indicate that the symbol corresponding to IdentifierNameSyntax is not declared in the solution, hence it cannot be modified.
I am new to Roslyn, so the above ideas might be wrong. If that is the case, please forgive me and tell me what the correct approach should be, such as using regex replacement to make modifications?
Beta Was this translation helpful? Give feedback.
All reactions