Renamed library project, cleaned up code

This commit is contained in:
Samuele Lorefice
2025-01-22 01:57:46 +01:00
parent 2a051cf098
commit d1742775ad
4 changed files with 107 additions and 49 deletions

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,34 @@
using System.Numerics;
namespace BlendFile.CompatTypes;
public readonly struct uchar {
public uchar Value => _value;
private readonly byte _value;
public uchar(byte value) => _value = value;
public uchar(uchar value) => _value = value._value;
public static explicit operator byte(uchar value) => value._value;
public static implicit operator uchar(byte value) => new(value);
public static explicit operator sbyte(uchar value) => (sbyte)value._value;
public static implicit operator uchar(sbyte value) => new((byte)value);
public static explicit operator int(uchar value) => value._value;
public static implicit operator uchar(int value) => new((byte)value);
public static uchar operator +(uchar left, uchar right) => left.Value + right.Value;
public static uchar operator -(uchar left, uchar right) => left.Value - right.Value;
public static uchar operator *(uchar left, uchar right) => left.Value * right.Value;
public static uchar operator /(uchar left, uchar right) => left.Value / right.Value;
public static uchar operator %(uchar left, uchar right) => left.Value % right.Value;
public static uchar operator &(uchar left, uchar right) => left.Value & right.Value;
public static uchar operator |(uchar left, uchar right) => left.Value | right.Value;
public static uchar operator ^(uchar left, uchar right) => left.Value ^ right.Value;
public static uchar operator <<(uchar left, byte right) => left.Value << right;
public static uchar operator >>(uchar left, byte right) => left.Value >> right;
public static uchar operator ++(uchar value) => new (value.Value + 1);
public static uchar operator --(uchar value) => new (value.Value - 1);
}