mirror of
https://github.com/AssetRipper/AssetRipper.Primitives.git
synced 2026-11-13 04:26:30 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3ff29e8d7 | ||
|
|
61f47faf04 | ||
|
|
57912c52f1 | ||
|
|
5ab5d744d6 | ||
|
|
cd7f841845 | ||
|
|
9a5f8bb707 | ||
|
|
089c71d944 | ||
|
|
919fa0d5ab | ||
|
|
df8c5e2879 | ||
|
|
13ece60907 | ||
|
|
3a46414f08 | ||
|
|
bc556b7c72 | ||
|
|
7147a5d5b1 | ||
|
|
776ab543fa |
No files matched your search
@@ -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
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4.1.0
|
||||
uses: actions/setup-dotnet@v4.3.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>
|
||||
|
||||
|
||||
@@ -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.1.6</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>
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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 = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user