-
Notifications
You must be signed in to change notification settings - Fork 8
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
Custom colors for "this", "null" and "Action" #11
Comments
I'm not sure if all of these are possible but they are certainly good ideas and I'm going to keep them in mind if I wanted to add more features in the future. I also appreciate and accept any help coming from the user of this extension ;) |
I've started looking into the code for a bit. What I'm not sure about is how this actually gets executed since the ColorCoder.ColorCoderCore.GetTags method only seems to get called from the ColorCoderTaggerTests class? Because of this I'm also not sure about where the original data which gets parsed comes from. I'd assume the extension somehow gets this from the IDE's compiler (e.g. Roslyn) which then outputs a string (possibly html if that's why Span is used)? If so, is this a temporary string in memory or does it actually get saved to a file somewhere? If possible I'd like to look at its contents to understand the syntax better and to see if there's data in there which could be interpreted to allow for more custom colors. The GetSpan method seems to use this enum to differentiate the different cases: https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.symbolkind?view=roslyn-dotnet And finally there are the Preferences which need to be extended to allow setting additional colors but that's probably the easiest part. |
Yes you are correct about GetTagSpan. The ColorCoderTagger class inherits from an interface ITagger, that method only fulfills the interface. What's important is that it going to be used by ColorCoderTaggerProvider which in turn is going to be pick up by the framework. About the enum since ISymbol.Kind expects a type in Microsoft.CodeAnalysis I don't think we can use the second one that you've mentioned. |
Do you have any links describing this in more detail? I found this MS API page but it isnt very helpful: https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.text.tagging.itaggerprovider?view=visualstudiosdk-2019 Is it being called automatically like e.g. (since that's what I'm familiar with) Unity's Messages: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html ? I've found this page where at the bottom it says that Debugging should work by simply hitting F5: https://www.c-sharpcorner.com/article/creating-visual-studio-2019-extension/
Do you maybe have a project set up which does this but which you didnt commit to the repository? This would be super helpful for testing! Once that's set up it should allow using break points to look at the contents of certain variables and see if they contain values which can be used. I've found e.g. this stackoverflow answer where a simple string.Contains is used to check for a comment: https://stackoverflow.com/a/59855557 |
No I don't have any links, unfortunately the documentation for this kind of things are very hard to find. If you've installed the visual studio extension sdk and selected the primary (not the test) project it should run. |
Would it be possible to add support for the keywords "this" and "null"?
They are currently being controlled by the "Text Editor -> Keyword -> Foreground" setting.
I'd like to be able to set them to different colors from other keywords ("public", "private", "protected", etc., "void", "int", "float", etc.)
Also there's the "Action" keyword, as in e.g. "public event Action OnMyStateChanged;".
While it's possible to set a custom color for delegates, I have not yet found an option (in the default VS settings) to change the color for this keyword.
The text was updated successfully, but these errors were encountered: