-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* introduce WindowsFileStreamStrategy * introduce SyncWindowsFileStreamStrategy * introduce AsyncWindowsFileStreamStrategy * only DerivedFileStreamStrategy needs to have a reference to FileStream remove finalizer from FileStream, keep it only in DerivedFileStreamStrategy and LegacyFileStreamStrategy * use the new strategies when buffering is not enabled * introduce BufferedFileStreamStrategy * use the Legacy strategy by default for now, add tests for the other implementation * Apply suggestions from code review Co-authored-by: David Cantú <[email protected]> Co-authored-by: Stephen Toub <[email protected]>
- Loading branch information
1 parent
1292216
commit 6ef4b2e
Showing
43 changed files
with
3,086 additions
and
844 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/libraries/System.IO.FileSystem/tests/LegacyTests/LegacySwitchTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.Reflection; | ||
using Xunit; | ||
|
||
namespace System.IO.Tests | ||
{ | ||
public class LegacySwitchTests | ||
{ | ||
[Fact] | ||
public static void LegacySwitchIsHonored() | ||
{ | ||
string filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); | ||
|
||
using (FileStream fileStream = File.Create(filePath)) | ||
{ | ||
object strategy = fileStream | ||
.GetType() | ||
.GetField("_strategy", BindingFlags.NonPublic | BindingFlags.Instance) | ||
.GetValue(fileStream); | ||
|
||
Assert.DoesNotContain(strategy.GetType().FullName, "Legacy"); | ||
} | ||
|
||
File.Delete(filePath); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...libraries/System.IO.FileSystem/tests/LegacyTests/System.IO.FileSystem.Legacy.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<IncludeRemoteExecutor>true</IncludeRemoteExecutor> | ||
<!-- currently we have non Legacy strategy only for Windows, so we run the tests only on Windows --> | ||
<TargetFrameworks>$(NetCoreAppCurrent)-windows</TargetFrameworks> | ||
|
||
<RunTestsJSArguments>--working-dir=/test-dir</RunTestsJSArguments> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="..\**\*.cs" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetsUnix)' == 'true'"> | ||
<Compile Remove="..\**\*.Windows.cs" /> | ||
<Compile Remove="..\**\*.Browser.cs" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetsWindows)' == 'true'"> | ||
<Compile Remove="..\**\*.Unix.cs" /> | ||
<Compile Remove="..\**\*.Browser.cs" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(TargetsBrowser)' == 'true'"> | ||
<Compile Remove="..\**\*.Unix.cs" /> | ||
<Compile Remove="..\**\*.Windows.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<!-- Helpers --> | ||
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GenericOperations.cs" Link="Interop\Windows\Interop.GenericOperations.cs" /> | ||
<Compile Include="$(CommonTestPath)System\Buffers\NativeMemoryManager.cs" Link="Common\System\Buffers\NativeMemoryManager.cs" /> | ||
<Compile Include="$(CommonTestPath)System\IO\TempFile.cs" Link="Common\System\IO\TempFile.cs" /> | ||
<Compile Include="$(CommonTestPath)System\IO\PathFeatures.cs" Link="Common\System\IO\PathFeatures.cs" /> | ||
<Content Include="..\DirectoryInfo\test-dir\dummy.txt" Link="test-dir\dummy.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="$(CommonTestPath)StreamConformanceTests\StreamConformanceTests.csproj" /> | ||
</ItemGroup> | ||
</Project> |
5 changes: 5 additions & 0 deletions
5
src/libraries/System.IO.FileSystem/tests/LegacyTests/runtimeconfig.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"configProperties": { | ||
"System.IO.UseLegacyFileStream": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/libraries/System.IO/tests/LegacyTests/System.IO.Legacy.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<RootNamespace>System.IO</RootNamespace> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<TestRuntime>true</TestRuntime> | ||
<IncludeRemoteExecutor>true</IncludeRemoteExecutor> | ||
<!-- currently we have non Legacy strategy only for Windows, so we run the tests only on Windows --> | ||
<TargetFrameworks>$(NetCoreAppCurrent)-windows</TargetFrameworks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="..\**\*.cs" /> | ||
<!-- Helpers --> | ||
<Compile Include="$(CommonTestPath)System\Buffers\NativeMemoryManager.cs" Link="Common\System\Buffers\NativeMemoryManager.cs" /> | ||
<Compile Include="$(CommonTestPath)System\IO\CallTrackingStream.cs" Link="Common\System\IO\CallTrackingStream.cs" /> | ||
<Compile Include="$(CommonTestPath)System\IO\DelegateStream.cs" Link="Common\System\IO\DelegateStream.cs" /> | ||
<Compile Include="$(CommonTestPath)System\IO\WrappedMemoryStream.cs" Link="Common\System\IO\WrappedMemoryStream.cs" /> | ||
<Compile Include="$(CommonTestPath)System\IO\ConnectedStreams.cs" Link="Common\System\IO\ConnectedStreams.cs" /> | ||
<Compile Include="$(CommonPath)System\Net\MultiArrayBuffer.cs" Link="ProductionCode\Common\System\Net\MultiArrayBuffer.cs" /> | ||
<Compile Include="$(CommonPath)System\Net\StreamBuffer.cs" Link="ProductionCode\Common\System\Net\StreamBuffer.cs" /> | ||
<Compile Include="$(CommonPath)System\Threading\Tasks\TaskToApm.cs" Link="Common\System\Threading\Tasks\TaskToApm.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="$(CommonTestPath)StreamConformanceTests\StreamConformanceTests.csproj" /> | ||
</ItemGroup> | ||
</Project> |
5 changes: 5 additions & 0 deletions
5
src/libraries/System.IO/tests/LegacyTests/runtimeconfig.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"configProperties": { | ||
"System.IO.UseLegacyFileStream": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.