Compare commits

...
18 Commits
Author SHA1 Message Date
dependabot[bot] 7091ff7f36 Bump actions/checkout from 4 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-01-14 12:08:29 -08:00
dependabot[bot] 3377fa0bea Bump actions/setup-dotnet from 4.3.0 to 5.1.0
Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 4.3.0 to 5.1.0.
- [Release notes](https://github.com/actions/setup-dotnet/releases)
- [Commits](https://github.com/actions/setup-dotnet/compare/v4.3.0...v5.1.0)

---
updated-dependencies:
- dependency-name: actions/setup-dotnet
  dependency-version: 5.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2026-01-14 12:07:30 -08:00
ds5678 d759b3db98 Bump version to 3.2.0 in AssetRipper.Primitives.csproj
Updated the package version from 3.1.6 to 3.2.0 to reflect the latest changes and improvements.
2025-04-28 20:42:46 -07:00
ds5678 55b3294ff5 Explicit conversion for Utf8String from ReadOnlySpan 2025-04-28 20:42:03 -07:00
ds5678 c3ff29e8d7 Bump version to 3.1.6 in project file
Updated the version number from 3.1.5 to 3.1.6 in the AssetRipper.Primitives.csproj file.
2025-02-22 21:43:28 -08:00
ds5678 61f47faf04 Utf8StringJsonConverter 2025-02-22 21:42:49 -08:00
ds5678 57912c52f1 Update version to 3.1.5 and adjust project properties
- Bump version number from 3.1.4 to 3.1.5.
- Update copyright year to 2025.
- Add property group for trimmability with net6.0.
- Modify AOT compatibility check for net8.0.
2025-02-13 16:03:05 -08:00
ds5678 5ab5d744d6 UnityVersion : IParsable<UnityVersion> 2025-02-13 15:57:20 -08:00
ds5678 cd7f841845 Json serialization support for UnityVersion 2025-02-13 15:56:24 -08:00
ds5678 9a5f8bb707 .NET 9 support 2025-02-13 15:47:09 -08:00
dependabot[bot] 089c71d944 Bump actions/setup-dotnet from 4.1.0 to 4.3.0
Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 4.1.0 to 4.3.0.
- [Release notes](https://github.com/actions/setup-dotnet/releases)
- [Commits](https://github.com/actions/setup-dotnet/compare/v4.1.0...v4.3.0)

---
updated-dependencies:
- dependency-name: actions/setup-dotnet
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2025-02-13 18:44:41 -05:00
ds5678 919fa0d5ab Don't bother testing .NET 5 2025-02-13 15:40:27 -08:00
ds5678 df8c5e2879 All frameworks 2025-02-13 15:34:49 -08:00
ds5678 13ece60907 Remove dotnet restore 2025-02-13 15:26:28 -08:00
ds5678 3a46414f08 .net 8 only 2025-02-13 15:24:08 -08:00
ds5678 bc556b7c72 .net 8 2025-02-13 15:23:01 -08:00
ds5678 7147a5d5b1 Strings instead of floats 2025-02-13 15:21:08 -08:00
ds5678 776ab543fa Use a build matrix 2025-02-13 15:18:48 -08:00
10 changed files with 102 additions and 80 deletions

No files matched your search

+13 -58
View File
@@ -7,70 +7,25 @@ on:
branches: [ master ]
jobs:
net8:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ["9.0", "8.0", "7.0", "6.0"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v4.1.0
uses: actions/setup-dotnet@v5.1.0
with:
dotnet-version: 8.0.x
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --framework net8.0 --no-restore
run: dotnet build --framework net${{ matrix.dotnet-version }} --no-restore
- name: Test
run: dotnet test --framework net8.0 --no-build --verbosity normal
net7:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --framework net7.0 --no-restore
- name: Test
run: dotnet test --framework net7.0 --no-build --verbosity normal
net6:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --framework net6.0 --no-restore
- name: Test
run: dotnet test --framework net6.0 --no-build --verbosity normal
net5:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --framework net5.0 --no-restore
- name: Test
run: dotnet test --framework net5.0 --no-build --verbosity normal
run: dotnet test --framework net${{ matrix.dotnet-version }} --no-build --verbosity normal
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net35;net40;net48;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net35;net40;net48;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<LangVersion>Latest</LangVersion>
<Nullable>enable</Nullable>
@@ -33,7 +33,7 @@ public class Utf8StringTests
[Test]
public void Utf8StringMadeFromUtf8LiteralIsTheSameAsMadeFromConstantString()
{
Utf8String dataString = "AssetRipperTestString"u8;
Utf8String dataString = (Utf8String)"AssetRipperTestString"u8;
Utf8String systemString = "AssetRipperTestString";
Assert.That(dataString, Is.EqualTo(systemString));
}
@@ -41,7 +41,7 @@ public class Utf8StringTests
[Test]
public void ConcatenationBetweenTwoUtf8StringsWorks()
{
Utf8String dataString = "AssetRipperTestString"u8;
Utf8String dataString = (Utf8String)"AssetRipperTestString"u8;
Utf8String systemString = "AssetRipperTestString";
Utf8String concatenated = dataString + systemString;
Assert.That(concatenated, Is.EqualTo((Utf8String)"AssetRipperTestStringAssetRipperTestString"u8));
@@ -58,10 +58,10 @@ public class Utf8StringTests
[Test]
public void ConcatenationBetweenFourUtf8StringsWorks()
{
Utf8String string1 = "hello"u8;
Utf8String string2 = " world"u8;
Utf8String string3 = "!"u8;
Utf8String string4 = ", how are you?"u8;
Utf8String string1 = (Utf8String)"hello"u8;
Utf8String string2 = (Utf8String)" world"u8;
Utf8String string3 = (Utf8String)"!"u8;
Utf8String string4 = (Utf8String)", how are you?"u8;
Utf8String concatenated = Utf8String.Concat(string1, string2, string3, string4);
Assert.That(concatenated, Is.EqualTo((Utf8String)"hello world!, how are you?"u8));
}
@@ -81,7 +81,7 @@ public class Utf8StringTests
[Test]
public void IsNullOrEmptyReturnsFalseForNonEmptyString()
{
Assert.That(Utf8String.IsNullOrEmpty("AssetRipperTestString"u8), Is.False);
Assert.That(Utf8String.IsNullOrEmpty((Utf8String)"AssetRipperTestString"u8), Is.False);
}
}
#endif
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net35;net40;net461;netstandard2.0;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net35;net40;net461;netstandard2.0;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<LangVersion>Latest</LangVersion>
<Nullable>enable</Nullable>
<Authors>ds5678</Authors>
<Company>AssetRipper</Company>
<Version>3.1.4</Version>
<Version>3.2.0</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<PackageId>AssetRipper.Primitives</PackageId>
<PackageTags>C# assetripper unity unity3d</PackageTags>
@@ -14,18 +14,18 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/AssetRipper/AssetRipper.Primitives</PackageProjectUrl>
<Copyright>Copyright (c) 2022-2024 ds5678</Copyright>
<Copyright>Copyright (c) 2022-2025 ds5678</Copyright>
<Description>Managed library for primitive types used in AssetRipper.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' != 'net35' and '$(TargetFramework)' != 'net40' ">
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>
+15 -1
View File
@@ -2,10 +2,24 @@
using System.Numerics;
namespace AssetRipper.Primitives;
partial struct UnityVersion : IComparisonOperators<UnityVersion, UnityVersion, bool>, IEqualityOperators<UnityVersion, UnityVersion, bool>, IMinMaxValue<UnityVersion>
partial struct UnityVersion :
IComparisonOperators<UnityVersion, UnityVersion, bool>,
IEqualityOperators<UnityVersion, UnityVersion, bool>,
IMinMaxValue<UnityVersion>,
IParsable<UnityVersion>
{
static UnityVersion IMinMaxValue<UnityVersion>.MaxValue => MaxVersion;
static UnityVersion IMinMaxValue<UnityVersion>.MinValue => MinVersion;
static UnityVersion IParsable<UnityVersion>.Parse(string s, IFormatProvider? provider)
{
return Parse(s);
}
static bool IParsable<UnityVersion>.TryParse(string? s, IFormatProvider? provider, out UnityVersion result)
{
return TryParse(s, out result, out _);
}
}
#endif
@@ -0,0 +1,10 @@
#if NET5_0_OR_GREATER
using System.Text.Json.Serialization;
namespace AssetRipper.Primitives;
[JsonConverter(typeof(UnityVersionJsonConverter))]
partial struct UnityVersion
{
}
#endif
@@ -84,9 +84,9 @@ public readonly partial struct UnityVersion
/// <param name="version">The parsed Unity version</param>
/// <param name="customEngine">Not null if this version was generated by a custom Unity Engine.</param>
/// <returns>True if parsing was successful</returns>
public static bool TryParse(string s, out UnityVersion version, out string? customEngine)
public static bool TryParse(string? s, out UnityVersion version, out string? customEngine)
{
if (string.IsNullOrEmpty(s))
if (s is null || s.Length is 0)
{
customEngine = null;
version = default;
@@ -0,0 +1,19 @@
#if NET5_0_OR_GREATER
using System.Text.Json;
using System.Text.Json.Serialization;
namespace AssetRipper.Primitives;
public sealed class UnityVersionJsonConverter : JsonConverter<UnityVersion>
{
public override UnityVersion Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return UnityVersion.Parse(reader.GetString() ?? throw new JsonException("String was read as null"));
}
public override void Write(Utf8JsonWriter writer, UnityVersion value, JsonSerializerOptions options)
{
writer.WriteStringValue(value.ToString());
}
}
#endif
+9 -4
View File
@@ -11,12 +11,15 @@ namespace AssetRipper.Primitives;
/// <remarks>
/// Conversions to and from <see cref="string"/> are handled by <see cref="Encoding.UTF8"/>.
/// </remarks>
#if NET5_0_OR_GREATER
[System.Text.Json.Serialization.JsonConverter(typeof(Utf8StringJsonConverter))]
#endif
public sealed class Utf8String :
#if NET7_0_OR_GREATER
System.Numerics.IEqualityOperators<Utf8String?, Utf8String?, bool>,
System.Numerics.IEqualityOperators<Utf8String?, string?, bool>,
System.Numerics.IEqualityOperators<Utf8String?, string?, bool>,
#endif
IEquatable<Utf8String>
IEquatable<Utf8String>
{
private readonly byte[] data;
private string? cachedString;
@@ -28,7 +31,7 @@ public sealed class Utf8String :
/// </summary>
public Utf8String()
{
data = Array.Empty<byte>();
data = [];
cachedString = "";
}
@@ -108,8 +111,10 @@ public sealed class Utf8String :
return utf8String?.String;
}
public static implicit operator Utf8String(ReadOnlySpan<byte> data)
public static explicit operator Utf8String(ReadOnlySpan<byte> data)
{
// Explicit conversion because of first class spans
// https://github.com/dotnet/roslyn/issues/78314
return data.Length == 0 ? Empty : new Utf8String(data);
}
@@ -0,0 +1,19 @@
#if NET5_0_OR_GREATER
using System.Text.Json;
using System.Text.Json.Serialization;
namespace AssetRipper.Primitives;
public sealed class Utf8StringJsonConverter : JsonConverter<Utf8String>
{
public override Utf8String Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetString() ?? throw new JsonException("String was read as null");
}
public override void Write(Utf8JsonWriter writer, Utf8String value, JsonSerializerOptions options)
{
writer.WriteStringValue(value.ToString());
}
}
#endif