Skip to content
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

C# more edge cases for class styling #1371

Closed
PulsarFX opened this issue Mar 27, 2018 · 2 comments
Closed

C# more edge cases for class styling #1371

PulsarFX opened this issue Mar 27, 2018 · 2 comments

Comments

@PulsarFX
Copy link

PulsarFX commented Mar 27, 2018

After #1365 has been fixed, classes are styled when they are passed as parameters.
There are more cases, where classes get no coloring:


generics:
container.Register<Car>();
container.Register<IJuice, Juice>();
Bind<IWeapon>().To<Sword>();

grafik

expected coloring:
grafik


generics with lambdas:
var container = new Container(f =>
{
    f.For<IFoo>().Use<Foo>();
});

grafik

expected coloring:
grafik


overridden methods:
class LandAnimal { 
    public void Move() => Run(); }
class Dog : LandAnimal { 
    public new void Move() => Run(); }
class Works : LandAnimal { 
    public override void Move() => Run(); }

void is detected as class when preceeded by new instead of override.

grafik

expected coloring:
grafik


found another one for attributes:

[Required]
[Range(1, 10)]
public long PersId {
     get; set;
  }

// above is the common short of this:
 
[RequiredAttribute()]
[RangeAttribute(1, 10)]
public long PersId {
 get; set;
}

grafik

This is indeed a real edge case, as these are constructor calls. the first one is a parameterless ctor,
the second one has 2 params.

expected coloring:

grafik


this one is another attribute problem:
[ValidatePath(
    AllowEmptyStrings = false, 
    ErrorMessage = "must end with a slash")]
public string SearchDir { get; set; }

grafik

here we have properties which are allowed to be set in the ctor call. those are not arguments for the ctor, but properties of the ValidatePathAttribute class.
So ValidatePath should be colored as class, AllowEmptyStrings as property.

expected coloring:

grafik


(maybe it looks different for you, I sepratated the coloroing for class and function into different colors in the css.)

(Seems as if github has its problems, too. It does some funny coloring, too. ;-) )

@Golmote
Copy link
Contributor

Golmote commented Mar 28, 2018

Thanks for reporting.
As an introduction, remember that Prism is not a parser nor a linter, only a highlighter. It does not aim to be perfectly semantically accurate.

I played around with your examples a bit, and managed to end up with the following, where (for the sake of this example) functions are red and classes are dark green:

Looks good enough to me, can you confirm?

@PulsarFX
Copy link
Author

looks great 👍

@Golmote Golmote mentioned this issue Apr 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants