File tree 7 files changed +17
-5
lines changed
System.Private.CoreLib/src
System.Runtime/tests/System.IO.Tests
7 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,9 @@ public static async Task OutWriteAndWriteLineOverloads()
158
158
Console . SetOut ( sw ) ;
159
159
TextWriter writer = Console . Out ;
160
160
Assert . NotNull ( writer ) ;
161
- Assert . NotEqual ( writer , sw ) ; // the writer we provide gets wrapped
161
+ // Browser bypasses SyncTextWriter for faster startup
162
+ if ( ! OperatingSystem . IsBrowser ( ) )
163
+ Assert . NotEqual ( writer , sw ) ; // the writer we provide gets wrapped
162
164
163
165
// We just want to ensure none of these throw exceptions, we don't actually validate
164
166
// what was written.
Original file line number Diff line number Diff line change 12
12
13
13
public class SyncTextWriter
14
14
{
15
- [ Fact ]
15
+ // Browser bypasses SyncTextWriter for faster startup
16
+ [ ConditionalFact ( typeof ( PlatformDetection ) , nameof ( PlatformDetection . IsThreadingSupported ) ) ]
16
17
public void SyncTextWriterLockedOnThis ( )
17
18
{
18
19
TextWriter oldWriter = Console . Out ;
Original file line number Diff line number Diff line change 22
22
<IsBigEndian Condition="'$(Platform)' == 's390x'">true</IsBigEndian>
23
23
<Is64Bit Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64' or '$(Platform)' == 's390x' or '$(Platform)' == 'loongarch64' or '$(Platform)' == 'ppc64le' or '$(Platform)' == 'riscv64'">true</Is64Bit>
24
24
<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>
25
27
</PropertyGroup>
26
28
<PropertyGroup>
27
29
<DefineConstants Condition="'$(IsBigEndian)' == 'true'">$(DefineConstants);BIGENDIAN</DefineConstants>
Original file line number Diff line number Diff line change @@ -759,7 +759,11 @@ public static TextWriter Synchronized(TextWriter writer)
759
759
{
760
760
ArgumentNullException . ThrowIfNull ( writer ) ;
761
761
762
+ #if ! TARGET_BROWSER || FEATURE_WASM_MANAGED_THREADS
762
763
return writer is SyncTextWriter ? writer : new SyncTextWriter ( writer ) ;
764
+ #else
765
+ return writer ;
766
+ #endif
763
767
}
764
768
765
769
internal sealed class SyncTextWriter : TextWriter , IDisposable
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ public void ObjectClosedReadLineBaseStream()
29
29
Assert . Throws < ObjectDisposedException > ( ( ) => sr . ReadLine ( ) ) ;
30
30
}
31
31
32
- [ Fact ]
32
+ // Browser bypasses SyncTextWriter for faster startup
33
+ [ ConditionalFact ( typeof ( PlatformDetection ) , nameof ( PlatformDetection . IsThreadingSupported ) ) ]
33
34
public void Synchronized_NewObject ( )
34
35
{
35
36
using ( Stream str = GetLargeStream ( ) )
Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ namespace System.IO.Tests
7
7
{
8
8
public partial class WriteTests
9
9
{
10
- [ Fact ]
10
+ // Browser bypasses SyncTextWriter for faster startup
11
+ [ ConditionalFact ( typeof ( PlatformDetection ) , nameof ( PlatformDetection . IsThreadingSupported ) ) ]
11
12
public void Synchronized_NewObject ( )
12
13
{
13
14
using ( Stream str = CreateStream ( ) )
Original file line number Diff line number Diff line change @@ -690,7 +690,8 @@ public void DisposeAsync_ExceptionReturnedInTask()
690
690
Assert . Same ( e , vt . AsTask ( ) . Exception . InnerException ) ;
691
691
}
692
692
693
- [ Fact ]
693
+ // Browser bypasses SyncTextWriter for faster startup
694
+ [ ConditionalFact ( typeof ( PlatformDetection ) , nameof ( PlatformDetection . IsThreadingSupported ) ) ]
694
695
public async Task FlushAsync_Precanceled ( )
695
696
{
696
697
Assert . Equal ( TaskStatus . RanToCompletion , TextWriter . Null . FlushAsync ( new CancellationToken ( true ) ) . Status ) ;
You can’t perform that action at this time.
0 commit comments