-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add Enumerable.Reverse(this T[])
polyfill
#75104
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -879,6 +879,13 @@ public static bool SequenceEqual<T>(this IEnumerable<T>? first, IEnumerable<T>? | |
} | ||
} | ||
|
||
// https://github.com/dotnet/runtime/issues/107723 | ||
#if NET10_0_OR_GREATER | ||
public static IEnumerable<T> Reverse<T>(T[] source) => Enumerable.Reverse(source); | ||
#else | ||
public static IEnumerable<T> Reverse<T>(this T[] source) => Enumerable.Reverse(source); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably not correct to put this here. @jaredpar to confirm, but I'm concerned that we'll end up breaking ourselves when the bcl adds this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is fine. Problems could arise if we wrap this in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we should be able to mitigate this by wrapping this in #if !NET10_OR_GREATER By the time that we actually start targeting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't we potentially break in a torn dll scenario though? Or have we thoroughly removed any change of that at this point? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What teared scenario are you thinking of? This is just another API inside the compiler. The only impact that can happen is weirdness at compile time. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, we certainly had a tear like this when we had the EA dll. Have we gotten rid of all of those scenarios? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't have this type of tearing problem without the EA DLL There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, good idea about adding the |
||
#endif | ||
|
||
#if NETSTANDARD | ||
|
||
// Copied from https://github.com/dotnet/runtime/blob/main/src/libraries/System.Linq/src/System/Linq/Chunk.cs | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in
net10.0
though won't we get this method for free? Basically it would be coming from the BCL so we wouldn't need it at all.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the guidelines say to define the non-extension version for binary compatibility, or does that not apply here for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but what idiot wrote those guidelines? ;)
I looked back over the guidelines and I'm trying to decide why I added that particular section. I know the reason for creating the non-extension version was to avoid compile time ambiguities. I can't remember exactly why I didn't say "just remove it entirely". I'm guessing it was because there were cases where it was used by full name ...
Anyways, wrote that for a reason so lets follow it 😄