Linq mutator proposal
See original GitHub issueI’m thinking about a cool new mutator for C#. There are a lot of LinQ methods that return the same interface, this makes them suitable for removing and switching. For example:
var query = someList.Where(x => x.Name == "Stryker").Distinct();
var query = someList.Where(x => x.Name == "Stryker"); // mutated
And
var query = someList.Where(x => x.Name == "Stryker").Reverse();
var query = someList.Where(x => x.Name == "Stryker"); // mutated
And
var query = someList.Where(x => x.Name == "Stryker").SingleOrDefault();
var query = someList.Where(x => x.Name == "Stryker").FirstOrDefault(); // mutated
What do you guys thinks about a mutator like this? Would this be useful, and if so, what kind of mutations should we make?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Equivalent to NEW operator that uses mutators instead of ...
Short Answer No you can not use mutators in JPQL. While I do not know LINQ I can not see this getting done...
Read more >Modernize Your C# Code - Part I: Properties
Actually, the idea of a mutator method (getter / setter) for a field is as ... A great feature in C# 3 has...
Read more >Dynamic filtering and sorting with Entity Framework
It is supposed to 'mutate' the query by applying a LINQ operator to it, ... SearchFieldMutators = new List<SearchFieldMutator<UserListItem, ...
Read more >Containers and Aggregates, Mutators and Isolates for ...
Containers and Aggregates, Mutators and Isolates for Reactive Programming. Aleksandar Prokopec ... We propose reactive isolates for concurrent reactive pro-.
Read more >Time to open up a can of worms: LINQ
LINQ enables type safe querying as a first-class construct from any ... terms, when I offer solutions to the very issue that the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So to further refine the issue, I suggest the following mutations:
Distinct()
Reverse()
OrderBy()
OrderByDescending()
SingleOrDefault()
FirstOrDefault()
FirstOrDefault()
SingleOrDefault()
First()
Last()
Last()
First()
All()
Any()
Any()
All()
Skip()
Take()
Take()
Skip()
SkipWhile()
TakeWhile()
TakeWhile()
SkipWhile()
Min()
Max()
Max()
Min()
Sum()
Count()
Count()
Sum()
@Michielpeeters No the mutations are not specific for Linq statements with Where, that was just an example query. I’m not mutating Where in the Linq mutator with reason because the expression in the Where() will already be mutated by Stryker. An example on how this mutator will work is:
would be mutated into
and
When you are sure your tests are correct and still no test fails when removing
.Distinct()
for example, maybe the.Distinct()
can be safely removed from your codebase. That way the mutation was still useful.