diff --git a/src/libraries/Common/src/Polyfills/ArrayPolyfills.cs b/src/libraries/Common/src/Polyfills/ArrayPolyfills.cs
new file mode 100644
index 00000000000000..c1b563bc84d9d9
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/ArrayPolyfills.cs
@@ -0,0 +1,13 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System;
+
+/// Provides downlevel polyfills for static members on .
+internal static class ArrayPolyfills
+{
+ extension(Array)
+ {
+ public static int MaxLength => 0x7FFFFFC7;
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/BitArrayPolyfills.cs b/src/libraries/Common/src/Polyfills/BitArrayPolyfills.cs
new file mode 100644
index 00000000000000..430aeaec2eece6
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/BitArrayPolyfills.cs
@@ -0,0 +1,26 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Collections;
+
+namespace System.Collections;
+
+/// Provides downlevel polyfills for instance methods on .
+internal static class BitArrayPolyfills
+{
+ extension(BitArray bitArray)
+ {
+ public bool HasAllSet()
+ {
+ for (int i = 0; i < bitArray.Count; i++)
+ {
+ if (!bitArray[i])
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/BitConverterPolyfills.cs b/src/libraries/Common/src/Polyfills/BitConverterPolyfills.cs
new file mode 100644
index 00000000000000..dd418d32f94406
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/BitConverterPolyfills.cs
@@ -0,0 +1,27 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System;
+
+/// Provides downlevel polyfills for static methods on .
+internal static class BitConverterPolyfills
+{
+ extension(BitConverter)
+ {
+ public static uint SingleToUInt32Bits(float value)
+ {
+ unsafe
+ {
+ return *(uint*)&value;
+ }
+ }
+
+ public static ulong DoubleToUInt64Bits(double value)
+ {
+ unsafe
+ {
+ return *(ulong*)&value;
+ }
+ }
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/BitOperationsPolyfills.cs b/src/libraries/Common/src/Polyfills/BitOperationsPolyfills.cs
new file mode 100644
index 00000000000000..780abeb26d2add
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/BitOperationsPolyfills.cs
@@ -0,0 +1,12 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Runtime.CompilerServices;
+
+namespace System.Numerics;
+
+internal static class BitOperations
+{
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static uint RotateLeft(uint value, int offset) => (value << offset) | (value >> (32 - offset));
+}
diff --git a/src/libraries/Common/src/Polyfills/CollectionsPolyfills.cs b/src/libraries/Common/src/Polyfills/CollectionsPolyfills.cs
new file mode 100644
index 00000000000000..414ad64bcf8d0b
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/CollectionsPolyfills.cs
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System.Collections.Generic;
+
+/// Provides downlevel polyfills for .
+internal static class KeyValuePairPolyfills
+{
+ public static void Deconstruct(this KeyValuePair source, out TKey key, out TValue value)
+ {
+ key = source.Key;
+ value = source.Value;
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/DateTimeOffsetPolyfills.cs b/src/libraries/Common/src/Polyfills/DateTimeOffsetPolyfills.cs
new file mode 100644
index 00000000000000..1dcbae615775ad
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/DateTimeOffsetPolyfills.cs
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System;
+
+/// Provides downlevel polyfills for instance members on .
+internal static class DateTimeOffsetPolyfills
+{
+ extension(DateTimeOffset value)
+ {
+ public int TotalOffsetMinutes =>
+ (int)(value.Offset.Ticks / TimeSpan.TicksPerMinute);
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/DictionaryPolyfills.cs b/src/libraries/Common/src/Polyfills/DictionaryPolyfills.cs
new file mode 100644
index 00000000000000..a6c1e9bce2b5c1
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/DictionaryPolyfills.cs
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System.Collections.Generic;
+
+/// Provides downlevel polyfills for instance methods on .
+internal static class DictionaryPolyfills
+{
+ public static bool TryAdd(this IDictionary dictionary, TKey key, TValue value)
+ {
+ if (!dictionary.ContainsKey(key))
+ {
+ dictionary.Add(key, value);
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/DoublePolyfills.cs b/src/libraries/Common/src/Polyfills/DoublePolyfills.cs
new file mode 100644
index 00000000000000..b469f1d17d8fc2
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/DoublePolyfills.cs
@@ -0,0 +1,20 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Runtime.CompilerServices;
+
+namespace System;
+
+/// Provides downlevel polyfills for static methods on .
+internal static class DoublePolyfills
+{
+ extension(double)
+ {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsFinite(double d)
+ {
+ long bits = BitConverter.DoubleToInt64Bits(d);
+ return ((ulong)~bits & 0x7FF0_0000_0000_0000UL) != 0;
+ }
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/EncodingPolyfills.cs b/src/libraries/Common/src/Polyfills/EncodingPolyfills.cs
new file mode 100644
index 00000000000000..6bfe09449f0508
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/EncodingPolyfills.cs
@@ -0,0 +1,81 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Text;
+
+/// Provides downlevel polyfills for span-based Encoding APIs.
+internal static class EncodingPolyfills
+{
+ public static unsafe int GetByteCount(this Encoding encoding, ReadOnlySpan chars)
+ {
+ fixed (char* charsPtr = &GetNonNullPinnableReference(chars))
+ {
+ return encoding.GetByteCount(charsPtr, chars.Length);
+ }
+ }
+
+ public static unsafe int GetCharCount(this Encoding encoding, ReadOnlySpan bytes)
+ {
+ fixed (byte* bytesPtr = &GetNonNullPinnableReference(bytes))
+ {
+ return encoding.GetCharCount(bytesPtr, bytes.Length);
+ }
+ }
+
+ public static int GetBytes(this Encoding encoding, string str, Span bytes)
+ {
+ return GetBytes(encoding, str.AsSpan(), bytes);
+ }
+
+ public static unsafe int GetBytes(this Encoding encoding, ReadOnlySpan chars, Span bytes)
+ {
+ fixed (char* charsPtr = &GetNonNullPinnableReference(chars))
+ fixed (byte* bytesPtr = &GetNonNullPinnableReference(bytes))
+ {
+ return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length);
+ }
+ }
+
+ public static unsafe int GetChars(this Encoding encoding, ReadOnlySpan bytes, Span chars)
+ {
+ fixed (byte* bytesPtr = &GetNonNullPinnableReference(bytes))
+ fixed (char* charsPtr = &GetNonNullPinnableReference(chars))
+ {
+ return encoding.GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length);
+ }
+ }
+
+ public static unsafe string GetString(this Encoding encoding, ReadOnlySpan bytes)
+ {
+ fixed (byte* bytesPtr = &GetNonNullPinnableReference(bytes))
+ {
+ return encoding.GetString(bytesPtr, bytes.Length);
+ }
+ }
+
+ public static bool TryGetChars(this Encoding encoding, ReadOnlySpan bytes, Span chars, out int charsWritten)
+ {
+ int charCount = encoding.GetCharCount(bytes);
+
+ if (charCount > chars.Length)
+ {
+ charsWritten = 0;
+ return false;
+ }
+
+ charsWritten = encoding.GetChars(bytes, chars);
+ Debug.Assert(charCount == charsWritten);
+ return true;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static unsafe ref readonly T GetNonNullPinnableReference(ReadOnlySpan buffer)
+ {
+ // Based on the internal implementation from MemoryMarshal.
+ return ref buffer.Length != 0 ? ref MemoryMarshal.GetReference(buffer) : ref Unsafe.AsRef((void*)1);
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/EnvironmentPolyfills.cs b/src/libraries/Common/src/Polyfills/EnvironmentPolyfills.cs
new file mode 100644
index 00000000000000..101515cb50ccc0
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/EnvironmentPolyfills.cs
@@ -0,0 +1,29 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Diagnostics;
+
+namespace System;
+
+/// Provides downlevel polyfills for static members on .
+internal static class EnvironmentPolyfills
+{
+ private static int s_processId;
+
+ extension(Environment)
+ {
+ public static int ProcessId
+ {
+ get
+ {
+ int processId = s_processId;
+ if (processId == 0)
+ {
+ using Process currentProcess = Process.GetCurrentProcess();
+ s_processId = processId = currentProcess.Id;
+ }
+ return processId;
+ }
+ }
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/GuidPolyfills.cs b/src/libraries/Common/src/Polyfills/GuidPolyfills.cs
new file mode 100644
index 00000000000000..8614e6f796d4c5
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/GuidPolyfills.cs
@@ -0,0 +1,33 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System;
+
+/// Provides downlevel polyfills for instance methods on .
+internal static class GuidPolyfills
+{
+ extension(Guid self)
+ {
+ public bool TryWriteBytes(Span destination)
+ {
+ if (destination.Length < 16)
+ return false;
+
+ ref Guid selfRef = ref Unsafe.AsRef(in self);
+ if (BitConverter.IsLittleEndian)
+ {
+ MemoryMarshal.Write(destination, ref selfRef);
+ }
+ else
+ {
+ // slower path for BigEndian
+ self.ToByteArray().AsSpan().CopyTo(destination);
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/HashCodePolyfills.cs b/src/libraries/Common/src/Polyfills/HashCodePolyfills.cs
new file mode 100644
index 00000000000000..7b2bc309c24bfd
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/HashCodePolyfills.cs
@@ -0,0 +1,24 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Runtime.InteropServices;
+
+namespace System;
+
+/// Provides downlevel polyfills for instance methods on .
+internal static class HashCodePolyfills
+{
+ public static void AddBytes(this ref HashCode hashCode, ReadOnlySpan value)
+ {
+ while (value.Length >= sizeof(int))
+ {
+ hashCode.Add(MemoryMarshal.Read(value));
+ value = value.Slice(sizeof(int));
+ }
+
+ foreach (byte b in value)
+ {
+ hashCode.Add(b);
+ }
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/RuntimeHelpersPolyfills.cs b/src/libraries/Common/src/Polyfills/RuntimeHelpersPolyfills.cs
new file mode 100644
index 00000000000000..0f60f78e1287d7
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/RuntimeHelpersPolyfills.cs
@@ -0,0 +1,34 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+
+namespace System.Runtime.CompilerServices;
+
+/// Provides downlevel polyfills for static methods on .
+internal static class RuntimeHelpersPolyfills
+{
+ extension(RuntimeHelpers)
+ {
+ public static bool TryEnsureSufficientExecutionStack()
+ {
+ try
+ {
+ RuntimeHelpers.EnsureSufficientExecutionStack();
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+ public static object GetUninitializedObject(Type type)
+ {
+#pragma warning disable SYSLIB0050 // FormatterServices.GetUninitializedObject is obsolete
+ return System.Runtime.Serialization.FormatterServices.GetUninitializedObject(type);
+#pragma warning restore SYSLIB0050
+ }
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/SinglePolyfills.cs b/src/libraries/Common/src/Polyfills/SinglePolyfills.cs
new file mode 100644
index 00000000000000..a654095a13e732
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/SinglePolyfills.cs
@@ -0,0 +1,20 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Runtime.CompilerServices;
+
+namespace System;
+
+/// Provides downlevel polyfills for static methods on .
+internal static class SinglePolyfills
+{
+ extension(float)
+ {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static unsafe bool IsFinite(float f)
+ {
+ uint bits = *(uint*)&f;
+ return (~bits & 0x7F80_0000U) != 0;
+ }
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/StopwatchPolyfills.cs b/src/libraries/Common/src/Polyfills/StopwatchPolyfills.cs
new file mode 100644
index 00000000000000..1608d36e9170e4
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/StopwatchPolyfills.cs
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Diagnostics;
+
+namespace System.Diagnostics;
+
+/// Provides downlevel polyfills for static methods on .
+internal static class StopwatchPolyfills
+{
+ private static readonly double s_tickFrequency = (double)TimeSpan.TicksPerSecond / Stopwatch.Frequency;
+
+ extension(Stopwatch)
+ {
+ public static TimeSpan GetElapsedTime(long startingTimestamp) =>
+ new((long)((Stopwatch.GetTimestamp() - startingTimestamp) * s_tickFrequency));
+
+ public static TimeSpan GetElapsedTime(long startingTimestamp, long endingTimestamp) =>
+ new((long)((endingTimestamp - startingTimestamp) * s_tickFrequency));
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/StreamPolyfills.cs b/src/libraries/Common/src/Polyfills/StreamPolyfills.cs
new file mode 100644
index 00000000000000..076f7faa5676ea
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/StreamPolyfills.cs
@@ -0,0 +1,32 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace System.IO;
+
+/// Provides downlevel polyfills for instance methods on .
+internal static class StreamPolyfills
+{
+ extension(Stream stream)
+ {
+ public void ReadExactly(byte[] buffer)
+ {
+ int totalRead = 0;
+ while (totalRead < buffer.Length)
+ {
+ int read = stream.Read(buffer, totalRead, buffer.Length - totalRead);
+ if (read == 0)
+ {
+ throw new EndOfStreamException();
+ }
+
+ totalRead += read;
+ }
+ }
+
+ public Task CopyToAsync(Stream destination, CancellationToken cancellationToken) =>
+ stream.CopyToAsync(destination, 81_920, cancellationToken); // 81_920 is the default buffer size used by Stream.CopyToAsync on .NET
+ }
+}
diff --git a/src/libraries/Common/src/Polyfills/TextWriterPolyfills.cs b/src/libraries/Common/src/Polyfills/TextWriterPolyfills.cs
new file mode 100644
index 00000000000000..cff559d3ca617d
--- /dev/null
+++ b/src/libraries/Common/src/Polyfills/TextWriterPolyfills.cs
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System.IO;
+
+/// Provides downlevel polyfills for instance methods on .
+internal static class TextWriterPolyfills
+{
+ extension(TextWriter writer)
+ {
+ public void Write(ReadOnlySpan value) =>
+ writer.Write(value.ToString());
+ }
+}
diff --git a/src/libraries/Common/src/System/Text/EncodingPolyfills.cs b/src/libraries/Common/src/System/Text/EncodingPolyfills.cs
deleted file mode 100644
index 9e2981db8f922d..00000000000000
--- a/src/libraries/Common/src/System/Text/EncodingPolyfills.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace System.Text
-{
- /// Provides downlevel polyfills for span-based Encoding APIs.
- internal static class EncodingPolyfills
- {
- public static unsafe int GetByteCount(this Encoding encoding, ReadOnlySpan chars)
- {
- fixed (char* charsPtr = &GetNonNullPinnableReference(chars))
- {
- return encoding.GetByteCount(charsPtr, chars.Length);
- }
- }
-
- public static unsafe int GetCharCount(this Encoding encoding, ReadOnlySpan bytes)
- {
- fixed (byte* bytesPtr = &GetNonNullPinnableReference(bytes))
- {
- return encoding.GetCharCount(bytesPtr, bytes.Length);
- }
- }
-
- public static int GetBytes(this Encoding encoding, string str, Span bytes)
- {
- return GetBytes(encoding, str.AsSpan(), bytes);
- }
-
- public static unsafe int GetBytes(this Encoding encoding, ReadOnlySpan chars, Span bytes)
- {
- fixed (char* charsPtr = &GetNonNullPinnableReference(chars))
- fixed (byte* bytesPtr = &GetNonNullPinnableReference(bytes))
- {
- return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length);
- }
- }
-
- public static unsafe int GetChars(this Encoding encoding, ReadOnlySpan bytes, Span chars)
- {
- fixed (byte* bytesPtr = &GetNonNullPinnableReference(bytes))
- fixed (char* charsPtr = &GetNonNullPinnableReference(chars))
- {
- return encoding.GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length);
- }
- }
-
- public static unsafe string GetString(this Encoding encoding, ReadOnlySpan bytes)
- {
- fixed (byte* bytesPtr = &GetNonNullPinnableReference(bytes))
- {
- return encoding.GetString(bytesPtr, bytes.Length);
- }
- }
-
- public static bool TryGetChars(this Encoding encoding, ReadOnlySpan bytes, Span chars, out int charsWritten)
- {
- int charCount = encoding.GetCharCount(bytes);
-
- if (charCount > chars.Length)
- {
- charsWritten = 0;
- return false;
- }
-
- charsWritten = encoding.GetChars(bytes, chars);
- Debug.Assert(charCount == charsWritten);
- return true;
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static unsafe ref readonly T GetNonNullPinnableReference(ReadOnlySpan buffer)
- {
- // Based on the internal implementation from MemoryMarshal.
- return ref buffer.Length != 0 ? ref MemoryMarshal.GetReference(buffer) : ref Unsafe.AsRef((void*)1);
- }
- }
-}
diff --git a/src/libraries/Common/tests/Common.Tests.csproj b/src/libraries/Common/tests/Common.Tests.csproj
index b665728750cc4b..dd184b098635f5 100644
--- a/src/libraries/Common/tests/Common.Tests.csproj
+++ b/src/libraries/Common/tests/Common.Tests.csproj
@@ -6,8 +6,8 @@
$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-osx
-
+
(this IDictionary dict, TKey key, TValue value)
- {
- if (!dict.ContainsKey(key))
- {
- dict.Add(key, value);
- return true;
- }
-
- return false;
- }
- }
-}
diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets
index c1f238a86bd203..b6fee26af35e3d 100644
--- a/src/libraries/Directory.Build.targets
+++ b/src/libraries/Directory.Build.targets
@@ -208,7 +208,7 @@
-
+
+
+
diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj b/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj
index a18b479fcea19c..ecdb05dc3eb4ff 100644
--- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj
+++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj
@@ -132,6 +132,7 @@ System.Diagnostics.DiagnosticSource
+
diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Base2ExponentialHistogramAggregator.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Base2ExponentialHistogramAggregator.cs
index 09043dd5b0df6c..d162b767882e8f 100644
--- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Base2ExponentialHistogramAggregator.cs
+++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Base2ExponentialHistogramAggregator.cs
@@ -172,7 +172,7 @@ public override IAggregationStatistics Collect()
public override void Update(double measurement)
{
- if (!IsFinite(measurement))
+ if (!double.IsFinite(measurement))
{
return;
}
@@ -232,7 +232,7 @@ public override void Update(double measurement)
/// Returns the index of the bucket.
public int MapToIndex(double value)
{
- Debug.Assert(IsFinite(value), "IEEE-754 +Inf, -Inf and NaN should be filtered out before calling this method.");
+ Debug.Assert(double.IsFinite(value), "IEEE-754 +Inf, -Inf and NaN should be filtered out before calling this method.");
Debug.Assert(value != 0, "IEEE-754 zero values should be handled by ZeroCount.");
Debug.Assert(value > 0, "IEEE-754 negative values should be normalized before calling this method.");
@@ -266,16 +266,6 @@ public int MapToIndex(double value)
}
}
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static bool IsFinite(double value)
- {
-#if NET
- return double.IsFinite(value);
-#else
- return !double.IsInfinity(value) && !double.IsNaN(value);
-#endif
- }
-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int LeadingZero64(long value)
{
diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/tests/System.Diagnostics.DiagnosticSource.Tests.csproj b/src/libraries/System.Diagnostics.DiagnosticSource/tests/System.Diagnostics.DiagnosticSource.Tests.csproj
index 1b3172278e278c..f96ce52f55badd 100644
--- a/src/libraries/System.Diagnostics.DiagnosticSource/tests/System.Diagnostics.DiagnosticSource.Tests.csproj
+++ b/src/libraries/System.Diagnostics.DiagnosticSource/tests/System.Diagnostics.DiagnosticSource.Tests.csproj
@@ -75,4 +75,8 @@
+
+
+
+
diff --git a/src/libraries/System.Formats.Cbor/src/System.Formats.Cbor.csproj b/src/libraries/System.Formats.Cbor/src/System.Formats.Cbor.csproj
index 0a0b502728f9c4..04dfc7a44cf491 100644
--- a/src/libraries/System.Formats.Cbor/src/System.Formats.Cbor.csproj
+++ b/src/libraries/System.Formats.Cbor/src/System.Formats.Cbor.csproj
@@ -49,6 +49,9 @@ System.Formats.Cbor.CborWriter
+
+
+
diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborConformanceLevel.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborConformanceLevel.cs
index b46066f061a5bc..bddd4c9c018502 100644
--- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborConformanceLevel.cs
+++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborConformanceLevel.cs
@@ -207,20 +207,7 @@ public static bool RequireCanonicalSimpleValueEncodings(CborConformanceMode conf
public static int GetKeyEncodingHashCode(ReadOnlySpan encoding)
{
HashCode hash = default;
-#if NET
hash.AddBytes(encoding);
-#else
- while (encoding.Length >= sizeof(int))
- {
- hash.Add(MemoryMarshal.Read(encoding));
- encoding = encoding.Slice(sizeof(int));
- }
-
- foreach (byte b in encoding)
- {
- hash.Add(b);
- }
-#endif
return hash.ToHashCode();
}
diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.Tag.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.Tag.cs
index 245c5eb0d3f458..a3b4cd4470e6f1 100644
--- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.Tag.cs
+++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.Tag.cs
@@ -38,11 +38,7 @@ public void WriteTag(CborTag tag)
public void WriteDateTimeOffset(DateTimeOffset value)
{
string dateString =
-#if NET
value.TotalOffsetMinutes == 0 ?
-#else
- value.Offset == TimeSpan.Zero ?
-#endif // NET
value.UtcDateTime.ToString(Rfc3339FormatString, CultureInfo.InvariantCulture) : // prefer 'Z' over '+00:00'
value.ToString(Rfc3339FormatString, CultureInfo.InvariantCulture);
diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.cs
index 12bf1f0a242b53..f233130cfef898 100644
--- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.cs
+++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.cs
@@ -241,11 +241,7 @@ private void EnsureWriteCapacity(int pendingCount)
if (currentCapacity < requiredCapacity)
{
int newCapacity = currentCapacity == 0 ? 1024 : currentCapacity * 2;
- const uint MaxArrayLength = 0x7FFFFFC7; // Array.MaxLength
-#if NET
- Debug.Assert(MaxArrayLength == Array.MaxLength);
-#endif
- if ((uint)newCapacity > MaxArrayLength || newCapacity < requiredCapacity)
+ if ((uint)newCapacity > (uint)Array.MaxLength || newCapacity < requiredCapacity)
{
newCapacity = requiredCapacity;
}
diff --git a/src/libraries/System.Formats.Nrbf/src/System.Formats.Nrbf.csproj b/src/libraries/System.Formats.Nrbf/src/System.Formats.Nrbf.csproj
index 056aa832e7d927..7be11b59ad80f2 100644
--- a/src/libraries/System.Formats.Nrbf/src/System.Formats.Nrbf.csproj
+++ b/src/libraries/System.Formats.Nrbf/src/System.Formats.Nrbf.csproj
@@ -17,5 +17,6 @@
+
diff --git a/src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/ArrayInfo.cs b/src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/ArrayInfo.cs
index dd045f7cd9e483..48527dee991541 100644
--- a/src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/ArrayInfo.cs
+++ b/src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/ArrayInfo.cs
@@ -16,11 +16,7 @@ namespace System.Formats.Nrbf;
[DebuggerDisplay("{ArrayType}, rank={Rank}")]
internal readonly struct ArrayInfo
{
-#if NET
- internal static int MaxArrayLength => Array.MaxLength; // dynamic lookup in case the value changes in a future runtime
-#else
- internal const int MaxArrayLength = 2147483591; // hardcode legacy Array.MaxLength for downlevel runtimes
-#endif
+ internal static int MaxArrayLength => Array.MaxLength;
internal ArrayInfo(SerializationRecordId id, long totalElementsCount, BinaryArrayType arrayType = BinaryArrayType.Single, int rank = 1)
{
diff --git a/src/libraries/System.IO.Hashing/src/System.IO.Hashing.csproj b/src/libraries/System.IO.Hashing/src/System.IO.Hashing.csproj
index 0a9790f49767db..c8767ed4b326fe 100644
--- a/src/libraries/System.IO.Hashing/src/System.IO.Hashing.csproj
+++ b/src/libraries/System.IO.Hashing/src/System.IO.Hashing.csproj
@@ -42,6 +42,7 @@ System.IO.Hashing.XxHash32
+
diff --git a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/NonCryptographicHashAlgorithm.cs b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/NonCryptographicHashAlgorithm.cs
index c9b9b0a6ba864a..1289b70496750d 100644
--- a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/NonCryptographicHashAlgorithm.cs
+++ b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/NonCryptographicHashAlgorithm.cs
@@ -127,9 +127,6 @@ public Task AppendAsync(Stream stream, CancellationToken cancellationToken = def
return stream.CopyToAsync(
new CopyToDestinationStream(this),
-#if !NET
- 81_920, // default size used by Stream.CopyTo{Async}
-#endif
cancellationToken);
}
diff --git a/src/libraries/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj b/src/libraries/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj
index 97ead77d068104..1352ecdfbcd1a6 100644
--- a/src/libraries/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj
+++ b/src/libraries/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj
@@ -223,8 +223,8 @@
-
+
diff --git a/src/libraries/System.Private.Xml.Linq/tests/TreeManipulation/System.Xml.Linq.TreeManipulation.Tests.csproj b/src/libraries/System.Private.Xml.Linq/tests/TreeManipulation/System.Xml.Linq.TreeManipulation.Tests.csproj
index ea539d2f80c484..1805fc4dd3f194 100644
--- a/src/libraries/System.Private.Xml.Linq/tests/TreeManipulation/System.Xml.Linq.TreeManipulation.Tests.csproj
+++ b/src/libraries/System.Private.Xml.Linq/tests/TreeManipulation/System.Xml.Linq.TreeManipulation.Tests.csproj
@@ -3,8 +3,8 @@
$(NetCoreAppCurrent)
-
+
diff --git a/src/libraries/System.Private.Xml.Linq/tests/xNodeBuilder/System.Xml.Linq.xNodeBuilder.Tests.csproj b/src/libraries/System.Private.Xml.Linq/tests/xNodeBuilder/System.Xml.Linq.xNodeBuilder.Tests.csproj
index 2f28c03a4f266d..65a781aa853eea 100644
--- a/src/libraries/System.Private.Xml.Linq/tests/xNodeBuilder/System.Xml.Linq.xNodeBuilder.Tests.csproj
+++ b/src/libraries/System.Private.Xml.Linq/tests/xNodeBuilder/System.Xml.Linq.xNodeBuilder.Tests.csproj
@@ -4,8 +4,8 @@
$(NetCoreAppCurrent)
-
+
diff --git a/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj b/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj
index 242a4c1f6a6f54..9cb8b293db3b83 100644
--- a/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj
+++ b/src/libraries/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj
@@ -93,7 +93,8 @@ The System.Reflection.Metadata library is built-in as part of the shared framewo
-
+
+
diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/Polyfills.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/Polyfills.cs
deleted file mode 100644
index 8c91c9ff15f59e..00000000000000
--- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/Polyfills.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace System
-{
- internal static class BitConverterPolyfills
- {
- extension(BitConverter)
- {
- public static uint SingleToUInt32Bits(float value)
- {
- unsafe
- {
- return *(uint*)&value;
- }
- }
-
- public static ulong DoubleToUInt64Bits(double value)
- {
- unsafe
- {
- return *(ulong*)&value;
- }
- }
- }
- }
-
- internal static class GuidPolyfills
- {
- extension(Guid self)
- {
- public bool TryWriteBytes(Span destination)
- {
- if (destination.Length < 16)
- return false;
-
- ref Guid selfRef = ref Unsafe.AsRef(in self);
- if (BitConverter.IsLittleEndian)
- {
- MemoryMarshal.Write(destination, ref selfRef);
- }
- else
- {
- // slower path for BigEndian
- self.ToByteArray().AsSpan().CopyTo(destination);
- }
-
- return true;
- }
- }
- }
-}
diff --git a/src/libraries/System.Security.Cryptography.Cose/src/System.Security.Cryptography.Cose.csproj b/src/libraries/System.Security.Cryptography.Cose/src/System.Security.Cryptography.Cose.csproj
index a448ec9e6322be..b2b23ba884f621 100644
--- a/src/libraries/System.Security.Cryptography.Cose/src/System.Security.Cryptography.Cose.csproj
+++ b/src/libraries/System.Security.Cryptography.Cose/src/System.Security.Cryptography.Cose.csproj
@@ -56,6 +56,7 @@
+
diff --git a/src/libraries/System.Security.Cryptography.Cose/src/System/Security/Cryptography/Cose/CoseHeaderValue.cs b/src/libraries/System.Security.Cryptography.Cose/src/System/Security/Cryptography/Cose/CoseHeaderValue.cs
index 3be45eca1a9bbf..a87d20454bcb28 100644
--- a/src/libraries/System.Security.Cryptography.Cose/src/System/Security/Cryptography/Cose/CoseHeaderValue.cs
+++ b/src/libraries/System.Security.Cryptography.Cose/src/System/Security/Cryptography/Cose/CoseHeaderValue.cs
@@ -252,14 +252,7 @@ public int GetValueAsBytes(Span destination)
public override int GetHashCode()
{
HashCode hashCode = default;
-#if NET
hashCode.AddBytes(EncodedValue.Span);
-#else
- foreach (byte b in EncodedValue.Span)
- {
- hashCode.Add(b);
- }
-#endif
return hashCode.ToHashCode();
}
diff --git a/src/libraries/System.ServiceModel.Syndication/src/System.ServiceModel.Syndication.csproj b/src/libraries/System.ServiceModel.Syndication/src/System.ServiceModel.Syndication.csproj
index c5f32e4efda4cb..be54549f6ff28a 100644
--- a/src/libraries/System.ServiceModel.Syndication/src/System.ServiceModel.Syndication.csproj
+++ b/src/libraries/System.ServiceModel.Syndication/src/System.ServiceModel.Syndication.csproj
@@ -67,4 +67,9 @@
+
+
+
+
+
diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs
index 966fd0feaf097b..37e5cd5c150aa8 100644
--- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs
+++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs
@@ -573,11 +573,7 @@ private static TextSyndicationContent ReadTextContentFromHelper(XmlReader reader
private static string AsString(DateTimeOffset dateTime)
{
-#if NET
if (dateTime.TotalOffsetMinutes == 0)
-#else
- if (dateTime.Offset == TimeSpan.Zero)
-#endif // NET
{
return dateTime.ToUniversalTime().ToString(Rfc3339UTCDateTimeFormat, CultureInfo.InvariantCulture);
}
diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs
index f8788e4b4cff7b..d6017df5aec154 100644
--- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs
+++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs
@@ -174,11 +174,7 @@ protected virtual void WriteItems(XmlWriter writer, IEnumerable
private static string AsString(DateTimeOffset dateTime)
{
-#if NET
if (dateTime.TotalOffsetMinutes == 0)
-#else
- if (dateTime.Offset == TimeSpan.Zero)
-#endif // NET
{
return dateTime.ToUniversalTime().ToString(Rfc822OutputUtcDateTimeFormat, CultureInfo.InvariantCulture);
}
diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/XmlBuffer.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/XmlBuffer.cs
index 4c31f32bf505a2..7a1b4a28f171e5 100644
--- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/XmlBuffer.cs
+++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/XmlBuffer.cs
@@ -87,20 +87,7 @@ public void Close()
_buffer = new byte[_stream.Length];
_stream.Position = 0;
-#if NET
_stream.ReadExactly(_buffer);
-#else
- int totalRead = 0;
- while (totalRead < _buffer.Length)
- {
- int bytesRead = _stream.Read(_buffer, totalRead, _buffer.Length - totalRead);
- if (bytesRead <= 0)
- {
- throw new EndOfStreamException();
- }
- totalRead += bytesRead;
- }
-#endif
_writer = null;
_stream = null;
diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/AudioBase.cs b/src/libraries/System.Speech/src/Internal/Synthesis/AudioBase.cs
index 8ea0dac7b1232d..12d95cd667750f 100644
--- a/src/libraries/System.Speech/src/Internal/Synthesis/AudioBase.cs
+++ b/src/libraries/System.Speech/src/Internal/Synthesis/AudioBase.cs
@@ -122,20 +122,7 @@ internal void PlayWaveFile(AudioData audio)
{
byte[] data = new byte[(int)audio._stream.Length];
-#if NET
audio._stream.ReadExactly(data);
-#else
- int totalRead = 0;
- while (totalRead < data.Length)
- {
- int bytesRead = audio._stream.Read(data, totalRead, data.Length - totalRead);
- if (bytesRead <= 0)
- {
- throw new EndOfStreamException();
- }
- totalRead += bytesRead;
- }
-#endif
Play(data);
}
diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs b/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs
index efed2d9a07aecf..95e1a30859835e 100644
--- a/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs
+++ b/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs
@@ -176,20 +176,7 @@ public int Volume
MemoryStream memStream = new(cLen);
byte[] ab = new byte[cLen];
-#if NET
stream.ReadExactly(ab);
-#else
- int totalRead = 0;
- while (totalRead < cLen)
- {
- int bytesRead = stream.Read(ab, totalRead, cLen - totalRead);
- if (bytesRead <= 0)
- {
- throw new EndOfStreamException();
- }
- totalRead += bytesRead;
- }
-#endif
_resourceLoader.UnloadFile(localPath);
memStream.Write(ab, 0, cLen);
diff --git a/src/libraries/System.Speech/src/System.Speech.csproj b/src/libraries/System.Speech/src/System.Speech.csproj
index ab974973218280..76f1feb71ff35e 100644
--- a/src/libraries/System.Speech/src/System.Speech.csproj
+++ b/src/libraries/System.Speech/src/System.Speech.csproj
@@ -35,6 +35,7 @@ System.Speech.Recognition.SpeechRecognizer
+
diff --git a/src/libraries/System.Text.Json/src/System.Text.Json.csproj b/src/libraries/System.Text.Json/src/System.Text.Json.csproj
index bd9a5dd0680aba..964cbb77d4425f 100644
--- a/src/libraries/System.Text.Json/src/System.Text.Json.csproj
+++ b/src/libraries/System.Text.Json/src/System.Text.Json.csproj
@@ -167,7 +167,6 @@ The System.Text.Json library is built-in as part of the shared framework in .NET
-
@@ -367,6 +366,11 @@ The System.Text.Json library is built-in as part of the shared framework in .NET
+
+
+
+
+
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.MetadataDb.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.MetadataDb.cs
index 20cdf3775c0a43..87ee6ca78d751c 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.MetadataDb.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.MetadataDb.cs
@@ -237,17 +237,10 @@ private void Enlarge()
byte[] toReturn = _data;
// Allow the data to grow up to maximum possible capacity (~2G bytes) before encountering overflow.
- // Note: Array.MaxLength exists only on .NET 6 or greater,
- // so for the other versions value is hardcoded
- const int MaxArrayLength = 0x7FFFFFC7;
-#if NET
- Debug.Assert(MaxArrayLength == Array.MaxLength);
-#endif
-
int newCapacity = toReturn.Length * 2;
// Note that this check works even when newCapacity overflowed thanks to the (uint) cast
- if ((uint)newCapacity > MaxArrayLength) newCapacity = MaxArrayLength;
+ if ((uint)newCapacity > Array.MaxLength) newCapacity = Array.MaxLength;
// If the maximum capacity has already been reached,
// then set the new capacity to be larger than what is possible
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonElement.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonElement.cs
index d791f189607e41..27cd31fd85fa40 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonElement.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonElement.cs
@@ -1257,7 +1257,7 @@ internal ReadOnlySpan ValueSpan
///
public static bool DeepEquals(JsonElement element1, JsonElement element2)
{
- if (!StackHelper.TryEnsureSufficientExecutionStack())
+ if (!RuntimeHelpers.TryEnsureSufficientExecutionStack())
{
ThrowHelper.ThrowInsufficientExecutionStackException_JsonElementDeepEqualsInsufficientExecutionStack();
}
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs b/src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs
index b551ef4dee1a56..ccfc08e7b384cd 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs
@@ -247,24 +247,6 @@ public static Dictionary CreateDictionaryFromCollection
/// Gets a Regex instance for recognizing integer representations of enums.
///
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.TryGet.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.TryGet.cs
index bef69db6770c99..fa4427656868eb 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.TryGet.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.TryGet.cs
@@ -605,7 +605,7 @@ internal float GetSingleWithQuotes()
// The following logic reconciles the two implementations to enforce consistent behavior.
if (!(Utf8Parser.TryParse(span, out value, out int bytesConsumed)
&& span.Length == bytesConsumed
- && JsonHelpers.IsFinite(value)))
+ && float.IsFinite(value)))
{
ThrowHelper.ThrowFormatException(NumericType.Single);
}
@@ -662,7 +662,7 @@ internal double GetDoubleWithQuotes()
// The following logic reconciles the two implementations to enforce consistent behavior.
if (!(Utf8Parser.TryParse(span, out value, out int bytesConsumed)
&& span.Length == bytesConsumed
- && JsonHelpers.IsFinite(value)))
+ && double.IsFinite(value)))
{
ThrowHelper.ThrowFormatException(NumericType.Double);
}
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/FSharp/FSharpUnionConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/FSharp/FSharpUnionConverter.cs
index f4818ccb690f1c..8525196eb7ceda 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/FSharp/FSharpUnionConverter.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/FSharp/FSharpUnionConverter.cs
@@ -7,9 +7,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
-#if !NET
-using System.Runtime.Serialization;
-#endif
using System.Text.Json.Reflection;
using System.Text.Json.Serialization.Metadata;
@@ -104,11 +101,7 @@ public FSharpUnionConverter(
{
Type fieldType = fields[i].FieldType;
defaultFieldValues[i] = fieldType.IsValueType ?
-#if NET
RuntimeHelpers.GetUninitializedObject(fieldType) :
-#else
- FormatterServices.GetUninitializedObject(fieldType) :
-#endif
null!;
}
}
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/StackHelper.cs b/src/libraries/System.Text.Json/src/System/Text/Json/StackHelper.cs
deleted file mode 100644
index b3c6530dec0700..00000000000000
--- a/src/libraries/System.Text.Json/src/System/Text/Json/StackHelper.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Runtime.CompilerServices;
-
-namespace System.Text.Json
-{
- /// Provides tools for avoiding stack overflows.
- internal static class StackHelper
- {
- /// Tries to ensure there is sufficient stack to execute the average .NET function.
- public static bool TryEnsureSufficientExecutionStack()
- {
-#if NET
- return RuntimeHelpers.TryEnsureSufficientExecutionStack();
-#else
- try
- {
- RuntimeHelpers.EnsureSufficientExecutionStack();
- return true;
- }
- catch
- {
- return false;
- }
-#endif
- }
- }
-}
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs
index 38ff45cde115ff..c69d78ed5c6fbb 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs
@@ -78,7 +78,7 @@ public static void ValidateValue(ReadOnlySpan value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ValidateDouble(double value)
{
- if (!JsonHelpers.IsFinite(value))
+ if (!double.IsFinite(value))
{
ThrowHelper.ThrowArgumentException_ValueNotSupported();
}
@@ -87,7 +87,7 @@ public static void ValidateDouble(double value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ValidateSingle(float value)
{
- if (!JsonHelpers.IsFinite(value))
+ if (!float.IsFinite(value))
{
ThrowHelper.ThrowArgumentException_ValueNotSupported();
}
diff --git a/src/libraries/System.Threading.RateLimiting/src/System.Threading.RateLimiting.csproj b/src/libraries/System.Threading.RateLimiting/src/System.Threading.RateLimiting.csproj
index 8a42115792903d..f20f8228960737 100644
--- a/src/libraries/System.Threading.RateLimiting/src/System.Threading.RateLimiting.csproj
+++ b/src/libraries/System.Threading.RateLimiting/src/System.Threading.RateLimiting.csproj
@@ -47,6 +47,7 @@ System.Threading.RateLimiting.RateLimitLease
+
diff --git a/src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/RateLimiterHelper.cs b/src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/RateLimiterHelper.cs
index 4fae65d1245a9a..e538fc720072dd 100644
--- a/src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/RateLimiterHelper.cs
+++ b/src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/RateLimiterHelper.cs
@@ -7,9 +7,6 @@ namespace System.Threading.RateLimiting
{
internal static class RateLimiterHelper
{
-#if !NET
- private static readonly double TickFrequency = (double)TimeSpan.TicksPerSecond / Stopwatch.Frequency;
-#endif
public static TimeSpan? GetElapsedTime(long? startTimestamp)
{
if (startTimestamp is null)
@@ -17,20 +14,12 @@ internal static class RateLimiterHelper
return null;
}
-#if NET
return Stopwatch.GetElapsedTime(startTimestamp.Value);
-#else
- return new((long)((Stopwatch.GetTimestamp() - startTimestamp.Value) * TickFrequency));
-#endif
}
public static TimeSpan GetElapsedTime(long startTimestamp, long endTimestamp)
{
-#if NET
return Stopwatch.GetElapsedTime(startTimestamp, endTimestamp);
-#else
- return new((long)((endTimestamp - startTimestamp) * TickFrequency));
-#endif
}
}
}
diff --git a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs
index cf0189a9b47c30..989744c3269d2f 100644
--- a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs
+++ b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs
@@ -314,20 +314,7 @@ private void LoadStream(bool loadSync)
int streamLen = (int)_stream.Length;
_currentPos = 0;
_streamData = new byte[streamLen];
-#if NET
_stream.ReadExactly(_streamData);
-#else
- int totalRead = 0;
- while (totalRead < streamLen)
- {
- int bytesRead = _stream.Read(_streamData, totalRead, streamLen - totalRead);
- if (bytesRead <= 0)
- {
- throw new EndOfStreamException();
- }
- totalRead += bytesRead;
- }
-#endif
IsLoadCompleted = true;
OnLoadCompleted(new AsyncCompletedEventArgs(null, false, null));
}