diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 68d878fa1bacfd..fb6d6ddb0e990e 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -142,8 +142,17 @@ public static int SlowRuntimeTimeoutModifier public static bool IsStartingProcessesSupported => !IsiOS && !IstvOS; - public static bool IsSpeedOptimized => !IsSizeOptimized; - public static bool IsSizeOptimized => IsBrowser || IsWasi || IsAndroid || IsAppleMobile; + public static bool IsLinqSpeedOptimized => !IsLinqSizeOptimized; + public static bool IsLinqSizeOptimized => s_linqIsSizeOptimized.Value; + private static readonly Lazy s_linqIsSizeOptimized = new Lazy(ComputeIsLinqSizeOptimized); + private static bool ComputeIsLinqSizeOptimized() + { +#if NET + return (bool)typeof(Enumerable).GetMethod("get_IsSizeOptimized", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, Array.Empty()); +#else + return false; +#endif + } public static bool IsBrowserDomSupported => IsEnvironmentVariableTrue("IsBrowserDomSupported"); public static bool IsBrowserDomSupportedOrNotBrowser => IsNotBrowser || IsBrowserDomSupported; diff --git a/src/libraries/System.IO.Compression/tests/ZipArchive/zip_LargeFiles.cs b/src/libraries/System.IO.Compression/tests/ZipArchive/zip_LargeFiles.cs index b4623e653af84d..dbb91fc5523de0 100644 --- a/src/libraries/System.IO.Compression/tests/ZipArchive/zip_LargeFiles.cs +++ b/src/libraries/System.IO.Compression/tests/ZipArchive/zip_LargeFiles.cs @@ -9,7 +9,7 @@ namespace System.IO.Compression.Tests; [Collection(nameof(DisableParallelization))] public class zip_LargeFiles : ZipFileTestBase { - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized), nameof(PlatformDetection.Is64BitProcess))] // don't run it on slower runtimes + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMobile), nameof(PlatformDetection.Is64BitProcess))] // don't run it on slower runtimes [OuterLoop("It requires almost 12 GB of free disk space")] public static void UnzipOver4GBZipFile() { @@ -49,7 +49,7 @@ private static void FillWithHardToCompressData(byte[] buffer) Random.Shared.NextBytes(buffer); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized), nameof(PlatformDetection.Is64BitProcess))] // don't run it on slower runtimes + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMobile), nameof(PlatformDetection.Is64BitProcess))] // don't run it on slower runtimes [OuterLoop("It requires 5~6 GB of free disk space and a lot of CPU time for compressed tests")] [InlineData(false)] [InlineData(true)] diff --git a/src/libraries/System.IO.Packaging/tests/LargeFilesTests.Net.cs b/src/libraries/System.IO.Packaging/tests/LargeFilesTests.Net.cs index c073c09b8f92f7..ad93cf44172ee5 100644 --- a/src/libraries/System.IO.Packaging/tests/LargeFilesTests.Net.cs +++ b/src/libraries/System.IO.Packaging/tests/LargeFilesTests.Net.cs @@ -15,7 +15,7 @@ private static void FillWithHardToCompressData(byte[] buffer) Random.Shared.NextBytes(buffer); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized), nameof(PlatformDetection.Is64BitProcess))] // don't run it on slower runtimes + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotMobile), nameof(PlatformDetection.Is64BitProcess))] // don't run it on slower runtimes [InlineData(false)] [InlineData(true)] [OuterLoop("It requires 5~6 GB of free disk space and a lot of CPU time for compressed tests")] diff --git a/src/libraries/System.Linq/src/System.Linq.csproj b/src/libraries/System.Linq/src/System.Linq.csproj index 6bea440207f3a2..cbbec2028cf8d7 100644 --- a/src/libraries/System.Linq/src/System.Linq.csproj +++ b/src/libraries/System.Linq/src/System.Linq.csproj @@ -1,98 +1,85 @@ - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos + $(NetCoreAppCurrent) false - - - $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true - $(DefineConstants);OPTIMIZE_FOR_SIZE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libraries/System.Linq/src/System/Linq/AnyAll.cs b/src/libraries/System.Linq/src/System/Linq/AnyAll.cs index b236c6a6f1ac64..2e10e25db1c5a3 100644 --- a/src/libraries/System.Linq/src/System/Linq/AnyAll.cs +++ b/src/libraries/System.Linq/src/System/Linq/AnyAll.cs @@ -20,8 +20,7 @@ public static bool Any(this IEnumerable source) return gc.Count != 0; } -#if !OPTIMIZE_FOR_SIZE - if (source is Iterator iterator) + if (!IsSizeOptimized && source is Iterator iterator) { int count = iterator.GetCount(onlyIfCheap: true); if (count >= 0) @@ -32,7 +31,6 @@ public static bool Any(this IEnumerable source) iterator.TryGetFirst(out bool found); return found; } -#endif if (source is ICollection ngc) { diff --git a/src/libraries/System.Linq/src/System/Linq/Count.cs b/src/libraries/System.Linq/src/System/Linq/Count.cs index 85bb624800d9d3..6a12a11cbe163d 100644 --- a/src/libraries/System.Linq/src/System/Linq/Count.cs +++ b/src/libraries/System.Linq/src/System/Linq/Count.cs @@ -20,12 +20,10 @@ public static int Count(this IEnumerable source) return collectionoft.Count; } -#if !OPTIMIZE_FOR_SIZE - if (source is Iterator iterator) + if (!IsSizeOptimized && source is Iterator iterator) { return iterator.GetCount(onlyIfCheap: false); } -#endif if (source is ICollection collection) { @@ -115,8 +113,7 @@ public static bool TryGetNonEnumeratedCount(this IEnumerable s return true; } -#if !OPTIMIZE_FOR_SIZE - if (source is Iterator iterator) + if (!IsSizeOptimized && source is Iterator iterator) { int c = iterator.GetCount(onlyIfCheap: true); if (c >= 0) @@ -125,7 +122,6 @@ public static bool TryGetNonEnumeratedCount(this IEnumerable s return true; } } -#endif if (source is ICollection collection) { diff --git a/src/libraries/System.Linq/src/System/Linq/ElementAt.cs b/src/libraries/System.Linq/src/System/Linq/ElementAt.cs index 97b87f9eba9999..26c69366fa9f3b 100644 --- a/src/libraries/System.Linq/src/System/Linq/ElementAt.cs +++ b/src/libraries/System.Linq/src/System/Linq/ElementAt.cs @@ -23,9 +23,7 @@ public static TSource ElementAt(this IEnumerable source, int i bool found; TSource? element = -#if !OPTIMIZE_FOR_SIZE - source is Iterator iterator ? iterator.TryGetElementAt(index, out found) : -#endif + !IsSizeOptimized && source is Iterator iterator ? iterator.TryGetElementAt(index, out found) : TryGetElementAtNonIterator(source, index, out found); if (!found) @@ -123,9 +121,7 @@ public static TSource ElementAt(this IEnumerable source, Index } return -#if !OPTIMIZE_FOR_SIZE - source is Iterator iterator ? iterator.TryGetElementAt(index, out found) : -#endif + !IsSizeOptimized && source is Iterator iterator ? iterator.TryGetElementAt(index, out found) : TryGetElementAtNonIterator(source, index, out found); } diff --git a/src/libraries/System.Linq/src/System/Linq/Enumerable.cs b/src/libraries/System.Linq/src/System/Linq/Enumerable.cs index fbdf9a12a28b65..8e5571ddda534e 100644 --- a/src/libraries/System.Linq/src/System/Linq/Enumerable.cs +++ b/src/libraries/System.Linq/src/System/Linq/Enumerable.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -9,6 +10,9 @@ namespace System.Linq { public static partial class Enumerable { + [FeatureSwitchDefinition("System.Linq.Enumerable.IsSizeOptimized")] + internal static bool IsSizeOptimized { get; } = AppContext.TryGetSwitch("System.Linq.Enumerable.IsSizeOptimized", out bool isEnabled) ? isEnabled : false; + public static IEnumerable AsEnumerable(this IEnumerable source) => source; /// Returns an empty . diff --git a/src/libraries/System.Linq/src/System/Linq/First.cs b/src/libraries/System.Linq/src/System/Linq/First.cs index fc97996d480dd7..814943c94438d8 100644 --- a/src/libraries/System.Linq/src/System/Linq/First.cs +++ b/src/libraries/System.Linq/src/System/Linq/First.cs @@ -70,9 +70,7 @@ public static TSource FirstOrDefault(this IEnumerable source, } return -#if !OPTIMIZE_FOR_SIZE - source is Iterator iterator ? iterator.TryGetFirst(out found) : -#endif + !IsSizeOptimized && source is Iterator iterator ? iterator.TryGetFirst(out found) : TryGetFirstNonIterator(source, out found); } diff --git a/src/libraries/System.Linq/src/System/Linq/Iterator.cs b/src/libraries/System.Linq/src/System/Linq/Iterator.cs index 8d5982eb0b9b49..00da01cb25cb80 100644 --- a/src/libraries/System.Linq/src/System/Linq/Iterator.cs +++ b/src/libraries/System.Linq/src/System/Linq/Iterator.cs @@ -88,11 +88,9 @@ public Iterator GetEnumerator() /// The type of the mapped items. /// The selector used to map each item. public virtual IEnumerable Select(Func selector) => -#if OPTIMIZE_FOR_SIZE - new IEnumerableSelectIterator(this, selector); -#else - new IteratorSelectIterator(this, selector); -#endif + !IsSizeOptimized + ? new IteratorSelectIterator(this, selector) + : new IEnumerableSelectIterator(this, selector); /// diff --git a/src/libraries/System.Linq/src/System/Linq/Last.cs b/src/libraries/System.Linq/src/System/Linq/Last.cs index 9de082deffa7a5..ca48475259d8e5 100644 --- a/src/libraries/System.Linq/src/System/Linq/Last.cs +++ b/src/libraries/System.Linq/src/System/Linq/Last.cs @@ -69,9 +69,7 @@ public static TSource LastOrDefault(this IEnumerable source, F } return -#if !OPTIMIZE_FOR_SIZE - source is Iterator iterator ? iterator.TryGetLast(out found) : -#endif + !IsSizeOptimized && source is Iterator iterator ? iterator.TryGetLast(out found) : TryGetLastNonIterator(source, out found); } diff --git a/src/libraries/System.Linq/src/System/Linq/Skip.SizeOpt.cs b/src/libraries/System.Linq/src/System/Linq/Skip.SizeOpt.cs index 3704526903ece1..13e6642ee1fc02 100644 --- a/src/libraries/System.Linq/src/System/Linq/Skip.SizeOpt.cs +++ b/src/libraries/System.Linq/src/System/Linq/Skip.SizeOpt.cs @@ -7,7 +7,7 @@ namespace System.Linq { public static partial class Enumerable { - private static IEnumerable SkipIterator(IEnumerable source, int count) + private static IEnumerable SizeOptimizedSkipIterator(IEnumerable source, int count) { using IEnumerator e = source.GetEnumerator(); while (count > 0 && e.MoveNext()) count--; diff --git a/src/libraries/System.Linq/src/System/Linq/Skip.SpeedOpt.cs b/src/libraries/System.Linq/src/System/Linq/Skip.SpeedOpt.cs index 74ff73a068242c..4de9afbbbfb47b 100644 --- a/src/libraries/System.Linq/src/System/Linq/Skip.SpeedOpt.cs +++ b/src/libraries/System.Linq/src/System/Linq/Skip.SpeedOpt.cs @@ -7,7 +7,7 @@ namespace System.Linq { public static partial class Enumerable { - private static IEnumerable SkipIterator(IEnumerable source, int count) => + private static IEnumerable SpeedOptimizedSkipIterator(IEnumerable source, int count) => source is IList sourceList ? (IEnumerable)new IListSkipTakeIterator(sourceList, count, int.MaxValue) : new IEnumerableSkipTakeIterator(source, count, -1); diff --git a/src/libraries/System.Linq/src/System/Linq/Skip.cs b/src/libraries/System.Linq/src/System/Linq/Skip.cs index 6b565670fe6903..ac8252a07c6d0c 100644 --- a/src/libraries/System.Linq/src/System/Linq/Skip.cs +++ b/src/libraries/System.Linq/src/System/Linq/Skip.cs @@ -30,14 +30,12 @@ public static IEnumerable Skip(this IEnumerable sourc count = 0; } -#if !OPTIMIZE_FOR_SIZE - else if (source is Iterator iterator) + else if (!IsSizeOptimized && source is Iterator iterator) { return iterator.Skip(count) ?? Empty(); } -#endif - return SkipIterator(source, count); + return IsSizeOptimized ? SizeOptimizedSkipIterator(source, count) : SpeedOptimizedSkipIterator(source, count); } public static IEnumerable SkipWhile(this IEnumerable source, Func predicate) diff --git a/src/libraries/System.Linq/src/System/Linq/Take.SizeOpt.cs b/src/libraries/System.Linq/src/System/Linq/Take.SizeOpt.cs index f61b01ee57773a..6f2bd0d9b0fa6b 100644 --- a/src/libraries/System.Linq/src/System/Linq/Take.SizeOpt.cs +++ b/src/libraries/System.Linq/src/System/Linq/Take.SizeOpt.cs @@ -8,7 +8,7 @@ namespace System.Linq { public static partial class Enumerable { - private static IEnumerable TakeIterator(IEnumerable source, int count) + private static IEnumerable SizeOptimizedTakeIterator(IEnumerable source, int count) { Debug.Assert(count > 0); @@ -19,7 +19,7 @@ private static IEnumerable TakeIterator(IEnumerable s } } - private static IEnumerable TakeRangeIterator(IEnumerable source, int startIndex, int endIndex) + private static IEnumerable SizeOptimizedTakeRangeIterator(IEnumerable source, int startIndex, int endIndex) { Debug.Assert(source is not null); Debug.Assert(startIndex >= 0 && startIndex < endIndex); diff --git a/src/libraries/System.Linq/src/System/Linq/Take.SpeedOpt.cs b/src/libraries/System.Linq/src/System/Linq/Take.SpeedOpt.cs index 81025ee21d0b4b..b5ec96ab3a0f12 100644 --- a/src/libraries/System.Linq/src/System/Linq/Take.SpeedOpt.cs +++ b/src/libraries/System.Linq/src/System/Linq/Take.SpeedOpt.cs @@ -8,7 +8,7 @@ namespace System.Linq { public static partial class Enumerable { - private static IEnumerable TakeIterator(IEnumerable source, int count) + private static IEnumerable SpeedOptimizedTakeIterator(IEnumerable source, int count) { Debug.Assert(source is not null && !IsEmptyArray(source)); Debug.Assert(count > 0); @@ -19,7 +19,7 @@ private static IEnumerable TakeIterator(IEnumerable s new IEnumerableSkipTakeIterator(source, 0, count - 1); } - private static IEnumerable TakeRangeIterator(IEnumerable source, int startIndex, int endIndex) + private static IEnumerable SpeedOptimizedTakeRangeIterator(IEnumerable source, int startIndex, int endIndex) { Debug.Assert(source is not null && !IsEmptyArray(source)); Debug.Assert(startIndex >= 0 && startIndex < endIndex); diff --git a/src/libraries/System.Linq/src/System/Linq/Take.cs b/src/libraries/System.Linq/src/System/Linq/Take.cs index 65feb8a3eb08b8..9df5fbc8a2bec8 100644 --- a/src/libraries/System.Linq/src/System/Linq/Take.cs +++ b/src/libraries/System.Linq/src/System/Linq/Take.cs @@ -15,9 +15,12 @@ public static IEnumerable Take(this IEnumerable sourc ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source); } - return count <= 0 || IsEmptyArray(source) ? - [] : - TakeIterator(source, count); + if (count <= 0 || IsEmptyArray(source)) + { + return []; + } + + return IsSizeOptimized ? SizeOptimizedTakeIterator(source, count) : SpeedOptimizedTakeIterator(source, count); } /// Returns a specified range of contiguous elements from a sequence. @@ -60,9 +63,12 @@ public static IEnumerable Take(this IEnumerable sourc } else if (!isEndIndexFromEnd) { - return startIndex >= endIndex ? - [] : - TakeRangeIterator(source, startIndex, endIndex); + if (startIndex >= endIndex) + { + return []; + } + + return IsSizeOptimized ? SizeOptimizedTakeRangeIterator(source, startIndex, endIndex) : SpeedOptimizedTakeRangeIterator(source, startIndex, endIndex); } return TakeRangeFromEndIterator(source, isStartIndexFromEnd, startIndex, isEndIndexFromEnd, endIndex); @@ -88,7 +94,10 @@ private static IEnumerable TakeRangeFromEndIterator(IEnumerabl if (startIndex < endIndex) { - foreach (TSource element in TakeRangeIterator(source, startIndex, endIndex)) + IEnumerable rangeIterator = IsSizeOptimized + ? SizeOptimizedTakeRangeIterator(source, startIndex, endIndex) + : SpeedOptimizedTakeRangeIterator(source, startIndex, endIndex); + foreach (TSource element in rangeIterator) { yield return element; } diff --git a/src/libraries/System.Linq/src/System/Linq/ToCollection.cs b/src/libraries/System.Linq/src/System/Linq/ToCollection.cs index 05e18b2382c8c6..c6654b6e4fff1b 100644 --- a/src/libraries/System.Linq/src/System/Linq/ToCollection.cs +++ b/src/libraries/System.Linq/src/System/Linq/ToCollection.cs @@ -11,12 +11,10 @@ public static partial class Enumerable { public static TSource[] ToArray(this IEnumerable source) { -#if !OPTIMIZE_FOR_SIZE - if (source is Iterator iterator) + if (!IsSizeOptimized && source is Iterator iterator) { return iterator.ToArray(); } -#endif if (source is ICollection collection) { @@ -64,12 +62,10 @@ public static List ToList(this IEnumerable source) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source); } -#if !OPTIMIZE_FOR_SIZE - if (source is Iterator iterator) + if (!IsSizeOptimized && source is Iterator iterator) { return iterator.ToList(); } -#endif return new List(source); } diff --git a/src/libraries/System.Linq/tests/ConcatTests.cs b/src/libraries/System.Linq/tests/ConcatTests.cs index 9ec1b5edf05867..53273b21d57e23 100644 --- a/src/libraries/System.Linq/tests/ConcatTests.cs +++ b/src/libraries/System.Linq/tests/ConcatTests.cs @@ -320,7 +320,7 @@ public static IEnumerable ManyConcatsData() yield return [Enumerable.Range(0, 500).Select(i => Enumerable.Repeat(i, 1)).Reverse()]; } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsLinqSpeedOptimized))] public void CountOfConcatIteratorShouldThrowExceptionOnIntegerOverflow() { var supposedlyLargeCollection = new DelegateBasedCollection { CountWorker = () => int.MaxValue }; diff --git a/src/libraries/System.Linq/tests/CountTests.cs b/src/libraries/System.Linq/tests/CountTests.cs index 33f19e47433d87..ecb87f924d6e54 100644 --- a/src/libraries/System.Linq/tests/CountTests.cs +++ b/src/libraries/System.Linq/tests/CountTests.cs @@ -178,10 +178,11 @@ public static IEnumerable NonEnumeratedCount_SupportedEnumerables() yield return WrapArgs(0, Enumerable.Empty()); - if (PlatformDetection.IsSpeedOptimized) + yield return WrapArgs(100, Enumerable.Range(1, 100)); + yield return WrapArgs(80, Enumerable.Repeat(1, 80)); + + if (PlatformDetection.IsLinqSpeedOptimized) { - yield return WrapArgs(100, Enumerable.Range(1, 100)); - yield return WrapArgs(80, Enumerable.Repeat(1, 80)); yield return WrapArgs(50, Enumerable.Range(1, 50).Select(x => x + 1)); yield return WrapArgs(4, new int[] { 1, 2, 3, 4 }.Select(x => x + 1)); yield return WrapArgs(50, Enumerable.Range(1, 50).Select(x => x + 1).Select(x => x - 1)); @@ -200,10 +201,8 @@ public static IEnumerable NonEnumeratedCount_UnsupportedEnumerables() yield return WrapArgs(new Stack([1, 2, 3, 4]).Select(x => x + 1)); yield return WrapArgs(Enumerable.Range(1, 100).Distinct()); - if (!PlatformDetection.IsSpeedOptimized) + if (!PlatformDetection.IsLinqSpeedOptimized) { - yield return WrapArgs(Enumerable.Range(1, 100)); - yield return WrapArgs(Enumerable.Repeat(1, 80)); yield return WrapArgs(Enumerable.Range(1, 50).Select(x => x + 1)); yield return WrapArgs(new int[] { 1, 2, 3, 4 }.Select(x => x + 1)); yield return WrapArgs(Enumerable.Range(1, 50).Select(x => x + 1).Select(x => x - 1)); diff --git a/src/libraries/System.Linq/tests/OrderedSubsetting.cs b/src/libraries/System.Linq/tests/OrderedSubsetting.cs index be6ae710101842..5804ac1d4229e7 100644 --- a/src/libraries/System.Linq/tests/OrderedSubsetting.cs +++ b/src/libraries/System.Linq/tests/OrderedSubsetting.cs @@ -224,7 +224,7 @@ public void TakeAndSkip() Assert.Equal(Enumerable.Range(10, 1), ordered.Take(11).Skip(10)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsLinqSpeedOptimized))] public void TakeAndSkip_DoesntIterateRangeUnlessNecessary() { Assert.Empty(Enumerable.Range(0, int.MaxValue).Take(int.MaxValue).OrderBy(i => i).Skip(int.MaxValue - 4).Skip(15)); diff --git a/src/libraries/System.Linq/tests/RangeTests.cs b/src/libraries/System.Linq/tests/RangeTests.cs index 4b143d51d8ce48..79a41f80fcca62 100644 --- a/src/libraries/System.Linq/tests/RangeTests.cs +++ b/src/libraries/System.Linq/tests/RangeTests.cs @@ -210,19 +210,19 @@ public void FirstOrDefault() Assert.Equal(-100, Enumerable.Range(-100, int.MaxValue).FirstOrDefault()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsLinqSpeedOptimized))] public void Last() { Assert.Equal(1000000056, Enumerable.Range(57, 1000000000).Last()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsLinqSpeedOptimized))] public void LastOrDefault() { Assert.Equal(int.MaxValue - 101, Enumerable.Range(-100, int.MaxValue).LastOrDefault()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsLinqSpeedOptimized))] public void IListImplementationIsValid() { Validate(Enumerable.Range(42, 10), [42, 43, 44, 45, 46, 47, 48, 49, 50, 51]); diff --git a/src/libraries/System.Linq/tests/RepeatTests.cs b/src/libraries/System.Linq/tests/RepeatTests.cs index 7ae3370660e0ec..e63a93c046fdfb 100644 --- a/src/libraries/System.Linq/tests/RepeatTests.cs +++ b/src/libraries/System.Linq/tests/RepeatTests.cs @@ -234,7 +234,7 @@ public void Count() Assert.Equal(42, Enumerable.Repeat("Test", 42).Count()); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsLinqSpeedOptimized))] public void ICollectionImplementationIsValid() { Validate(Enumerable.Repeat(42, 10), [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]); diff --git a/src/libraries/System.Linq/tests/SelectManyTests.cs b/src/libraries/System.Linq/tests/SelectManyTests.cs index 55e0e35a193d55..297b00e8aa0828 100644 --- a/src/libraries/System.Linq/tests/SelectManyTests.cs +++ b/src/libraries/System.Linq/tests/SelectManyTests.cs @@ -470,7 +470,7 @@ public static IEnumerable DisposeAfterEnumerationData() return lengths.SelectMany(l => lengths, (l1, l2) => new object[] { l1, l2 }); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsLinqSpeedOptimized))] [InlineData(new[] { int.MaxValue, 1 })] [InlineData(new[] { 2, int.MaxValue - 1 })] [InlineData(new[] { 123, 456, int.MaxValue - 100000, 123456 })] diff --git a/src/libraries/System.Linq/tests/TakeTests.cs b/src/libraries/System.Linq/tests/TakeTests.cs index b19b9c17d65163..299dfb24b776a0 100644 --- a/src/libraries/System.Linq/tests/TakeTests.cs +++ b/src/libraries/System.Linq/tests/TakeTests.cs @@ -1079,7 +1079,7 @@ public void RepeatEnumeratingNotList() Assert.Equal(taken5, taken5); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsLinqSpeedOptimized))] [InlineData(1000)] [InlineData(1000000)] [InlineData(int.MaxValue)] @@ -2033,7 +2033,7 @@ public void EmptySource_DoNotThrowException_EnumerablePartition() Assert.Empty(EnumerablePartitionOrEmpty(source).Take(^6..^7)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsSpeedOptimized))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsLinqSpeedOptimized))] public void SkipTakeOnIListIsIList() { IList list = new ReadOnlyCollection(Enumerable.Range(0, 100).ToList()); diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WasmFeatures.props b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WasmFeatures.props index c429f998d9befa..289b8c503a39fc 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WasmFeatures.props +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WasmFeatures.props @@ -3,6 +3,7 @@ false false false + true true false false