diff --git a/Hi3Helper.Plugin.Core.csproj b/Hi3Helper.Plugin.Core.csproj index 2bd9d12..d7719bb 100644 --- a/Hi3Helper.Plugin.Core.csproj +++ b/Hi3Helper.Plugin.Core.csproj @@ -1,7 +1,7 @@ - + - net9.0 + net10.0 disable true enable @@ -22,7 +22,7 @@ - + diff --git a/Management/GameVersion.cs b/Management/GameVersion.cs index de1f935..bfa00c6 100644 --- a/Management/GameVersion.cs +++ b/Management/GameVersion.cs @@ -117,13 +117,10 @@ public readonly GameVersion GetIncrementedVersion() /// A string representation of . public readonly string ToString(string? format, IFormatProvider? formatProvider = null) { - Span writeStackalloc = stackalloc char[64]; - if (!TryFormat(writeStackalloc, out int written, format, formatProvider)) - { - throw new InvalidOperationException("Cannot write string to stackalloc buffer!"); - } - - return new string(writeStackalloc[..written]); + scoped Span writeStackalloc = stackalloc char[48]; + return !TryFormat(writeStackalloc, out int written, format, formatProvider) + ? throw new InvalidOperationException("Cannot write string to stackalloc buffer!") + : new string(writeStackalloc[..written]); } public static bool operator <(GameVersion? left, GameVersion? right) => @@ -136,6 +133,14 @@ public readonly string ToString(string? format, IFormatProvider? formatProvider public static bool operator >(GameVersion? left, GameVersion? right) => right < left; +#if NET10_0_OR_GREATER + public static bool operator <=(GameVersion? left, GameVersion? right) => + left < right || left == right; + + public static bool operator >=(GameVersion? left, GameVersion? right) => + right < left || right == left; +#endif + public static bool operator ==(GameVersion? left, GameVersion? right) => left.HasValue && right.HasValue && left.Value.Major == right.Value.Major && @@ -254,7 +259,7 @@ public readonly bool TryFormat(Span destination, out int charsWritten, Rea bool isUseAutoFormat = !format.IsEmpty && (format[0] | 0x20) == 's'; // This compares both 's' or 'S' as true. bool isForceUseFullFormat = !format.IsEmpty && (format[0] | 0x20) == 'f'; // This compares both 'f' or 'F' as false. bool isUseMiniFormat = !isForceUseFullFormat && - (!format.IsEmpty && (format[0] | 0x20) == 'n' // This compares both 'n' or 'N' as true. + ((!format.IsEmpty && (format[0] | 0x20) == 'n') // This compares both 'n' or 'N' as true. || Revision == 0); if (destination.Length < 4) @@ -342,12 +347,16 @@ public readonly bool TryFormat(Span destination, out int charsWritten, Rea /// public readonly bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) { + const byte formatByteS = (byte)'s'; + const byte formatByteF = (byte)'f'; + const byte formatByteN = (byte)'n'; + bytesWritten = 0; - bool isUseAutoFormat = !format.IsEmpty && (format[0] | 0x20) == 's'; // This compares both 's' or 'S' as true. - bool isForceUseFullFormat = !format.IsEmpty && (format[0] | 0x20) == 'f'; // This compares both 'f' or 'F' as false. + bool isUseAutoFormat = !format.IsEmpty && (format[0] | 0x20) == formatByteS; // This compares both 's' or 'S' as true. + bool isForceUseFullFormat = !format.IsEmpty && (format[0] | 0x20) == formatByteF; // This compares both 'f' or 'F' as false. bool isUseMiniFormat = !isForceUseFullFormat && - (!format.IsEmpty && (format[0] | 0x20) == 'n' // This compares both 'n' or 'N' as true. + ((!format.IsEmpty && (format[0] | 0x20) == formatByteN) // This compares both 'n' or 'N' as true. || Revision == 0); if (utf8Destination.Length < 4) diff --git a/PluginTest/PluginTest.csproj b/PluginTest/PluginTest.csproj index 68138da..fc62829 100644 --- a/PluginTest/PluginTest.csproj +++ b/PluginTest/PluginTest.csproj @@ -2,7 +2,7 @@ Exe - net9.0 + net10.0 disable enable true @@ -13,7 +13,7 @@ - + diff --git a/PluginTest/Properties/launchSettings.json b/PluginTest/Properties/launchSettings.json index 548bb82..b07631c 100644 --- a/PluginTest/Properties/launchSettings.json +++ b/PluginTest/Properties/launchSettings.json @@ -9,6 +9,11 @@ "commandName": "Project", "commandLineArgs": "NoWait \"H:\\myGit\\Hi3Helper.Plugin.HBR\\Hi3Helper.Plugin.HBR\\publish\\Debug\\main.dll\"", "nativeDebugging": true + }, + "PluginTest - DNA": { + "commandName": "Project", + "commandLineArgs": "NoWait \"D:\\GitHub\\Hi3Helper.Plugin.DNA\\Hi3Helper.Plugin.DNA\\publish\\Debug\\DNAbyss.dll\"", + "nativeDebugging": true } } } \ No newline at end of file diff --git a/packages.lock.json b/packages.lock.json index eca0f12..e3f310f 100644 --- a/packages.lock.json +++ b/packages.lock.json @@ -1,26 +1,32 @@ { "version": 1, "dependencies": { - "net9.0": { + "net10.0": { + "Microsoft.DotNet.ILCompiler": { + "type": "Direct", + "requested": "[10.0.0, )", + "resolved": "10.0.0", + "contentHash": "f9u8fMRROe2lS5MOOLutK6iSNTK9pC3kqd90FIn8Sk29fbZ0QDjZrBbwUkhouk/8dppC71SIEQaag0lGRTxvfA==" + }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Direct", - "requested": "[9.0.11, )", - "resolved": "9.0.11", - "contentHash": "UKWFTDwtZQIoypyt1YPVsxTnDK+0sKn26+UeSGeNlkRQddrkt9EC6kP4g94rgO/WOZkz94bKNlF1dVZN3QfPFQ==", + "requested": "[10.0.0, )", + "resolved": "10.0.0", + "contentHash": "FU/IfjDfwaMuKr414SSQNTIti/69bHEMb+QKrskRb26oVqpx3lNFXMjs/RC9ZUuhBhcwDM2BwOgoMw+PZ+beqQ==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.11" + "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.0" } }, "Microsoft.NET.ILLink.Tasks": { "type": "Direct", - "requested": "[9.0.10, )", - "resolved": "9.0.10", - "contentHash": "sseaSJcBxKEpkc59hnB00b3NmJdGvJLfj74HK+nucHxERxbZSUREuWKjC9ywc+HdzJvJyiP2eiyEOROaGSfcPw==" + "requested": "[10.0.0, )", + "resolved": "10.0.0", + "contentHash": "kICGrGYEzCNI3wPzfEXcwNHgTvlvVn9yJDhSdRK+oZQy4jvYH529u7O0xf5ocQKzOMjfS07+3z9PKRIjrFMJDA==" }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "9.0.11", - "contentHash": "+ZxxZzcVU+IEzq12GItUzf/V3mEc5nSLiXijwvDc4zyhbjvSZZ043giSZqGnhakrjwRWjkerIHPrRwm9okEIpw==" + "resolved": "10.0.0", + "contentHash": "L3AdmZ1WOK4XXT5YFPEwyt0ep6l8lGIPs7F5OOBZc77Zqeo01Of7XXICy47628sdVl0v/owxYJTe86DTgFwKCA==" } } }