Ancestors

Written by Sebastian Schöner on 2024-11-27 at 10:20

In C#, Rider keeps suggesting replacing simple code with opaque pattern checks. They call this suggestion "Merge null/pattern checks into complex pattern". Maybe "replace simple thing with complex pattern" should have been a red flag to begin with.

And yes, I have turned this suggestion off now. But why is it even showing up in the first place?

=> View attached media | View attached media

=> More informations about this toot | More toots from sschoener@mastodon.gamedev.place

Toot

Written by nietras 👾 on 2024-11-27 at 10:26

@sschoener

Failures?.Count > 0;

?

=> More informations about this toot | More toots from nietras@mastodon.social

Descendants

Written by Sebastian Schöner on 2024-11-27 at 10:42

@nietras I don't dislike the original code, actually. It shows pretty clearly what the code is going to do: check against null, then fetch count and check against 0. I think "Failures?.Count > 0" is somewhat OK? The mental gymnastics to desugar the null-check is relatively low, but translating the "complex pattern" is just silly.

=> More informations about this toot | More toots from sschoener@mastodon.gamedev.place

Written by nietras 👾 on 2024-11-27 at 11:40

@sschoener I find succinct being better often, but also have to get used to some of the pattern based code, think mostly a question of getting used to it, perhaps. If succinct and clear, then fine. Think "is null" better than "== null", as equality has override issues etc.

Actually using Roslynators.Analyzers to enforce boolean expressions get simplified, handles many common review issues.

=> More informations about this toot | More toots from nietras@mastodon.social

Written by Sebastian Schöner on 2024-11-27 at 11:45

@nietras "is null" vs "== null" is a great point, thank you!

=> More informations about this toot | More toots from sschoener@mastodon.gamedev.place

Written by Jb Evain on 2024-11-27 at 14:33

@sschoener @nietras Unity overriding the meaning of == null for Unity objects adds another layer of mental load when dealing with this.

=> More informations about this toot | More toots from jbevain@mastodon.gamedev.place

Written by WildRikku on 2024-11-27 at 20:26

@jbevain @sschoener @nietras Rider does annotate that one though so you don't have to think of Unity's check yourself. Did the suggestion have a "Why does Rider suggest this?" thingy? I expected ?.Count like @nietras suggested when I started reading the code.

=> More informations about this toot | More toots from wildrikku@mastodon.gamedev.place

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113554434817658593
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
277.583075 milliseconds
Gemini-to-HTML Time
1.34137 milliseconds

This content has been proxied by September (3851b).