Skip to content

Commit

Permalink
Add .NET 9 to target frameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
mnadareski committed Nov 16, 2024
1 parent 2508b71 commit 0d79e88
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_nupkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore dependencies
run: dotnet restore
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
strategy:
matrix:
project: [psxt001z]
runtime: [win-x86, win-x64, linux-x64, osx-x64] #[win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64]
framework: [net8.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0]
conf: [Release, Debug]
runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64]
framework: [net9.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0, net9.0]
conf: [Debug] #[Release, Debug]

steps:
- uses: actions/checkout@v4
Expand All @@ -23,13 +23,13 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8')) && '-p:PublishSingleFile=true' || ''}}
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8') || startsWith(matrix.framework, 'net9')) && '-p:PublishSingleFile=true' || ''}}

- name: Archive build
run: zip -r ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip ${{ matrix.project }}/bin/${{ matrix.conf }}/${{ matrix.framework }}/${{ matrix.runtime }}/publish/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Build
run: dotnet build
26 changes: 11 additions & 15 deletions psxt001z.Library/FileTools.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Text;
using SabreTools.IO.Extensions;

namespace psxt001z
{
Expand All @@ -22,37 +23,33 @@ public string GetExecutableName()
string filename = string.Empty;
while (filename != "SYSTEM.CNF")
{
byte[] buf = new byte[10];
_file.Read(buf, 0, 10);
byte[] buf = _file.ReadBytes(10);
filename = Encoding.ASCII.GetString(buf);
_file.Seek(-9, SeekOrigin.Current);
}

byte[] buffer = new byte[20];

_file.Seek(-32, SeekOrigin.Current);
_file.Read(buffer, 0, 4);
uint lba = BitConverter.ToUInt32(buffer, 0);
uint lba = _file.ReadUInt32();

_file.Seek((2352 * lba) + 29, SeekOrigin.Begin);
_file.Read(buffer, 0, 6);
byte[] buffer = _file.ReadBytes(6);

string iniLine = Encoding.ASCII.GetString(buffer);
while (iniLine != "cdrom:")
{
_file.Seek(-5, SeekOrigin.Current);
_file.Read(buffer, 0, 6);
buffer = _file.ReadBytes(6);
iniLine = Encoding.ASCII.GetString(buffer);
}

_file.Read(buffer, 0, 1);
buffer = _file.ReadBytes(1);
if (buffer[0] != '\\')
_file.Seek(-1, SeekOrigin.Current);

int i = -1;
do
{
_file.Read(buffer, ++i, 1);
_ = _file.Read(buffer, ++i, 1);
} while (buffer[i] != ';');

for (long a = 0; a < i; a++)
Expand All @@ -65,20 +62,19 @@ public string GetExecutableName()

public string GetDate()
{
byte[] buffer = new byte[12], datenofrmt = new byte[3];

_file.Seek(51744, SeekOrigin.Begin);

byte[] buffer = new byte[12];
do
{
_file.Read(buffer, 0, 11);
_ = _file.Read(buffer, 0, 11);
buffer[11] = 0;
_file.Seek(-10, SeekOrigin.Current);
} while (Encoding.ASCII.GetString(_executableName) != Encoding.ASCII.GetString(buffer));

_file.Seek(-16, SeekOrigin.Current);
_file.Read(datenofrmt, 0, 3);

byte[] datenofrmt = _file.ReadBytes(3);
if (datenofrmt[0] < 50)
{
byte[] year = Encoding.ASCII.GetBytes($"{2000 + datenofrmt[0]}");
Expand Down Expand Up @@ -140,7 +136,7 @@ public int GetImageSize()
{
_file.Seek(0x9368, SeekOrigin.Begin);
byte[] sizebuf = new byte[4];
_file.Read(sizebuf, 0, 4);
_ = _file.Read(sizebuf, 0, 4);
return BitConverter.ToInt32(sizebuf, 0);
}
}
Expand Down
10 changes: 5 additions & 5 deletions psxt001z.Library/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,30 @@ internal static byte[] GetExecutableName(Stream file)
file.Seek(51744, SeekOrigin.Begin);
while (Encoding.ASCII.GetString(buffer) != "SYSTEM.CNF")
{
file.Read(buffer, 0, 10);
_ = file.Read(buffer, 0, 10);
buffer[10] = 0;
file.Seek(-9, SeekOrigin.Current);
}

file.Seek(-32, SeekOrigin.Current);
uint lba = file.ReadUInt32();
file.Seek((2352 * lba) + 29, SeekOrigin.Begin);
file.Read(buffer, 0, 6);
_ = file.Read(buffer, 0, 6);
buffer[6] = 0;
while (Encoding.ASCII.GetString(buffer) != "cdrom:")
{
file.Seek(-5, SeekOrigin.Current);
file.Read(buffer, 0, 6);
_ = file.Read(buffer, 0, 6);
}

file.Read(buffer, 0, 1);
_ = file.Read(buffer, 0, 1);
if (buffer[0] != '\\')
file.Seek(-1, SeekOrigin.Current);

int i = -1;
do
{
file.Read(buffer, ++i, 1);
_ = file.Read(buffer, ++i, 1);
} while (buffer[i] != ';');

for (int a = 0; a < i; a++)
Expand Down
8 changes: 4 additions & 4 deletions psxt001z.Library/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static bool Info(string filename, bool fix)

#region Type

image.Read(buffer, 0, 12);
_ = image.Read(buffer, 0, 12);

int sectorsize;
if (buffer.Take(12).SequenceEqual(syncheader.Take(12)))
Expand Down Expand Up @@ -130,7 +130,7 @@ public static bool Info(string filename, bool fix)
var crc = new CRC32();
for (int i = 0; i < 16; i++)
{
image.Read(buffer, 0, 2352);
_ = image.Read(buffer, 0, 2352);
crc.Calculate(buffer, 0, 2352);
}

Expand All @@ -155,7 +155,7 @@ public static bool Info(string filename, bool fix)
#region Postgap

image.Seek((sectors - 150) * sectorsize + 16, SeekOrigin.Begin);
image.Read(buffer, 0, 2336);
_ = image.Read(buffer, 0, 2336);

string postgap = "Postgap type: Form ";
if ((buffer[2] >> 5 & 0x01) != 0)
Expand Down Expand Up @@ -203,7 +203,7 @@ public static bool Info(string filename, bool fix)
{
bool bad = false;
image.Seek(sector * sectorsize, SeekOrigin.Begin);
image.Read(buffer, 0, sectorsize);
_ = image.Read(buffer, 0, sectorsize);

string sectorInfo = string.Empty;

Expand Down
2 changes: 1 addition & 1 deletion psxt001z.Library/Scramble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal static int __main(string[] args)
}
else
{
sector_file.Read(sector, 0, sectors);
_ = sector_file.Read(sector, 0, sectors);
}

int offset = MemSearch(sector, sync, sectors, 12);
Expand Down
12 changes: 8 additions & 4 deletions psxt001z.Library/psxt001z.Library.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<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</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -25,8 +24,13 @@
<None Include="../README.md" Pack="true" PackagePath="" />
</ItemGroup>

<!-- Support for old .NET versions -->
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`))">
<PackageReference Include="Net30.LinqBridge" Version="1.3.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="SabreTools.IO" Version="1.4.0" />
<PackageReference Include="SabreTools.IO" Version="1.5.1" />
</ItemGroup>

</Project>
28 changes: 14 additions & 14 deletions psxt001z/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static void Info(string filename)
var crc = new CRC32();
for (uint i = 0; i < 16; i++)
{
image.Read(buffer, 0, 2352);
_ = image.Read(buffer, 0, 2352);
crc.Calculate(buffer, 0, 2352);
}

Expand Down Expand Up @@ -264,7 +264,7 @@ private static bool Patch(string[] args)
while (f1.Position < f1.Length && f2.Position < f2.Length)
{
byte[] buffer = new byte[1];
f2.Read(buffer, 0, 1);
_ = f2.Read(buffer, 0, 1);
f1.Write(buffer, 0, 1);
i++;
}
Expand Down Expand Up @@ -377,13 +377,13 @@ private static void AntiZektor(string filename)
image.Seek(sector * 2352 + 18, SeekOrigin.Begin);

byte[] z = new byte[1];
image.Read(z, 0, 1);
_ = image.Read(z, 0, 1);
if ((z[0] >> 5 & 0x1) != 0)
{
image.Seek(-3, SeekOrigin.Current);

byte[] buffer = new byte[2332];
image.Read(buffer, 0, 2332);
_ = image.Read(buffer, 0, 2332);
image.Seek(0, SeekOrigin.Current);

buffer = BitConverter.GetBytes(CalculateEDC(buffer, 0, 2332, edc_lut));
Expand Down Expand Up @@ -634,13 +634,13 @@ private static void Matrix(string[] args)
for (long i = 0; i < subsize; i++)
{
byte[] r1 = new byte[1];
f1.Read(r1, 0, 1);
_ = f1.Read(r1, 0, 1);

byte[] r2 = new byte[1];
f2.Read(r2, 0, 1);
_ = f2.Read(r2, 0, 1);

byte[] r3 = new byte[1];
f3.Read(r3, 0, 1);
_ = f3.Read(r3, 0, 1);

if (r1 == r2)
{
Expand Down Expand Up @@ -691,19 +691,19 @@ private static void Str(string[] args)
str.Seek(2, SeekOrigin.Current);

byte[] ctrlbyte = new byte[1];
str.Read(ctrlbyte, 0, 1);
_ = str.Read(ctrlbyte, 0, 1);

byte[] buffer = new byte[2336];
if ((ctrlbyte[0] >> 5 & 0x1) != 0)
{
str.Seek(-3, SeekOrigin.Current);
str.Read(buffer, 0, 2336);
_ = str.Read(buffer, 0, 2336);
audio.Write(buffer, 0, 2336);
}
else
{
str.Seek(5, SeekOrigin.Current);
str.Read(buffer, 0, 2048);
_ = str.Read(buffer, 0, 2048);
video.Write(buffer, 0, 2048);
str.Seek(280, SeekOrigin.Current);
}
Expand Down Expand Up @@ -738,7 +738,7 @@ private static void Str2Bs(string[] args)
Stream bs = File.OpenWrite(directory + "\\000001.bs");

str.Seek(32, SeekOrigin.Current);
str.Read(buffer, 0, 2016);
_ = str.Read(buffer, 0, 2016);
Console.WriteLine(directory);

bs.Write(buffer, 0, 2016);
Expand All @@ -750,7 +750,7 @@ private static void Str2Bs(string[] args)
str.Seek(1, SeekOrigin.Current);

byte[] byt = new byte[1];
str.Read(byt, 0, 1);
_ = str.Read(byt, 0, 1);

if (byt[0] == 0)
{
Expand All @@ -760,7 +760,7 @@ private static void Str2Bs(string[] args)
}

str.Seek(30, SeekOrigin.Current);
str.Read(buffer, 0, 2016);
_ = str.Read(buffer, 0, 2016);
bs.Write(buffer, 0, 2016);
}

Expand Down Expand Up @@ -877,7 +877,7 @@ private static void Zektor(string filename)
image.Seek(sector * 2352 + 18, SeekOrigin.Begin);

byte[] z = new byte[1];
image.Read(z, 0, 1);
_ = image.Read(z, 0, 1);
if ((z[0] >> 5 & 0x1) != 0)
{
image.Seek(2329, SeekOrigin.Current);
Expand Down
19 changes: 16 additions & 3 deletions psxt001z/psxt001z.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>0.21-rc1</Version>
<Version>0.21-rc2</Version>

<!-- Package Properties -->
<Authors>Kirill Korolyov, Matt Nadareski</Authors>
Expand All @@ -20,6 +19,20 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<!-- Support All Frameworks -->
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net4`))">
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\psxt001z.Library\psxt001z.Library.csproj" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 0d79e88

Please sign in to comment.