Separate out collections extensions

Even though there are relatively few collections extensions right now, there is a relatively high chance that other extension will be used in the future.
This commit is contained in:
Matt Nadareski
2026-03-23 10:50:09 -04:00
parent 1f1a5c51f3
commit 77dc8ebed7
14 changed files with 108 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ Find the link to the Nuget package [here](https://www.nuget.org/packages/SabreTo
Below are a list of the included namespaces with links to their README files:
- [SabreTools.Collections.Extensions](https://github.com/SabreTools/SabreTools.IO/tree/main/SabreTools.Collections.Extensions)
- [SabreTools.IO](https://github.com/SabreTools/SabreTools.IO/tree/main/SabreTools.IO)
- [SabreTools.IO.Compression](https://github.com/SabreTools/SabreTools.IO/tree/main/SabreTools.IO.Compression)
- [SabreTools.IO.Extensions](https://github.com/SabreTools/SabreTools.IO/tree/main/SabreTools.IO.Extensions)

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Xunit;
namespace SabreTools.IO.Extensions.Test
namespace SabreTools.Collections.Extensions.Test
{
public class DictionaryExtensionsTests
{

View File

@@ -7,7 +7,7 @@ using Xunit;
#pragma warning disable IDE0060 // Remove unused parameter
#pragma warning disable IDE0290 // Use primary constructor
namespace SabreTools.IO.Extensions.Test
namespace SabreTools.Collections.Extensions.Test
{
public class EnumerableExtensionsTests
{

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsNotAsErrors>CS0618</WarningsNotAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SabreTools.Collections.Extensions\SabreTools.Collections.Extensions.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace SabreTools.IO.Extensions
namespace SabreTools.Collections.Extensions
{
public static class DictionaryExtensions
{

View File

@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace SabreTools.IO.Extensions
namespace SabreTools.Collections.Extensions
{
public static class EnumerableExtensions
{

View File

@@ -0,0 +1,9 @@
#if NET20
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
internal sealed class ExtensionAttribute : Attribute { }
}
#endif

View File

@@ -0,0 +1,8 @@
# SabreTools.Collections.Extensions
This library contains collection-related extensions.
| Class | Description |
| --- | --- |
| `DictionaryExtensions` | Utility `Dictionary<string, List<string>>` extensions commonly used in SabreTools projects. |
| `EnumerableExtensions` | Specialized enumeration wrapper functionality. |

View File

@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeSymbols>true</IncludeSymbols>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.9.1</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
<Description>Common collections extensions used by other SabreTools projects</Description>
<Copyright>Copyright (c) Matt Nadareski 2019-2026</Copyright>
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/SabreTools/SabreTools.IO</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>collections dictionary enumerable</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="" />
</ItemGroup>
</Project>

View File

@@ -2,6 +2,7 @@
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using SabreTools.Collections.Extensions;
using SabreTools.Text.Compare;
namespace SabreTools.IO.Extensions

View File

@@ -2,7 +2,7 @@
This library contains IO-related extensions with some functionality locked behind .NET version support.
Relies on functionality found in `SabreTools.IO.Matching`, `SabreTools.Numerics`, and `SabreTools.Text.Compare`.
Relies on functionality found in `SabreTools.Collections.Extensions`, `SabreTools.IO`, `SabreTools.IO.Matching`, `SabreTools.Numerics`, `SabreTools.Numerics.Extensions`, `SabreTools.Text.Compare`, and `SabreTools.Text.Extensions`.
| Class | Description |
| --- | --- |
@@ -12,8 +12,6 @@ Relies on functionality found in `SabreTools.IO.Matching`, `SabreTools.Numerics`
| `ByteArrayReaderExtensions` | Extensions to `byte[]` for specialized type reading. |
| `ByteArrayWriterExtensions` | Extensions to `byte[]` for specialized type writing. |
| `DateTimeExtensions` | `DateTime` conversion, specifically between standard and MS-DOS formats. |
| `DictionaryExtensions` | Utility `Dictionary<string, List<string>>` extensions commonly used in SabreTools projects. |
| `EnumerableExtensions` | Specialized enumeration wrapper functionality. |
| `IOExtensions` | Path, directory, and file extensions. |
| `MarshalHelpers` | Internal-only reflection-based extensions used by some other extension classes. |
| `ParentablePathExtensions` | Extensions to `SabreTools.IO.ParentablePath` for filtering. |

View File

@@ -30,6 +30,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SabreTools.Collections.Extensions\SabreTools.Collections.Extensions.csproj" />
<ProjectReference Include="..\SabreTools.IO\SabreTools.IO.csproj" />
<ProjectReference Include="..\SabreTools.Matching\SabreTools.Matching.csproj" />
<ProjectReference Include="..\SabreTools.Numerics\SabreTools.Numerics.csproj" />

View File

@@ -31,6 +31,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\SabreTools.Collections.Extensions\*.cs" Exclude="..\SabreTools.Collections.Extensions\ExtensionAttribute.cs" />
<Compile Include="..\SabreTools.IO\*.cs" />
<Compile Include="..\SabreTools.IO.Compression\Blast\*.cs" />
<Compile Include="..\SabreTools.IO.Compression\BZip2\*.cs" />

View File

@@ -55,6 +55,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Numerics.Extensi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Numerics.Extensions.Test", "SabreTools.Numerics.Extensions.Test\SabreTools.Numerics.Extensions.Test.csproj", "{058292DF-E791-4206-9F67-DBCD76BB284C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Collections.Extensions", "SabreTools.Collections.Extensions\SabreTools.Collections.Extensions.csproj", "{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SabreTools.Collections.Extensions.Test", "SabreTools.Collections.Extensions.Test\SabreTools.Collections.Extensions.Test.csproj", "{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -377,6 +381,30 @@ Global
{058292DF-E791-4206-9F67-DBCD76BB284C}.Release|x64.Build.0 = Release|Any CPU
{058292DF-E791-4206-9F67-DBCD76BB284C}.Release|x86.ActiveCfg = Release|Any CPU
{058292DF-E791-4206-9F67-DBCD76BB284C}.Release|x86.Build.0 = Release|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Debug|x64.ActiveCfg = Debug|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Debug|x64.Build.0 = Debug|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Debug|x86.ActiveCfg = Debug|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Debug|x86.Build.0 = Debug|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Release|Any CPU.Build.0 = Release|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Release|x64.ActiveCfg = Release|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Release|x64.Build.0 = Release|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Release|x86.ActiveCfg = Release|Any CPU
{BAEF98B9-BF0F-47E3-993E-5FDD37B71193}.Release|x86.Build.0 = Release|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Debug|x64.ActiveCfg = Debug|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Debug|x64.Build.0 = Debug|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Debug|x86.ActiveCfg = Debug|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Debug|x86.Build.0 = Debug|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Release|Any CPU.Build.0 = Release|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Release|x64.ActiveCfg = Release|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Release|x64.Build.0 = Release|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Release|x86.ActiveCfg = Release|Any CPU
{C32AA0AE-46ED-49CE-9E4F-84B45130D2CE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE