Skip to content

Commit 9d52b1c

Browse files
committed
Don't use SyncTextWriter on WASI either
Follow-up to dotnet#101221 so we match behavior between single-threaded Browser and WASI.
1 parent 42b2b19 commit 9d52b1c

File tree

8 files changed

+7
-11
lines changed

8 files changed

+7
-11
lines changed

src/libraries/System.Console/tests/ReadAndWrite.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ public static async Task OutWriteAndWriteLineOverloads()
158158
Console.SetOut(sw);
159159
TextWriter writer = Console.Out;
160160
Assert.NotNull(writer);
161-
// Browser bypasses SyncTextWriter for faster startup
162-
if (!OperatingSystem.IsBrowser())
161+
// single-threaded WASM bypasses SyncTextWriter for faster startup
162+
if (!PlatformDetection.IsThreadingSupported)
163163
Assert.NotEqual(writer, sw); // the writer we provide gets wrapped
164164

165165
// We just want to ensure none of these throw exceptions, we don't actually validate

src/libraries/System.Console/tests/SyncTextWriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class SyncTextWriter
1414
{
15-
// Browser bypasses SyncTextWriter for faster startup
15+
// single-threaded WASM bypasses SyncTextWriter for faster startup
1616
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
1717
public void SyncTextWriterLockedOnThis()
1818
{

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
<IsBigEndian Condition="'$(Platform)' == 's390x'">true</IsBigEndian>
2323
<Is64Bit Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64' or '$(Platform)' == 's390x' or '$(Platform)' == 'loongarch64' or '$(Platform)' == 'ppc64le' or '$(Platform)' == 'riscv64'">true</Is64Bit>
2424
<UseMinimalGlobalizationData Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true</UseMinimalGlobalizationData>
25-
<FeatureWasmManagedThreads Condition="'$(WasmEnableThreads)' == 'true'">true</FeatureWasmManagedThreads>
26-
<DefineConstants Condition="'$(FeatureWasmManagedThreads)' == 'true'">$(DefineConstants);FEATURE_WASM_MANAGED_THREADS</DefineConstants>
2725
</PropertyGroup>
2826
<PropertyGroup>
2927
<DefineConstants Condition="'$(IsBigEndian)' == 'true'">$(DefineConstants);BIGENDIAN</DefineConstants>

src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ public static TextWriter Synchronized(TextWriter writer)
759759
{
760760
ArgumentNullException.ThrowIfNull(writer);
761761

762-
#if !TARGET_BROWSER || FEATURE_WASM_MANAGED_THREADS
762+
#if (!TARGET_BROWSER && !TARGET_WASI) || FEATURE_WASM_MANAGED_THREADS
763763
return writer is SyncTextWriter ? writer : new SyncTextWriter(writer);
764764
#else
765765
return writer;

src/libraries/System.Runtime/tests/System.IO.Tests/StreamReader/StreamReader.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void ObjectClosedReadLineBaseStream()
2929
Assert.Throws<ObjectDisposedException>(() => sr.ReadLine());
3030
}
3131

32-
// Browser bypasses SyncTextWriter for faster startup
32+
// single-threaded WASM bypasses SyncTextWriter for faster startup
3333
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
3434
public void Synchronized_NewObject()
3535
{

src/libraries/System.Runtime/tests/System.IO.Tests/StreamWriter/StreamWriter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace System.IO.Tests
77
{
88
public partial class WriteTests
99
{
10-
// Browser bypasses SyncTextWriter for faster startup
10+
// single-threaded WASM bypasses SyncTextWriter for faster startup
1111
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
1212
public void Synchronized_NewObject()
1313
{

src/libraries/System.Runtime/tests/System.IO.Tests/TextWriter/TextWriterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ public void DisposeAsync_ExceptionReturnedInTask()
690690
Assert.Same(e, vt.AsTask().Exception.InnerException);
691691
}
692692

693-
// Browser bypasses SyncTextWriter for faster startup
693+
// single-threaded WASM bypasses SyncTextWriter for faster startup
694694
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
695695
public async Task FlushAsync_Precanceled()
696696
{

src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
<Platforms>x64;x86;arm;armv6;arm64;riscv64;s390x;wasm;ppc64le</Platforms>
1414

1515
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
16-
<FeatureWasmManagedThreads Condition="'$(WasmEnableThreads)' == 'true'">true</FeatureWasmManagedThreads>
17-
<DefineConstants Condition="'$(FeatureWasmManagedThreads)' == 'true'">$(DefineConstants);FEATURE_WASM_MANAGED_THREADS</DefineConstants>
1816
</PropertyGroup>
1917

2018
<!-- Note that various places in SPCL depend on this resource name i.e. TplEventSource -->

0 commit comments

Comments
 (0)