From e4919edb78070624f318dd84d9880a21ee8109b4 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 19 Jan 2026 20:18:59 +0100 Subject: [PATCH 1/6] rebase --- .../ILLink.Descriptors.LibraryBuild.xml | 3 + .../src/System/Text/EncodingTable.cs | 17 ++++- .../src/System/TimeZoneInfo.Cache.cs | 7 +- .../DoesntIncludeConcurentTypes.cs | 71 +++++++++++++++++++ .../System.Runtime.TrimmingTests.proj | 3 + 5 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/DoesntIncludeConcurentTypes.cs diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Descriptors.LibraryBuild.xml b/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Descriptors.LibraryBuild.xml index becbb43a7ed1bb..49ff513f8e65b4 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Descriptors.LibraryBuild.xml +++ b/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Descriptors.LibraryBuild.xml @@ -11,4 +11,7 @@ + + + diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/EncodingTable.cs b/src/libraries/System.Private.CoreLib/src/System/Text/EncodingTable.cs index 77952ee9c1d96d..eae110b80393ba 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/EncodingTable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/EncodingTable.cs @@ -5,6 +5,11 @@ using System.Collections.Generic; using System.Diagnostics; using System.Threading; +#if FEATURE_SINGLE_THREADED +using CodePageDictionary = System.Collections.Generic.Dictionary; +#else +using CodePageDictionary = System.Collections.Concurrent.ConcurrentDictionary; +#endif namespace System.Text { @@ -15,7 +20,7 @@ namespace System.Text // internal static partial class EncodingTable { - private static readonly ConcurrentDictionary s_nameToCodePage = new(StringComparer.OrdinalIgnoreCase); + private static readonly CodePageDictionary s_nameToCodePage = new(StringComparer.OrdinalIgnoreCase); private static CodePageDataItem?[]? s_codePageToCodePageData; /*=================================GetCodePageFromName========================== @@ -32,7 +37,17 @@ internal static int GetCodePageFromName(string name) { ArgumentNullException.ThrowIfNull(name); +#if FEATURE_SINGLE_THREADED + if (s_nameToCodePage.TryGetValue(name, out int codePage)) + { + return codePage; + } + codePage = InternalGetCodePageFromName(name); + s_nameToCodePage[name] = codePage; + return codePage; +#else return s_nameToCodePage.GetOrAdd(name, InternalGetCodePageFromName); +#endif } // Find the data item by binary searching the table. diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Cache.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Cache.cs index e45a90401f4cf3..20d74b3d21229b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Cache.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Cache.cs @@ -64,6 +64,11 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; +#if FEATURE_SINGLE_THREADED +using TransitionCacheDictionary = System.Collections.Generic.Dictionary; +#else +using TransitionCacheDictionary = System.Collections.Concurrent.ConcurrentDictionary; +#endif namespace System { @@ -1394,7 +1399,7 @@ private static TimeSpan GetRuleFullUtcOffset(AdjustmentRule rule) => // _transitionCache maps a year to int value. the low 16 bits store the index of the first transition for that year in _yearsTransitions. // the high 16 bits store the number of transitions for that year. We use concurrent dictionary for thread-safe access. - private readonly ConcurrentDictionary _transitionCache = new ConcurrentDictionary(); + private readonly TransitionCacheDictionary _transitionCache = new TransitionCacheDictionary(); // _yearsTransitions stores all transitions for all cached years. // When accessing _yearsTransitions, store it in a local variable as it may be replaced by another thread. diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/DoesntIncludeConcurentTypes.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/DoesntIncludeConcurentTypes.cs new file mode 100644 index 00000000000000..d6b08d58f0740b --- /dev/null +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/DoesntIncludeConcurentTypes.cs @@ -0,0 +1,71 @@ +// 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.Linq; +using System.Reflection; +using System.Threading.Tasks; + + +/// +/// Tests that concurrent collections are not included in a trimmed app targeting browser. +/// The idea is that the runtime should not depend on these types when running in a browser. +/// Motivation: application size and wasted CPU cycles these types would use to stay thread safe. +/// +class Program +{ + static async Task Main(string[] args) + { + var dictType = GetTypeByName("ConcurrentDictionary`2"); + if (dictType != null) + { + Console.WriteLine("Failed ConcurrentDictionary"); + return -1; + } + var bagType = GetTypeByName("ConcurrentBag`1"); + if (bagType != null) + { + Console.WriteLine("Failed ConcurrentBag"); + return -2; + } + var stackType = GetTypeByName("ConcurrentStack`1"); + if (stackType != null) + { + Console.WriteLine("Failed ConcurrentStack"); + return -3; + } + var collectionType = GetTypeByName("BlockingCollection`1"); + if (collectionType != null) + { + Console.WriteLine("Failed BlockingCollection"); + return -4; + } + var queueType = GetTypeByName("ConcurrentQueue`1"); + if (queueType != null) + { + Console.WriteLine("Failed ConcurrentQueue"); + return -5; + } + if (AppDomain.CurrentDomain.GetAssemblies().Any(a => a.GetName().Name == "System.Collections.Concurrent")) + { + Console.WriteLine("Failed: System.Collections.Concurrent assembly is present"); + return -6; + } + + return 100; + } + + // make reflection trimmer incompatible + static Type GetTypeByName(string typeName) + { + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + var type = assembly.GetType("System.Collections.Concurrent." + typeName); + if (type != null) + { + return type; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj index 73b334d839ecf3..5e0ff9c9c83869 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj @@ -79,6 +79,9 @@ UseWindowsThreadPool + + + From 24a61aa0ba858f209f42fd83fc948579a2d50cb3 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 20 Jan 2026 13:41:55 +0100 Subject: [PATCH 2/6] wip --- .../ILLink.Descriptors.LibraryBuild.xml | 3 - .../src/System/Numerics/BFloat16.cs | 16 +++-- .../src/System/Text/EncodingTable.cs | 17 +----- .../src/System/TimeZoneInfo.Cache.cs | 7 +-- .../System/Numerics/BFloat16Tests.cs | 60 ------------------- ...> BrowserDoesNotIncludeConcurrentTypes.cs} | 8 +-- .../System.Runtime.TrimmingTests.proj | 2 +- 7 files changed, 11 insertions(+), 102 deletions(-) rename src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/{DoesntIncludeConcurentTypes.cs => BrowserDoesNotIncludeConcurrentTypes.cs} (86%) diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Descriptors.LibraryBuild.xml b/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Descriptors.LibraryBuild.xml index 49ff513f8e65b4..becbb43a7ed1bb 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Descriptors.LibraryBuild.xml +++ b/src/libraries/System.ComponentModel.TypeConverter/src/ILLink/ILLink.Descriptors.LibraryBuild.xml @@ -11,7 +11,4 @@ - - - diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs index 9cb4fb9e09da08..7095ca0a3f10d8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs @@ -116,11 +116,11 @@ internal sbyte Exponent } } - internal byte Significand + internal ushort Significand { get { - return (byte)(TrailingSignificand | ((BiasedExponent != 0) ? (1U << BiasedExponentShift) : 0U)); + return (ushort)(TrailingSignificand | ((BiasedExponent != 0) ? (1U << BiasedExponentShift) : 0U)); } } @@ -1010,7 +1010,7 @@ int IFloatingPoint.GetExponentShortestBitLength() } /// - int IFloatingPoint.GetSignificandByteCount() => sizeof(byte); + int IFloatingPoint.GetSignificandByteCount() => sizeof(ushort); /// int IFloatingPoint.GetSignificandBitLength() => SignificandLength; @@ -1046,10 +1046,9 @@ bool IFloatingPoint.TryWriteExponentLittleEndian(Span destinatio /// bool IFloatingPoint.TryWriteSignificandBigEndian(Span destination, out int bytesWritten) { - if (destination.Length >= sizeof(byte)) + if (BinaryPrimitives.TryWriteUInt16BigEndian(destination, Significand)) { - destination[0] = Significand; - bytesWritten = sizeof(byte); + bytesWritten = sizeof(uint); return true; } @@ -1060,10 +1059,9 @@ bool IFloatingPoint.TryWriteSignificandBigEndian(Span destinatio /// bool IFloatingPoint.TryWriteSignificandLittleEndian(Span destination, out int bytesWritten) { - if (destination.Length >= sizeof(byte)) + if (BinaryPrimitives.TryWriteUInt16LittleEndian(destination, Significand)) { - destination[0] = Significand; - bytesWritten = sizeof(byte); + bytesWritten = sizeof(uint); return true; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/EncodingTable.cs b/src/libraries/System.Private.CoreLib/src/System/Text/EncodingTable.cs index eae110b80393ba..77952ee9c1d96d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/EncodingTable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/EncodingTable.cs @@ -5,11 +5,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Threading; -#if FEATURE_SINGLE_THREADED -using CodePageDictionary = System.Collections.Generic.Dictionary; -#else -using CodePageDictionary = System.Collections.Concurrent.ConcurrentDictionary; -#endif namespace System.Text { @@ -20,7 +15,7 @@ namespace System.Text // internal static partial class EncodingTable { - private static readonly CodePageDictionary s_nameToCodePage = new(StringComparer.OrdinalIgnoreCase); + private static readonly ConcurrentDictionary s_nameToCodePage = new(StringComparer.OrdinalIgnoreCase); private static CodePageDataItem?[]? s_codePageToCodePageData; /*=================================GetCodePageFromName========================== @@ -37,17 +32,7 @@ internal static int GetCodePageFromName(string name) { ArgumentNullException.ThrowIfNull(name); -#if FEATURE_SINGLE_THREADED - if (s_nameToCodePage.TryGetValue(name, out int codePage)) - { - return codePage; - } - codePage = InternalGetCodePageFromName(name); - s_nameToCodePage[name] = codePage; - return codePage; -#else return s_nameToCodePage.GetOrAdd(name, InternalGetCodePageFromName); -#endif } // Find the data item by binary searching the table. diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Cache.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Cache.cs index 20d74b3d21229b..e45a90401f4cf3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Cache.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Cache.cs @@ -64,11 +64,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; -#if FEATURE_SINGLE_THREADED -using TransitionCacheDictionary = System.Collections.Generic.Dictionary; -#else -using TransitionCacheDictionary = System.Collections.Concurrent.ConcurrentDictionary; -#endif namespace System { @@ -1399,7 +1394,7 @@ private static TimeSpan GetRuleFullUtcOffset(AdjustmentRule rule) => // _transitionCache maps a year to int value. the low 16 bits store the index of the first transition for that year in _yearsTransitions. // the high 16 bits store the number of transitions for that year. We use concurrent dictionary for thread-safe access. - private readonly TransitionCacheDictionary _transitionCache = new TransitionCacheDictionary(); + private readonly ConcurrentDictionary _transitionCache = new ConcurrentDictionary(); // _yearsTransitions stores all transitions for all cached years. // When accessing _yearsTransitions, store it in a local variable as it may be replaced by another thread. diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Numerics/BFloat16Tests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Numerics/BFloat16Tests.cs index c4e3e40c3adce7..041dccf8528618 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Numerics/BFloat16Tests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Numerics/BFloat16Tests.cs @@ -2271,66 +2271,6 @@ public static void RadiansToDegreesTest(BFloat16 value, BFloat16 expectedResult, AssertEqual(+expectedResult, BFloat16.RadiansToDegrees(+value), allowedVariance); } - public static IEnumerable TryWriteSignificandBigEndianTest_TestData() => - [ - [BFloat16.NegativeInfinity, 1, new byte[] { 0x80 }], - [BFloat16.MinValue, 1, new byte[] { 0xFF }], - [(BFloat16)(-1.0f), 1, new byte[] { 0x80 }], - [-BFloat16.Epsilon, 1, new byte[] { 0x01 }], - [BFloat16.NaN, 1, new byte[] { 0xC0 }], - [(BFloat16)0.0f, 1, new byte[] { 0x00 }], - [(BFloat16)1.0f, 1, new byte[] { 0x80 }], - [BFloat16.MaxValue, 1, new byte[] { 0xFF }], - [BFloat16.PositiveInfinity, 1, new byte[] { 0x80 }], - ]; - - [Theory] - [MemberData(nameof(TryWriteSignificandBigEndianTest_TestData))] - public static void TryWriteSignificandBigEndianTest(BFloat16 value, int expectedBytesWritten, byte[] expectedBytes) - { - Span destination = [0]; - Assert.True(FloatingPointHelper.TryWriteSignificandBigEndian(value, destination, out int bytesWritten)); - Assert.Equal(expectedBytesWritten, bytesWritten); - Assert.Equal(expectedBytes, destination.ToArray()); - } - - [Fact] - public static void TryWriteSignificandBigEndianTest_EmptyDestination() - { - Assert.False(FloatingPointHelper.TryWriteSignificandBigEndian(default, Span.Empty, out int bytesWritten)); - Assert.Equal(0, bytesWritten); - } - - public static IEnumerable TryWriteSignificandLittleEndianTest_TestData() => - [ - [BFloat16.NegativeInfinity, 1, new byte[] { 0x80 }], - [BFloat16.MinValue, 1, new byte[] { 0xFF }], - [(BFloat16)(-1.0f), 1, new byte[] { 0x80 }], - [-BFloat16.Epsilon, 1, new byte[] { 0x01 }], - [BFloat16.NaN, 1, new byte[] { 0xC0 }], - [(BFloat16)0.0f, 1, new byte[] { 0x00 }], - [(BFloat16)1.0f, 1, new byte[] { 0x80 }], - [BFloat16.MaxValue, 1, new byte[] { 0xFF }], - [BFloat16.PositiveInfinity, 1, new byte[] { 0x80 }], - ]; - - [Theory] - [MemberData(nameof(TryWriteSignificandLittleEndianTest_TestData))] - public static void TryWriteSignificandLittleEndianTest(BFloat16 value, int expectedBytesWritten, byte[] expectedBytes) - { - Span destination = [0]; - Assert.True(FloatingPointHelper.TryWriteSignificandLittleEndian(value, destination, out int bytesWritten)); - Assert.Equal(expectedBytesWritten, bytesWritten); - Assert.Equal(expectedBytes, destination.ToArray()); - } - - [Fact] - public static void TryWriteSignificandLittleEndianTest_EmptyDestination() - { - Assert.False(FloatingPointHelper.TryWriteSignificandLittleEndian(default, Span.Empty, out int bytesWritten)); - Assert.Equal(0, bytesWritten); - } - #region AssertExtentions static bool IsNegativeZero(BFloat16 value) { diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/DoesntIncludeConcurentTypes.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs similarity index 86% rename from src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/DoesntIncludeConcurentTypes.cs rename to src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs index d6b08d58f0740b..29e59ae2b7f8fd 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/DoesntIncludeConcurentTypes.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs @@ -10,18 +10,12 @@ /// /// Tests that concurrent collections are not included in a trimmed app targeting browser. /// The idea is that the runtime should not depend on these types when running in a browser. -/// Motivation: application size and wasted CPU cycles these types would use to stay thread safe. +/// Motivation: application size. /// class Program { static async Task Main(string[] args) { - var dictType = GetTypeByName("ConcurrentDictionary`2"); - if (dictType != null) - { - Console.WriteLine("Failed ConcurrentDictionary"); - return -1; - } var bagType = GetTypeByName("ConcurrentBag`1"); if (bagType != null) { diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj index 5e0ff9c9c83869..4e654c7e5cc1d6 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj @@ -80,7 +80,7 @@ - + From 697c91afa81d5ac7f3e2e2164f0907dec09d8512 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 20 Jan 2026 13:44:17 +0100 Subject: [PATCH 3/6] fix merge --- .../src/System/Numerics/BFloat16.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs index d6100c8d3a6263..545b9a62091637 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs @@ -116,11 +116,11 @@ internal sbyte Exponent } } - internal ushort Significand + internal byte Significand { get { - return (ushort)(TrailingSignificand | ((BiasedExponent != 0) ? (1U << BiasedExponentShift) : 0U)); + return (byte)(TrailingSignificand | ((BiasedExponent != 0) ? (1U << BiasedExponentShift) : 0U)); } } @@ -1010,7 +1010,7 @@ int IFloatingPoint.GetExponentShortestBitLength() } /// - int IFloatingPoint.GetSignificandByteCount() => sizeof(ushort); + int IFloatingPoint.GetSignificandByteCount() => sizeof(byte); /// int IFloatingPoint.GetSignificandBitLength() => SignificandLength; @@ -1046,9 +1046,10 @@ bool IFloatingPoint.TryWriteExponentLittleEndian(Span destinatio /// bool IFloatingPoint.TryWriteSignificandBigEndian(Span destination, out int bytesWritten) { - if (BinaryPrimitives.TryWriteUInt16BigEndian(destination, Significand)) + if (destination.Length >= sizeof(byte)) { - bytesWritten = sizeof(uint); + destination[0] = Significand; + bytesWritten = sizeof(byte); return true; } @@ -1059,9 +1060,10 @@ bool IFloatingPoint.TryWriteSignificandBigEndian(Span destinatio /// bool IFloatingPoint.TryWriteSignificandLittleEndian(Span destination, out int bytesWritten) { - if (BinaryPrimitives.TryWriteUInt16LittleEndian(destination, Significand)) + if (destination.Length >= sizeof(byte)) { - bytesWritten = sizeof(uint); + destination[0] = Significand; + bytesWritten = sizeof(byte); return true; } From 36a1a42ca2a96afcacb49d0cf4d05744418872e6 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 20 Jan 2026 21:00:59 +0100 Subject: [PATCH 4/6] Update src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs index 29e59ae2b7f8fd..47b4b283c14b91 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs @@ -4,17 +4,17 @@ using System; using System.Linq; using System.Reflection; -using System.Threading.Tasks; /// /// Tests that concurrent collections are not included in a trimmed app targeting browser. +/// Tests that concurrent collections are not included in a trimmed app targeting browser. /// The idea is that the runtime should not depend on these types when running in a browser. /// Motivation: application size. /// class Program { - static async Task Main(string[] args) + static int Main(string[] args) { var bagType = GetTypeByName("ConcurrentBag`1"); if (bagType != null) From f88faa043f2154a6fee850d68b2ae54e602d54a3 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Tue, 20 Jan 2026 21:01:18 +0100 Subject: [PATCH 5/6] Update src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs index 47b4b283c14b91..109747cd947c02 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs @@ -45,7 +45,6 @@ static int Main(string[] args) Console.WriteLine("Failed: System.Collections.Concurrent assembly is present"); return -6; } - return 100; } From 255b5590322f9bb69a911ec37ae6adfdaf38d382 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 20 Jan 2026 21:03:59 +0100 Subject: [PATCH 6/6] feedback --- .../TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs index 109747cd947c02..cfca913b9664e2 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs @@ -8,9 +8,9 @@ /// /// Tests that concurrent collections are not included in a trimmed app targeting browser. -/// Tests that concurrent collections are not included in a trimmed app targeting browser. /// The idea is that the runtime should not depend on these types when running in a browser. /// Motivation: application size. +/// Except ConcurrentDictionary which is used by other parts of the runtime and many apps. /// class Program {