Skip to content

Commit

Permalink
Common: Migrate to .NET 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
julianxhokaxhiu committed Dec 26, 2024
1 parent 2379799 commit ea21f72
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion AppCore/AppCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<TargetFramework>net9.0-windows7.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>AppCore</RootNamespace>
<ReleaseVersion>1.56</ReleaseVersion>
Expand Down
15 changes: 10 additions & 5 deletions AppCore/FileDownloadTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ private set

public FileDownloadTask(string source, string destination, object userState = null, CookieContainer cookies = null, FileDownloadTaskMode fdtMode = default, int chunkSizeInBytes = 10000 /*Default to 0.01 mb*/)
{
System.Net.ServicePointManager.Expect100Continue = false; // ensure this is set to false
AllowedToRun = true;

_sourceUrl = source;
Expand Down Expand Up @@ -133,11 +132,17 @@ public FileDownloadTask(string source, string destination, object userState = nu
private async Task Start(long range)
{
if (IsPaused || IsCanceled)
return;

var handler = _cookies != null ? new HttpClientHandler() { CookieContainer = _cookies } : new HttpClientHandler();
return;

var handler = new HttpClientHandler()
{
UseCookies = _cookies != null,
CookieContainer = _cookies,
SslProtocols = System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls13
};
var client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0");
client.DefaultRequestHeaders.ExpectContinue = false;
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0");
if (Headers != null) client.DefaultRequestHeaders.Add("Referer", Headers["Referer"]);
var request = new HttpRequestMessage { RequestUri = new Uri(_sourceUrl) };
if (range > 0) request.Headers.Range = new RangeHeaderValue(0, range);
Expand Down
2 changes: 1 addition & 1 deletion AppCore/Install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private void ProcessDownload(object state)
int isig = 0;
using (var fs = new FileStream(source, FileMode.Open, FileAccess.Read))
{
fs.Read(sig, 0, 4);
fs.ReadExactly(sig, 0, 4);
isig = BitConverter.ToInt32(sig, 0);
fs.Close();
}
Expand Down
2 changes: 1 addition & 1 deletion AppProxy/AppProxy.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<TargetFramework>net9.0-windows7.0</TargetFramework>
<RootNamespace>AppProxy</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
5 changes: 0 additions & 5 deletions AppUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public partial class App : Application

private bool hasShownErrorWindow = false;

public App()
{
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
}

protected override void OnStartup(StartupEventArgs e)
{
bool isNewInstance;
Expand Down
2 changes: 1 addition & 1 deletion AppUI/AppUI.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<TargetFramework>net9.0-windows7.0</TargetFramework>
<OutputType>WinExe</OutputType>
<RootNamespace>AppUI</RootNamespace>
<AssemblyName>Junction VIII</AssemblyName>
Expand Down
3 changes: 2 additions & 1 deletion AppWrapper/AppWrapper.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<TargetFramework>net9.0-windows7.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>AppWrapper</RootNamespace>
<ReleaseVersion>1.56</ReleaseVersion>
Expand Down Expand Up @@ -40,5 +40,6 @@
<PackageReference Include="SharpCompress">
<Version>0.38.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="9.0.0" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions AppWrapper/Bytes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ public static void WriteUShort(byte[] data, int offset, ushort value) {
}
public static long ReadLong(this System.IO.Stream s) {
byte[] data = new byte[8];
s.Read(data, 0, 8);
s.ReadExactly(data, 0, 8);
return BitConverter.ToInt64(data, 0);
}
public static int ReadInt(this System.IO.Stream s) {
byte[] data = new byte[4];
s.Read(data, 0, 4);
s.ReadExactly(data, 0, 4);
return BitConverter.ToInt32(data, 0);
}
public static ushort ReadUShort(this System.IO.Stream s) {
byte[] data = new byte[2];
s.Read(data, 0, 2);
s.ReadExactly(data, 0, 2);
return BitConverter.ToUInt16(data, 0);
}

Expand Down
12 changes: 6 additions & 6 deletions AppWrapper/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ public DataItem Get(int offset) {
public static class FF8Files {
public static int ReadInt(this System.IO.Stream s) {
byte[] data = new byte[4];
s.Read(data, 0, 4);
s.ReadExactly(data, 0, 4);
return BitConverter.ToInt32(data, 0);
}
public static uint ReadUInt(this System.IO.Stream s) {
byte[] data = new byte[4];
s.Read(data, 0, 4);
s.ReadExactly(data, 0, 4);
return BitConverter.ToUInt32(data, 0);
}
public static ushort ReadUShort(this System.IO.Stream s) {
byte[] data = new byte[2];
s.Read(data, 0, 2);
s.ReadExactly(data, 0, 2);
return BitConverter.ToUInt16(data, 0);
}

Expand All @@ -91,14 +91,14 @@ public static DataFile LoadLGP(System.IO.Stream fs, string file) {
if (fs.ReadUShort() != 0)
throw new Exception(file + " - not a valid LGP archive");
byte[] header = new byte[10];
fs.Read(header, 0, 10);
fs.ReadExactly(header, 0, 10);
if (!Encoding.ASCII.GetString(header).Equals("SQUARESOFT"))
throw new Exception(file + " - not a valid LGP archive");
int count = fs.ReadInt();
byte[] fname = new byte[20];
List<Tuple<string, uint, ushort, int>> files = new List<Tuple<string, uint, ushort, int>>();
for (int i = 0; i < count; i++) {
fs.Read(fname, 0, 20);
fs.ReadExactly(fname, 0, 20);
uint offset = fs.ReadUInt();
fs.ReadByte();
ushort dupe = fs.ReadUShort();
Expand All @@ -113,7 +113,7 @@ public static DataFile LoadLGP(System.IO.Stream fs, string file) {
byte[] pname = new byte[128];
foreach (int i in Enumerable.Range(0, entries)) {
foreach (int j in Enumerable.Range(0, fs.ReadUShort())) {
fs.Read(pname, 0, 128);
fs.ReadExactly(pname, 0, 128);
ushort toc = fs.ReadUShort();
string ppname = Encoding.ASCII.GetString(pname);
ppname = ppname.Substring(0, ppname.IndexOf('\0'));
Expand Down
14 changes: 7 additions & 7 deletions AppWrapper/IrosArc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void Open(System.IO.Stream s, int version) {
ushort len = s.ReadUShort();
ushort flen = s.ReadUShort();
byte[] fn = new byte[flen];
s.Read(fn, 0, flen);
s.ReadExactly(fn, 0, flen);
Filename = System.Text.Encoding.Unicode.GetString(fn);
Flags = (FileFlags)s.ReadInt();
if (version < 0x10001)
Expand Down Expand Up @@ -338,7 +338,7 @@ public void ApplyPatch(IrosArc patch, Action<double, string> onProgress) {
var patchEntry = patch._lookup[file];
byte[] data = new byte[patchEntry.Length];
patch._data.Position = patchEntry.Offset;
patch._data.Read(data, 0, data.Length);
patch._data.ReadExactly(data);
if (HasFile(file)) { //update existing
DebugLogger.DetailedWriteLine($"File {file} is already in archive...");
DirectoryEntry exist = _lookup[file];
Expand Down Expand Up @@ -463,7 +463,7 @@ private CacheEntry GetCache(DirectoryEntry e) {
case FileFlags.CompressLZS:
data = new byte[e.Length];
_data.Position = e.Offset;
_data.Read(data, 0, e.Length);
_data.ReadExactly(data, 0, e.Length);
var ms = new System.IO.MemoryStream(data);
var output = new System.IO.MemoryStream();
Lzs.Decode(ms, output);
Expand All @@ -476,12 +476,12 @@ private CacheEntry GetCache(DirectoryEntry e) {
_data.Position = e.Offset;
int decSize = _data.ReadInt(), propSize = _data.ReadInt();
byte[] props = new byte[propSize];
_data.Read(props, 0, props.Length);
_data.ReadExactly(props);
byte[] cdata = new byte[e.Length - propSize - 8];
_data.Read(cdata, 0, cdata.Length);
_data.ReadExactly(cdata);
data = new byte[decSize];
var lzma = new SharpCompress.Compressors.LZMA.LzmaStream(props, new System.IO.MemoryStream(cdata));
lzma.Read(data, 0, data.Length);
lzma.ReadExactly(data);
/*int srcSize = cdata.Length;
switch (LzmaUncompress(data, ref decSize, cdata, ref srcSize, props, props.Length)) {
case SZ_OK:
Expand Down Expand Up @@ -518,7 +518,7 @@ public byte[] GetBytes(string name) {
lock (_data) {
byte[] data = new byte[e.Length];
_data.Position = e.Offset;
_data.Read(data, 0, e.Length);
_data.ReadExactly(data, 0, e.Length);
return data;
}
}
Expand Down
4 changes: 2 additions & 2 deletions AppWrapper/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public static T DeserializeString<T>(string data) {
}

public static void SerializeBinary(object o, System.IO.Stream s) {
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter fmt = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
var fmt = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
fmt.Serialize(s, o);
}

public static T DeserializeBinary<T>(System.IO.Stream s) {
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter fmt = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
var fmt = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
return (T)fmt.Deserialize(s);
}

Expand Down
2 changes: 1 addition & 1 deletion TurBoLog/TurBoLog.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<TargetFramework>net9.0-windows7.0</TargetFramework>
<ProjectType>Local</ProjectType>
<ApplicationIcon>debug.ico</ApplicationIcon>
<AssemblyKeyContainerName />
Expand Down

0 comments on commit ea21f72

Please sign in to comment.