Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Hi3Helper.Plugin.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
Expand All @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.11" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)'=='DebugNoReflection'">
Expand Down
31 changes: 20 additions & 11 deletions Management/GameVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,10 @@ public readonly GameVersion GetIncrementedVersion()
/// <returns>A string representation of <see cref="GameVersion"/>.</returns>
public readonly string ToString(string? format, IFormatProvider? formatProvider = null)
{
Span<char> 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<char> 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) =>
Expand All @@ -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 &&
Expand Down Expand Up @@ -254,7 +259,7 @@ public readonly bool TryFormat(Span<char> 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)
Expand Down Expand Up @@ -342,12 +347,16 @@ public readonly bool TryFormat(Span<char> destination, out int charsWritten, Rea
/// </remarks>
public readonly bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> 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)
Expand Down
4 changes: 2 additions & 2 deletions PluginTest/PluginTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
Expand All @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.9" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions PluginTest/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
26 changes: 16 additions & 10 deletions packages.lock.json
Original file line number Diff line number Diff line change
@@ -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=="
}
}
}
Expand Down