C# read/write usage highlight not working (R# 2023.1, VS 2022 v17.5.4)
I have colors defined for Resharper Read Usage and Write Usage, but they're not working. Instead, I'm getting some gray background for both types of usage of variables declared "var" and then used in an expression. (It's also broken if I declare, say, an int, assign to it and use it in an expression).
If I disable Resharper, I get the coloring I want from VS.
How can I debug this? (Or, more preferably, solve it.)
Please sign in to leave a comment.
thank you for the report.
Could you please send us a sample project where we can reproduce the issue?
Also please send us the screenshots with this issue.
Thank you!
Hi, Olga, here's a screenshot. I have the project zipped up; how do I attach it?
thank you for the answer.
Please upload it here: https://uploads.jetbrains.com/ and share upload ID.
Thank you!
Upload id: 2023_05_24_8CgXYLq9yusXmLfQyVxY5v (file: SimpleHello.zip)
thank you for the project.
Have you tried to put the caret on 'nnn' and invoke 'ReSharper | Find | Highlight Usages in File' menu? Do you see highlightings?
Thank you!
Hi, Olga, that works fine, and shows the colors I expect, but I'm expecting it to work simply by placing the text cursor on the identifier, not with a manual turning-on/turning-off of highlighting.
Interestingly, it actually works correctly for a few seconds, but then I guess VS gets fully done with its startup processing and it doesn't work after that.
John.
Installed extensions:
I disabled as much of the Microsoft junk as I could (I'm pretty sure editor guidelines is not the problem). Looks like it works properly until exactly when inlays appear; then it switches to plain gray highlighting.
Specifically, the inlays that show names of function parameters:
Hello John,
Let me try to clarify the current implementation (ReSharper vs VS):
1. ReSharper automatically highlights usages of a symbol at caret with grey color by default (customizable).
2. ReSharper has a separate feature "Highlight Usages in File", it is a caret-independent highlighting that stays until you press Esc and applies different configurable colors to "Read" and "Write access" usages, you could invoke it in the menu: ReSharper | Find | Highlight Usages in File.
3. Visual Studio has a feature "Options | Text Editor | General | Show selection matches", it works when the user put a caret on a word and applies different configurable colors to "Read" and "Write access" usages too.
>Looks like it works properly until exactly when inlays appear; then it switches to plain gray highlighting.
When you open your project in VS, you can see VS feature working (while ReSharper is loading), and then ReSharper overrides it with the selected color (grey by default).
Please refer to items 1 and 2 above for proper usage of ReSharper highlighting features.
Thank you!
Hi, Olga, thanks. Could you be more specific about the settings I need to configure to get read/write highlight colors? I thought I had set it up properly, as shown in the images I'll insert below.
John.
Hello John,
please carefully separate "usage" functionality and their settings provided by VS and ReSharper: VS functionality works by default until ReSharper "usage" feature is not enabled. To enable\disable it please refer to ReSharper settings (ReSharper | Options | Code Inspection | Settings):
Please check the following settings to customize "ReSharper usage" feature:
>ReSharper automatically highlights usages of a symbol at caret with grey color by default (customizable).
To customize it please refer to "ReSharper usage of element under cursor" setting in VS menu "Options | Environment | Fonts and Colors".
>ReSharper has a separate feature "Highlight Usages in File", it is a caret-independent highlighting that stays until you press Esc and applies different configurable colors to "Read" and "Write access" usages, you could invoke it in the menu: ReSharper | Find | Highlight Usages in File.
To customize these colors please refer to "ReSharper Read usage" and "ReSharper Write usage" settings in VS menu "Options / Environment / Fonts and Colors".
Hi, Olga, thanks. This has always been set (I also set "Color identifiers" in that UI, but I just turned it off to match your screenshot). It's not working. (I've also restarted VS to be sure.)
please send me a screenshot containing the value of VS option of "ReSharper usage of element under cursor" setting in VS menu "Options | Environment | Fonts and Colors".
according to the setting value you just provided the behavior of the feature is correct.
If you instead would like to use VS "usage" feature, please turn off the ReSharper "usage" feature by disabling the follow setting: ReSharper | Options | Code Inspection | Settings | Highlight usages of the element under cursor
Thank you!
Pshew. Ok, it's working now. I was under the impression that things like "Resharper Read Usage" and "R# Write Usage" would work simply by placing the cursor on the token.
Y'all might want to clarify your docs to say that the two above color definitions work ONLY during an explicit, manual R# | Find | Highlight operation. And, that if you want read/write usages colored differently by simple cursor placement, you need to rely on VS, not R#.
John.
great that it works now for you.
Please feel free to contact us in case of any problems or questions.
Thank you!