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
'this' extension method parameters aren't fontified #46
Comments
I can definitely reproduce this one. I do have a pretty clear idea of where this needs to be fixed. Unless someone beats me to the mark with a PR, I will look into this one later when I have time. Thanks for the report! |
Fooling around with the code, it seems they do get fontified if they are regular built-in types, but not custom types. Stepping through this using
Obviously this does not trigger for custom types (which should be fontified
We probably need to extend our fontification to have a Anyone want to take a stab at this, or should I just put it in the "later, when I have time"-queue? :) Edit: Following |
Hmm, I've got it working by adding the following to (c-lang-defconst c-primitive-type-kwds csharp '("this")) A side effect of it is that if you type |
How about scenarios where you pass self-references around using Depending on the style of code you write, I'm almost certain you may encounter that quite often, and I'm not sure making extension-methods work nicely is a good trade-off. If it isn't hell getting done right, I may consider it, but for now I'd rather add some more fontification-rules to the lot we already have. |
Please attach sources for testing font-lock, my C#-fu is weak. |
See below: using System;
namespace DemoSpace
{
public class DemoClass
{
private InnerClass _innerClass;
public DemoClass()
{
// note usage of plain "this".
_innerClass = new InnerClass(this);
}
}
public static class DemoClassExtensions
{
public static bool ExampleWithMemberType(this DemoClass instance, string foo)
{
// fontifies parameters incorrectly
return false;
}
public static bool ExampleWithBulitInType(this string instance, int bar)
{
// fontifies parameters correctly
return true;
}
}
} Does this properly illustrate the issue? (Annoyingly, Github DOES not have the bug we're trying to fix :) ) |
Yup, this is fontified as type. |
Trying to verify this fix, I cannot reproduce that it fixes method declarations (or does anything at all). Where in the file did you add this? |
I did add this at the end, then did |
I added it here, saved the file, restarted emacs and re-evaled You need to do that for proper testing in my experience. There's just too much eval-on-load thingies, I suspect. I still get the same issue about extension-methods not being fontified properly (but I do get the issue of Got any other ideas? :) |
@josteink |
Yeah works for me too. Once |
No big deal, but thought I'd log it anyway.
The text was updated successfully, but these errors were encountered: