Skip to content

Commit

Permalink
refactor: restructure packages to improve extensibility (#919)
Browse files Browse the repository at this point in the history
This change splits the System.IO.Abstractions package into TestableIO.System.IO.Abstractions and TestableIO.System.IO.Abstractions.Wrappers.

The former contains just the interfaces and the latter the default wrapper implementations.
The package System.IO.Abstractions still exists as meta package to reduce impact on existing users.
The same applies to TestableIO.System.IO.Abstractions.TestingHelpers.

BREAKING CHANGE: This refactoring moves all types to the TestableIO.System.IO.Abstractions library. Users might need to recompile their libraries.

Co-authored-by: Valentin Breuß <vbreuss@gmail.com>
  • Loading branch information
fgreinacher and vbreuss committed Nov 28, 2022
1 parent 6e2fd18 commit 5c2c588
Show file tree
Hide file tree
Showing 98 changed files with 68 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ jobs:
github.event_name == 'push' &&
(
startsWith(github.event.head_commit.message, 'feat:') ||
startsWith(github.event.head_commit.message, 'fix:')
startsWith(github.event.head_commit.message, 'fix:') ||
contains(github.event.head_commit.message, 'breaking change')
)
needs: [pack]
runs-on: ubuntu-latest
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![System.IO.Abstractions](https://socialify.git.ci/TestableIO/System.IO.Abstractions/image?description=1&font=Source%20Code%20Pro&forks=1&issues=1&pattern=Charlie%20Brown&pulls=1&stargazers=1&theme=Dark)
[![NuGet](https://img.shields.io/nuget/v/System.IO.Abstractions.svg)](https://www.nuget.org/packages/System.IO.Abstractions)
[![NuGet](https://img.shields.io/nuget/v/TestableIO.System.IO.Abstractions.svg)](https://www.nuget.org/packages/TestableIO.System.IO.Abstractions)
![Continuous Integration](https://github.com/TestableIO/System.IO.Abstractions/workflows/Continuous%20Integration/badge.svg)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/54479b054d194adfb4ff476ef0182fe0)](https://www.codacy.com/gh/TestableIO/System.IO.Abstractions/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=TestableIO/System.IO.Abstractions&amp;utm_campaign=Badge_Grade)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
Expand All @@ -8,9 +8,11 @@
At the core of the library is `IFileSystem` and `FileSystem`. Instead of calling methods like `File.ReadAllText` directly, use `IFileSystem.File.ReadAllText`. We have exactly the same API, except that ours is injectable and testable.

```shell
dotnet add package System.IO.Abstractions
dotnet add package TestableIO.System.IO.Abstractions
```

*Note: This NuGet package is also published as `System.IO.Abstractions` but we suggest to use the prefix to make clear that this is not an official .NET package.*

```csharp
public class MyComponent
{
Expand Down Expand Up @@ -43,9 +45,11 @@ public class MyComponent
The library also ships with a series of test helpers to save you from having to mock out every call, for basic scenarios. They are not a complete copy of a real-life file system, but they'll get you most of the way there.

```shell
dotnet add package System.IO.Abstractions.TestingHelpers
dotnet add package TestableIO.System.IO.Abstractions.TestingHelpers
```

*Note: This NuGet package is also published as `System.IO.Abstractions.TestingHelpers` but we suggest to use the prefix to make clear that this is not an official .NET package.*

```csharp
[Test]
public void MyComponent_Validate_ShouldThrowNotSupportedExceptionIfTestingIsNotAwesome()
Expand Down
37 changes: 18 additions & 19 deletions System.IO.Abstractions.sln
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5F3BDA62-8052-4C37-97A0-94354AA971B0}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
StrongName.snk = StrongName.snk
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Abstractions.TestingHelpers.Tests", "tests\System.IO.Abstractions.TestingHelpers.Tests\System.IO.Abstractions.TestingHelpers.Tests.csproj", "{20B02738-952A-40F5-9C10-E2F83013E9FC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Abstractions", "src\System.IO.Abstractions\System.IO.Abstractions.csproj", "{B7DA254D-496F-4C50-969C-CF925758E2ED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Abstractions.TestingHelpers", "src\System.IO.Abstractions.TestingHelpers\System.IO.Abstractions.TestingHelpers.csproj", "{0103D32A-6124-4A1A-AD6C-30EB957F09B0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Abstractions.Benchmarks", "benchmarks\System.IO.Abstractions.Benchmarks\System.IO.Abstractions.Benchmarks.csproj", "{015B3812-E01D-479C-895D-BDDF16E798CA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestableIO.System.IO.Abstractions.Benchmarks", "benchmarks\TestableIO.System.IO.Abstractions.Benchmarks\TestableIO.System.IO.Abstractions.Benchmarks.csproj", "{015B3812-E01D-479C-895D-BDDF16E798CA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BCEC61BD-4941-41EC-975A-ACEFC7AC1780}"
EndProject
Expand All @@ -25,21 +17,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestableIO.System.IO.Abstra
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestableIO.System.IO.Abstractions.Wrappers", "src\TestableIO.System.IO.Abstractions.Wrappers\TestableIO.System.IO.Abstractions.Wrappers.csproj", "{3698BB93-B031-4140-BAEF-D3480A94F531}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "images", "images", "{F781892B-7C5D-4C8D-8D3D-3E9E207D686D}"
ProjectSection(SolutionItems) = preProject
images\icon_256x256.png = images\icon_256x256.png
EndProjectSection
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{C078E0B6-9747-475F-A999-B9E775DF6643}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestableIO.System.IO.Abstractions.TestingHelpers", "src\TestableIO.System.IO.Abstractions.TestingHelpers\TestableIO.System.IO.Abstractions.TestingHelpers.csproj", "{DE22AA55-408F-4041-B85D-26D6D6A158A4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestableIO.System.IO.Abstractions.TestingHelpers.Tests", "tests\TestableIO.System.IO.Abstractions.TestingHelpers.Tests\TestableIO.System.IO.Abstractions.TestingHelpers.Tests.csproj", "{919888D2-E37D-40E7-8AD0-600F9429316D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{20B02738-952A-40F5-9C10-E2F83013E9FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{20B02738-952A-40F5-9C10-E2F83013E9FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20B02738-952A-40F5-9C10-E2F83013E9FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20B02738-952A-40F5-9C10-E2F83013E9FC}.Release|Any CPU.Build.0 = Release|Any CPU
{B7DA254D-496F-4C50-969C-CF925758E2ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7DA254D-496F-4C50-969C-CF925758E2ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7DA254D-496F-4C50-969C-CF925758E2ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -64,14 +53,24 @@ Global
{3698BB93-B031-4140-BAEF-D3480A94F531}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3698BB93-B031-4140-BAEF-D3480A94F531}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3698BB93-B031-4140-BAEF-D3480A94F531}.Release|Any CPU.Build.0 = Release|Any CPU
{DE22AA55-408F-4041-B85D-26D6D6A158A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE22AA55-408F-4041-B85D-26D6D6A158A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE22AA55-408F-4041-B85D-26D6D6A158A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE22AA55-408F-4041-B85D-26D6D6A158A4}.Release|Any CPU.Build.0 = Release|Any CPU
{919888D2-E37D-40E7-8AD0-600F9429316D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{919888D2-E37D-40E7-8AD0-600F9429316D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{919888D2-E37D-40E7-8AD0-600F9429316D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{919888D2-E37D-40E7-8AD0-600F9429316D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{20B02738-952A-40F5-9C10-E2F83013E9FC} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
{0103D32A-6124-4A1A-AD6C-30EB957F09B0} = {C078E0B6-9747-475F-A999-B9E775DF6643}
{B7DA254D-496F-4C50-969C-CF925758E2ED} = {C078E0B6-9747-475F-A999-B9E775DF6643}
{015B3812-E01D-479C-895D-BDDF16E798CA} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
{7105D748-1253-409F-A624-4879412EF3C2} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
{919888D2-E37D-40E7-8AD0-600F9429316D} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8885C59C-F6A0-4C2F-A3BC-B720E9BD161F}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>System.IO.Abstractions.Benchmarks</AssemblyName>
<RootNamespace>System.IO.Abstractions.Benchmarks</RootNamespace>
<AssemblyName>TestableIO.System.IO.Abstractions.Benchmarks</AssemblyName>
<RootNamespace>TestableIO.System.IO.Abstractions.Benchmarks</RootNamespace>
<Description>Bencharmks comparisons.</Description>
<TargetFrameworks>net5.0;netcoreapp3.1;net461</TargetFrameworks>
<PackageProjectUrl>https://github.com/TestableIO/System.IO.Abstractions</PackageProjectUrl>
Expand All @@ -13,8 +13,8 @@
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../../src/System.IO.Abstractions/System.IO.Abstractions.csproj" />
<ProjectReference Include="../../src/System.IO.Abstractions.TestingHelpers/System.IO.Abstractions.TestingHelpers.csproj" />
<ProjectReference Include="../../src/TestableIO.System.IO.Abstractions.Wrappers/TestableIO.System.IO.Abstractions.Wrappers.csproj" />
<ProjectReference Include="../../src/TestableIO.System.IO.Abstractions.TestingHelpers/TestableIO.System.IO.Abstractions.TestingHelpers.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>System.IO.Abstractions.TestingHelpers</AssemblyName>
<RootNamespace>System.IO.Abstractions.TestingHelpers</RootNamespace>
<Description>A set of pre-built mocks to help when testing file system interactions.</Description>
<TargetFrameworks>net6.0;net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
<PackageIcon>icon_256x256.png</PackageIcon>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../System.IO.Abstractions/System.IO.Abstractions.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="..\..\images\icon_256x256.png" Pack="true" PackagePath="\" />
</ItemGroup>
<PropertyGroup>
<AssemblyName>System.IO.Abstractions.TestingHelpers</AssemblyName>
<RootNamespace>System.IO.Abstractions.TestingHelpers</RootNamespace>
<Description>A set of pre-built mocks to help when testing file system interactions.</Description>
<TargetFrameworks>net6.0;net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
<PackageIcon>icon_256x256.png</PackageIcon>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TestableIO.System.IO.Abstractions.TestingHelpers\TestableIO.System.IO.Abstractions.TestingHelpers.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\images\icon_256x256.png" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>TestableIO.System.IO.Abstractions.TestingHelpers</AssemblyName>
<RootNamespace>System.IO.Abstractions.TestingHelpers</RootNamespace>
<Description>A set of pre-built mocks to help when testing file system interactions.</Description>
<TargetFrameworks>net6.0;net5.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
<PackageIcon>icon_256x256.png</PackageIcon>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../TestableIO.System.IO.Abstractions/TestableIO.System.IO.Abstractions.csproj" />
<ProjectReference Include="../TestableIO.System.IO.Abstractions.Wrappers/TestableIO.System.IO.Abstractions.Wrappers.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="..\..\images\icon_256x256.png" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
<EmbeddedResource Include="TestFiles\TestFile.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/System.IO.Abstractions/System.IO.Abstractions.csproj" />
<ProjectReference Include="../../src/System.IO.Abstractions.TestingHelpers/System.IO.Abstractions.TestingHelpers.csproj" />
<ProjectReference Include="../../src/TestableIO.System.IO.Abstractions.TestingHelpers/TestableIO.System.IO.Abstractions.TestingHelpers.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0">
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "17.2",
"version": "18.0",
"assemblyVersion": {
"precision": "major"
},
Expand Down

0 comments on commit 5c2c588

Please sign in to comment.