-
Notifications
You must be signed in to change notification settings - Fork 735
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
.NET 6.0 Enumerable.MaxBy conflicts with Enumerable.MaxBy #1647
Comments
Actually the return type is different as it is a List for IX but a single value for .NET 6. |
We'll get this fixed soon. Are there any other conflicts due to new methods/overrides? |
That's the only one I noticed but I'm not sure if there are any others. |
Fixed in 5.1. |
Hi @clairernovotny What do you think? |
@terrajobst @bartdesmet for naming/suggestions. |
If i'm not mistaken the problem with ambiguity is bigger and solution provided for MaxBy/MinBy in 5.1 might be accidentally broken after future minor and major .NET releases Current pattern for solving ambiguity that i see in sources is wrapping duplicating methods with compiler directive for hiding method when referencing from some target frameworks from reference assembly. For example hiding of MaxBy was implemented by following directive (MinBy solution is simular):
Problem that i see in this solution is that we are checking especially that are we targeting .net6.0 listed in reference assembly project targetFrameworks: To fix it we must somehow set not just NET6_0, but something simular to NET6_0 || NET6_1 || NET7_0 ... Actually problem is already hurting us:
ref assembly at that time targeted:
Cs:
Problem reproduces only on net6.0 as it is explicitly targeted in reference assembly |
Using In Enumerable: In EnumerableEx: Given that the return type is different, I believe the only option to make the IX MaxBy available in .NET 6+ is to rename it to disambiguate. For example, it could be named |
@clement911 sure, you right that we need renaming to keep originnally conflicting, but still useful methods available from API My message is more about problems of existing "hiding" pattern. I just think that hiding conflicting method for keeping code compilable and adding renamed copies for specific frameworks for keeping functionality available is for sure related, but pretty parallel topics. So we can both set |
That would be great |
I've updated the code to use the |
What do the IX ones? Assuming they include ties, then |
The IX ones include ties. That's why they return a List. The .NET ones return a single object. |
|
@SicJG This is exactly what I am seeing in an attempt to upgrade my application to .net 6 today. Should a new issue be opened here? |
@bbarry i don't think so. Described problem was fixed in 4c248d2 and merged to main. |
Ix / Ix Async 6.0.1 were just published that have these fixes (and now include |
Thank you very much @clairernovotny |
.NET 6.0 introduces built-in methods for MaxBy/MinBy which have the same signature as the IX ones.
As a result, after upgrading to .NET 6.0, I get the following error:
The call is ambiguous between the following methods or properties: 'System.Linq.EnumerableEx.MaxBy<TSource, TKey>(System.Collections.Generic.IEnumerable, System.Func<TSource, TKey>)' and 'System.Linq.Enumerable.MaxBy<TSource, TKey>(System.Collections.Generic.IEnumerable, System.Func<TSource, TKey>)'
The text was updated successfully, but these errors were encountered: