polyadic / funcky

Funcky is a Functional Library for C#
https://polyadic.github.io/funcky
Apache License 2.0
19 stars 3 forks source link

Funcky.Xunit - Analyzer for Assert.Equal with FunctionalAssert.Ok/Some/Error/etc. in the `actual` parameter #749

Open Mafii opened 1 year ago

Mafii commented 1 year ago

Rudimentary example without context:

image

Can be simplified to

image

bash commented 1 year ago

This would be the first analyzer that analyzes Funcky.Xunit 🚀

It should of course come with an accompanying code fix.

So in summary, this analyzer would suggest the following changes to users:

Instead of having a hardcoded list of FunctionalAssert methods to check, I suggest adding an attribute (naming idea off the top of my head [HasAssertEqualOverload]).

If you want to implement this and need some guidance to get started, you can give me a shout on Discord :)

janhohenheim commented 1 year ago

@Mafii any updates?

Mafii commented 1 year ago

Sounds good! I don't know if I want to do this, or what the timeline is, but it would be a useful feature, so let's see if and when it happens :)

bash commented 1 year ago

We need to be very careful for which cases we emit a warning.

There are two things to consider:

Mafii commented 1 year ago

That's tricky! Both would be fine - adding specializations for FunctionalAssert (that's a lot of effort) or not emitting the analyzer warning. I think the second one is easier, as it can be applied partially instead of having to cover all cases immediately