Skip to content

Commit

Permalink
Package upgrades - prep for .NET 9 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
LTRData committed Sep 14, 2024
1 parent 44f88d9 commit 27fc757
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 97 deletions.
13 changes: 5 additions & 8 deletions Library/DiscUtils.Core/DiscUtils.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Implementation of the ISO, UDF, FAT and NTFS file systems is now fairly stable. VHD, XVA, VMDK and VDI disk formats are implemented, as well as read/write Registry support. The library also includes a simple iSCSI initiator, for accessing disks via iSCSI and an NFS client implementation.</Description>
<AssemblyTitle>DiscUtils (for .NET and .NET Core), core library that supports parts of DiscUtils</AssemblyTitle>
<Authors>Kenneth Bell;Quamotion;LordMike;Olof Lagerkvist</Authors>
<PackageTags>DiscUtils;VHD;VDI;XVA;VMDK;ISO;NTFS;EXT2FS</PackageTags>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DiscUtils.Streams\DiscUtils.Streams.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.CompareTo(`net461`))' &gt;= 0">
<PackageReference Include="Microsoft.Bcl.HashCode" Version="*" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.CompareTo(`net5`))' &gt;= 0">
<PackageReference Include="System.Text.Encoding.CodePages" Version="*" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>

</Project>
</Project>
4 changes: 2 additions & 2 deletions Library/DiscUtils.Core/Internal/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ public static string ResolvePath(string basePath, string path)

