From bb706bbfa7519c8b5c506e76a787b9b016acfb75 Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 14 Sep 2024 15:54:30 -0400 Subject: Squashed commit of the following: commit 322bbe00f77772ba6b0e25759de95dd517b6014c Author: vnugent Date: Sat Sep 14 15:43:45 2024 -0400 build: Testing updates and easier dev-testing commit abcd0e0d6cb5532c8a19a8cd8c7dd83e7f143442 Author: vnugent Date: Wed Sep 11 16:43:20 2024 -0400 Managed library & package updates commit 2ae018af277b808786cf398c689910bc016e7ef0 Author: vnugent Date: Tue Sep 10 18:59:06 2024 -0400 fix: zero/unsafezero with data types > sizeof(byte) commit 17c646a619eaa101d66871faa8f57c76500a8ad2 Merge: 97d0c46 a19807f Author: vnugent Date: Sat Sep 7 15:31:01 2024 -0400 Merge branch 'master' into develop --- lib/Utils/src/ERRNO.cs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'lib/Utils/src/ERRNO.cs') diff --git a/lib/Utils/src/ERRNO.cs b/lib/Utils/src/ERRNO.cs index 684a3c7..0a95780 100644 --- a/lib/Utils/src/ERRNO.cs +++ b/lib/Utils/src/ERRNO.cs @@ -30,8 +30,12 @@ namespace VNLib.Utils /// /// Implements a C style integer error code type. Size is platform dependent /// + /// + /// Creates a new from the specified error value + /// + /// The value of the error to represent [StructLayout(LayoutKind.Sequential)] - public readonly struct ERRNO : IEquatable, ISpanFormattable, IFormattable + public readonly struct ERRNO(nint errno) : IEquatable, ISpanFormattable, IFormattable { /// /// Represents a successfull error code (true) @@ -43,13 +47,7 @@ namespace VNLib.Utils /// public static readonly ERRNO E_FAIL = false; - private readonly nint ErrorCode; - - /// - /// Creates a new from the specified error value - /// - /// The value of the error to represent - public ERRNO(nint errno) => ErrorCode = errno; + private readonly nint ErrorCode = errno; /// /// Creates a new from an error code. null = 0 = false @@ -130,13 +128,14 @@ namespace VNLib.Utils } return false; } +#pragma warning disable CA1305 // Specify IFormatProvider /// /// The integer error value of the current instance in radix 10 /// /// The radix 10 formatted error code - public readonly override string ToString() => ErrorCode.ToString(); + public override readonly string ToString() => ErrorCode.ToString(); /// /// Formats the internal nint error code as a string in specified format /// @@ -144,11 +143,15 @@ namespace VNLib.Utils /// The formatted error code public readonly string ToString(string format) => ErrorCode.ToString(format); +#pragma warning restore CA1305 // Specify IFormatProvider + /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) => ErrorCode.TryFormat(destination, out charsWritten, format, provider); + public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + => ErrorCode.TryFormat(destination, out charsWritten, format, provider); /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) => ErrorCode.ToString(format, formatProvider); + public readonly string ToString(string? format, IFormatProvider? formatProvider) + => ErrorCode.ToString(format, formatProvider); public static ERRNO operator +(ERRNO err, int add) => new(err.ErrorCode + add); public static ERRNO operator +(ERRNO err, nint add) => new(err.ErrorCode + add); -- cgit