Skip to content

Commit

Permalink
Don't use SyncTextWriter on WASI either
Browse files Browse the repository at this point in the history
Follow-up to dotnet#101221 so we match behavior between single-threaded Browser and WASI.
  • Loading branch information
akoeplinger committed Jul 12, 2024
1 parent 42b2b19 commit 9d52b1c
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/libraries/System.Console/tests/ReadAndWrite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ public static async Task OutWriteAndWriteLineOverloads()
Console.SetOut(sw);
TextWriter writer = Console.Out;
Assert.NotNull(writer);
// Browser bypasses SyncTextWriter for faster startup
if (!OperatingSystem.IsBrowser())
// single-threaded WASM bypasses SyncTextWriter for faster startup
if (!PlatformDetection.IsThreadingSupported)
Assert.NotEqual(writer, sw); // the writer we provide gets wrapped

// We just want to ensure none of these throw exceptions, we don't actually validate
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Console/tests/SyncTextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class SyncTextWriter
{
// Browser bypasses SyncTextWriter for faster startup
// single-threaded WASM bypasses SyncTextWriter for faster startup
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
public void SyncTextWriterLockedOnThis()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
<IsBigEndian Condition="'$(Platform)' == 's390x'">true</IsBigEndian>
<Is64Bit Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64' or '$(Platform)' == 's390x' or '$(Platform)' == 'loongarch64' or '$(Platform)' == 'ppc64le' or '$(Platform)' == 'riscv64'">true</Is64Bit>
<UseMinimalGlobalizationData Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true</UseMinimalGlobalizationData>
<FeatureWasmManagedThreads Condition="'$(WasmEnableThreads)' == 'true'">true</FeatureWasmManagedThreads>
<DefineConstants Condition="'$(FeatureWasmManagedThreads)' == 'true'">$(DefineConstants);FEATURE_WASM_MANAGED_THREADS</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition="'$(IsBigEndian)' == 'true'">$(DefineConstants);BIGENDIAN</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ public static TextWriter Synchronized(TextWriter writer)
{
ArgumentNullException.ThrowIfNull(writer);

#if !TARGET_BROWSER || FEATURE_WASM_MANAGED_THREADS
#if (!TARGET_BROWSER && !TARGET_WASI) || FEATURE_WASM_MANAGED_THREADS
return writer is SyncTextWriter ? writer : new SyncTextWriter(writer);
#else
return writer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void ObjectClosedReadLineBaseStream()
Assert.Throws<ObjectDisposedException>(() => sr.ReadLine());
}

// Browser bypasses SyncTextWriter for faster startup
// single-threaded WASM bypasses SyncTextWriter for faster startup
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
public void Synchronized_NewObject()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace System.IO.Tests
{
public partial class WriteTests
{
// Browser bypasses SyncTextWriter for faster startup
// single-threaded WASM bypasses SyncTextWriter for faster startup
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
public void Synchronized_NewObject()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ public void DisposeAsync_ExceptionReturnedInTask()
Assert.Same(e, vt.AsTask().Exception.InnerException);
}

// Browser bypasses SyncTextWriter for faster startup
// single-threaded WASM bypasses SyncTextWriter for faster startup
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
public async Task FlushAsync_Precanceled()
{
Expand Down
2 changes: 0 additions & 2 deletions src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
<Platforms>x64;x86;arm;armv6;arm64;riscv64;s390x;wasm;ppc64le</Platforms>

<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<FeatureWasmManagedThreads Condition="'$(WasmEnableThreads)' == 'true'">true</FeatureWasmManagedThreads>
<DefineConstants Condition="'$(FeatureWasmManagedThreads)' == 'true'">$(DefineConstants);FEATURE_WASM_MANAGED_THREADS</DefineConstants>
</PropertyGroup>

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

0 comments on commit 9d52b1c

Please sign in to comment.