public static string MakeRelativePath(string path, string basePath)
{
var pathElements = path.AsMemory().Split('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
var basePathElements = basePath.AsMemory().Split('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
var pathElements = path.AsMemory().TokenEnum('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
var basePathElements = basePath.AsMemory().TokenEnum('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();

if (basePathElements.Length > 0 && basePath[basePath.Length - 1] != Path.DirectorySeparatorChar)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ internal static GenericAce CreateFromSddlForm(ReadOnlySpan<char> sddlForm, ref i
var count = endPos;
var elementsStr = sddlForm.Slice(0, count).ToString();
elementsStr = elementsStr.ToUpperInvariant();
var elements = elementsStr.AsMemory().Split(';').ToArray();
var elements = elementsStr.AsMemory().TokenEnum(';').ToArray();
if (elements.Length != 6)
{
throw new ArgumentException("Invalid SDDL string.", nameof(sddlForm));
Expand Down
13 changes: 5 additions & 8 deletions Library/DiscUtils.Fat/DiscUtils.Fat.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DiscUtils FAT filesystem parser</Description>
<Authors>Kenneth Bell;LordMike;Olof Lagerkvist</Authors>
<PackageTags>DiscUtils;Filesystem;FAT</PackageTags>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DiscUtils.Core\DiscUtils.Core.csproj" />
<!-- In order to test FileName and other internals in Unit tests-->
<InternalsVisibleTo Include="LibraryTests" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.CompareTo(`net5`))' &gt;= 0">
<PackageReference Include="System.Text.Encoding.CodePages" Version="*" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition="('$(TargetFramework.CompareTo(`net5`))' &lt; 0 And '$(TargetFramework.CompareTo(`net462`))' &gt;= 0) Or '$(TargetFramework.StartsWith(`netstandard`))'">
<PackageReference Include="System.Collections.Immutable" Version="*" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
</ItemGroup>

</Project>
</Project>
4 changes: 2 additions & 2 deletions Library/DiscUtils.Fat/FatFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ public override void CopyFile(string sourceFile, string destinationFile, bool ov
/// <param name="path">The directory to create.</param>
public override void CreateDirectory(string path)
{
var pathElements = path.AsMemory().Split('\\', '/', StringSplitOptions.RemoveEmptyEntries);
var pathElements = path.AsMemory().TokenEnum('\\', '/', StringSplitOptions.RemoveEmptyEntries);

var focusDir = _rootDir;

Expand Down Expand Up @@ -1735,7 +1735,7 @@ private long GetDirectoryEntry(Directory dir, string path, out Directory parent)

private long GetDirectoryEntry(Directory dir, string path, out Directory parent, out string lastPathName)
{
var pathElements = path.AsMemory().Split('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
var pathElements = path.AsMemory().TokenEnum('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
return GetDirectoryEntry(dir, pathElements, 0, out parent, out lastPathName);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/DiscUtils.Iscsi/LunInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static LunInfo ParseUri(Uri uri)
var targetInfo = new TargetInfo(targetName,
[new TargetAddress(address, port, targetGroupTag)]);

foreach (var queryElem in uri.Query.AsMemory(1).Split('&'))
foreach (var queryElem in uri.Query.AsMemory(1).TokenEnum('&'))
{
if (queryElem.Span.StartsWith("LUN=".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
Expand Down
4 changes: 2 additions & 2 deletions Library/DiscUtils.Iso9660/BuildDirectoryMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ private class DirectorySortedComparison : Comparer<BuildDirectoryMember>
{
public override int Compare(BuildDirectoryMember x, BuildDirectoryMember y)
{
var xParts = x.Name.AsMemory().Split('.', ';').ToArray();
var yParts = y.Name.AsMemory().Split('.', ';').ToArray();
var xParts = x.Name.AsMemory().TokenEnum('.', ';').ToArray();
var yParts = y.Name.AsMemory().TokenEnum('.', ';').ToArray();

ReadOnlyMemory<char> xPart;
ReadOnlyMemory<char> yPart;
Expand Down
6 changes: 3 additions & 3 deletions Library/DiscUtils.Iso9660/CDBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void SetBootImage(Stream image, BootDeviceEmulation emulation, int loadSe
/// </remarks>
public BuildDirectoryInfo AddDirectory(string name)
{
var nameElements = name.AsMemory().Split('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
var nameElements = name.AsMemory().TokenEnum('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
return GetDirectory(nameElements, nameElements.Length, true);
}

Expand Down Expand Up @@ -541,7 +541,7 @@ private Stream PatchBootImage(Stream bootImage, uint pvdLba, uint bootImageLba)
/// <returns>BuildDirectoryMember object representing already added file.</returns>
public BuildDirectoryMember GetFile(string path)
{
var nameElements = path.AsMemory().Split('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
var nameElements = path.AsMemory().TokenEnum('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
var dir = GetDirectory(nameElements, nameElements.Length - 1, true);

var name = nameElements[nameElements.Length - 1].ToString();
Expand All @@ -563,7 +563,7 @@ public BuildDirectoryMember GetFile(string path)

private void CheckDirectoryForFilePath(string name, out ReadOnlyMemory<char>[] nameElements, out BuildDirectoryInfo dir)
{
nameElements = name.AsMemory().Split('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
nameElements = name.AsMemory().TokenEnum('\\', '/', StringSplitOptions.RemoveEmptyEntries).ToArray();
dir = GetDirectory(nameElements, nameElements.Length - 1, true);

if (dir.TryGetMember(nameElements[nameElements.Length - 1].ToString(), out _))
Expand Down
11 changes: 4 additions & 7 deletions Library/DiscUtils.Iso9660/DiscUtils.Iso9660.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DiscUtils Iso9660</Description>

<PackageTags>DiscUtils;Optical;Iso9660</PackageTags>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DiscUtils.Core\DiscUtils.Core.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.CompareTo(`net461`))' &gt;= 0">
<PackageReference Include="Microsoft.Bcl.HashCode" Version="*" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
</ItemGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion Library/DiscUtils.Net/Dns/DnsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class DnsClient

internal static string NormalizeDomainName(string name)
{
var labels = name.AsMemory().Split('.', StringSplitOptions.RemoveEmptyEntries);
var labels = name.AsMemory().TokenEnum('.', StringSplitOptions.RemoveEmptyEntries);

return $"{string.Join(".", labels)}.";
}
Expand Down
11 changes: 4 additions & 7 deletions Library/DiscUtils.Nfs/DiscUtils.Nfs.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DiscUtils Nfs</Description>

<PackageTags>DiscUtils;Nfs</PackageTags>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DiscUtils.Core\DiscUtils.Core.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.CompareTo(`net461`))' &gt;= 0">
<PackageReference Include="Microsoft.Bcl.HashCode" Version="*" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
</ItemGroup>

</Project>
</Project>
12 changes: 5 additions & 7 deletions Library/DiscUtils.Ntfs/DiscUtils.Ntfs.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DiscUtils NTFS filesystem parser</Description>
<Authors>Kenneth Bell;LordMike;Olof Lagerkvist</Authors>
<PackageTags>DiscUtils;Filesystem;NTFS</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="*" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DiscUtils.Core\DiscUtils.Core.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.CompareTo(`net461`))' &gt;= 0">
<PackageReference Include="Microsoft.Bcl.HashCode" Version="*" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
</ItemGroup>

</Project>
</Project>
4 changes: 2 additions & 2 deletions Library/DiscUtils.OpticalDiscSharing/DiscContentBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ private static Dictionary<string, string> ParseAuthenticationHeader(string heade
{
var result = new Dictionary<string, string>();

var elements = header.AsMemory().Split(' ').ToArray();
var elements = header.AsMemory().TokenEnum(' ').ToArray();

authMethod = elements[0].ToString();

for (var i = 1; i < elements.Length; ++i)
{
var nvPair = elements[i].Split('=', StringSplitOptions.None);
var nvPair = elements[i].TokenEnum('=', StringSplitOptions.None);
result.Add(nvPair.ElementAt(0).ToString(), nvPair.ElementAt(1).Span.Trim('\"').ToString());
}

Expand Down
4 changes: 2 additions & 2 deletions Library/DiscUtils.OpticalDiscSharing/OpticalDiscService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ private Dictionary<string, string> GetParams(string section)
if (_instance.Parameters.TryGetValue(section, out var data))
{
var asString = Encoding.ASCII.GetString(data);
var nvPairs = asString.AsSpan().Split(',');
var nvPairs = asString.AsSpan().TokenEnum(',');

foreach (var nvPair in nvPairs)
{
var parts = nvPair.Split('=');
var parts = nvPair.TokenEnum('=');
result[parts.First().ToString()] = parts.ElementAt(1).ToString();
}
}
Expand Down
11 changes: 4 additions & 7 deletions Library/DiscUtils.Registry/DiscUtils.Registry.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DiscUtils Registry</Description>

<PackageTags>DiscUtils;Registry</PackageTags>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DiscUtils.Core\DiscUtils.Core.csproj" />
<ProjectReference Include="..\DiscUtils.Streams\DiscUtils.Streams.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Memory" Version="*" />
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>

</Project>
</Project>
15 changes: 6 additions & 9 deletions Library/DiscUtils.Streams/DiscUtils.Streams.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DiscUtils Streams</Description>
<Authors>Kenneth Bell;LordMike;Bianco Veigel;Olof Lagerkvist</Authors>
<PackageTags>DiscUtils;Streams</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Memory" Version="*" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="LTRData.Extensions" Version="1.0.10" />
<PackageReference Include="LTRData.Extensions" Version="1.0.11" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.CompareTo(`net461`))' &gt;= 0">
<PackageReference Include="Microsoft.Bcl.HashCode" Version="*" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
</ItemGroup>

</Project>
</Project>
11 changes: 4 additions & 7 deletions Library/DiscUtils.Vhd/DiscUtils.Vhd.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DiscUtils VHD</Description>

<PackageTags>DiscUtils;VHD</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="*" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DiscUtils.Core\DiscUtils.Core.csproj" />
</ItemGroup>

</Project>
</Project>
11 changes: 4 additions & 7 deletions Library/DiscUtils.Vhdx/DiscUtils.Vhdx.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DiscUtils VHDX</Description>

<PackageTags>DiscUtils;VHDX</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="*" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DiscUtils.Core\DiscUtils.Core.csproj" />
</ItemGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion Library/DiscUtils.Vmdk/DescriptorFileEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public DescriptorFileEntry(string key, string value, DescriptorFileEntryType typ

public static DescriptorFileEntry Parse(string value)
{
var parts = value.AsMemory().Split('=').Take(2).ToArray();
var parts = value.AsMemory().TokenEnum('=').Take(2).ToArray();

for (var i = 0; i < parts.Length; ++i)
{
Expand Down
11 changes: 4 additions & 7 deletions Library/DiscUtils.Vmdk/DiscUtils.Vmdk.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>DiscUtils VMDK</Description>

<PackageTags>DiscUtils;VMDK</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="*" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DiscUtils.Core\DiscUtils.Core.csproj" />
</ItemGroup>

</Project>
</Project>
4 changes: 2 additions & 2 deletions Library/DiscUtils.Wim/WimFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ protected override void Dispose(bool disposing)

private static void SplitFileName(string path, out string filePart, out string altStreamPart)
{
var streamSepPos = path.IndexOf(":", StringComparison.Ordinal);
var streamSepPos = path.IndexOf(':');

if (streamSepPos >= 0)
{
Expand Down Expand Up @@ -673,7 +673,7 @@ private DirectoryEntry GetEntry(string path)
path = Path.DirectorySeparatorChar + path;
}

return GetEntry(GetDirectory(0), path.AsMemory().Split('/', '\\').ToArray());
return GetEntry(GetDirectory(0), path.AsMemory().TokenEnum('/', '\\').ToArray());
}

private DirectoryEntry GetEntry(List<DirectoryEntry> dir, ReadOnlyMemory<char>[] path)
Expand Down
Loading

0 comments on commit 27fc757

Please sign in to comment.