stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.78k stars 187 forks source link

Decoupling file excludability from mutant spans #2645

Open psfinaki opened 1 year ago

psfinaki commented 1 year ago

Phew... Okay so this is a somewhat bigger steps towards the F# support.

Motivation

F# has its own understanding of text documents (btw that's sad). Roslyn (in this context C#) generally counts all characters from zero whereas F# generally uses lines and columns. Of course one is convertible to the other, it's more about what's native to the compiler. Type-wise, it's Microsoft.CodeAnalysis.Text.TextSpan versus FSharp.Compiler.Text.Range.

Sooner or later we would need native span arithmetics for mutants hence one approach is to create a definition of mutant span on the user level (= configuration level) and then translate them to compiler definitions of spans based on the file type.

Implementation

This PR

TO DO

psfinaki commented 1 year ago

Unit tests pass, there are two integration tests failing, I will look into them.

Maintainers - please, before I continue on this. Do you think this is a reasonable design change? Is the current change something you approve "in principle"? :)

psfinaki commented 1 year ago

Ping @richardwerkman @rouke-broersma @dupdob :)

psfinaki commented 1 year ago

Okay sorry for the delay, I am back on this. Now tests pass, int tests pass, good stuff. Let me see if I can refactor things a bit and add some extra tests, I will let you know then :)

psfinaki commented 1 year ago

Okay, so this one is getting quite big and I promised small PRs :)

I extracted the changes to the following PR:

Let's address those ones first and then see what's left here. Meanwhile converting to draft again.

rouke-broersma commented 2 weeks ago

F# has its own understanding of text documents (btw that's sad). Roslyn (in this context C#) generally counts all characters from zero whereas F# generally uses lines and columns. Of course one is convertible to the other, it's more about what's native to the compiler. Type-wise, it's Microsoft.CodeAnalysis.Text.TextSpan versus FSharp.Compiler.Text.Range.

Sooner or later we would need native span arithmetics for mutants hence one approach is to create a definition of mutant span on the user level (= configuration level) and then translate them to compiler definitions of spans based on the file type.

This is more relevant than ever, due to work being done on a mutation server protocol for driving mutation testing from external sources such as IDE plugins. The protocol supports mutant spans, and defines them as 1-based. It would be practical to take mutant spans as 1-based in configuration and then convert them to whatever csharp and/or f# needs.

psfinaki commented 2 weeks ago

Sorry for being a very bad contributor recently 😢 my life was quite turbulent until very recently.

Things are settling up tho, also I got a lot of F# knowledge meanwhile and hope to get back on track with this during gray autumn and dark winter evenings.

rouke-broersma commented 2 weeks ago

Sorry for being a very bad contributor recently 😢 my life was quite turbulent until very recently.

Things are settling up tho, also I got a lot of F# knowledge meanwhile and hope to get back on track with this during gray autumn and dark winter evenings.

No worries, we haven't kicked you out yet ;D Life happens, hope all's well for you soon!