File: Windows.Win32.char.InlineArrays.g.cs
Project: src\src\System.Private.Windows.Core\src\Microsoft.Private.Windows.Core.csproj (Microsoft.Private.Windows.Core)
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------

#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981
using global::System;
using global::System.Diagnostics;
using global::System.Diagnostics.CodeAnalysis;
using global::System.Runtime.CompilerServices;
using global::System.Runtime.InteropServices;
using global::System.Runtime.Versioning;
using winmdroot = global::Windows.Win32;
namespace Windows.Win32
{
	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	internal partial struct __char_32
	{
		private const int SpanLength = 32;

		/// <summary>The length of the inline array.</summary>
		internal readonly int Length => SpanLength;

		internal unsafe fixed char Value[SpanLength];

		/// <summary>
		/// Gets a ref to an individual element of the inline array.
		/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it.
		/// </summary>
		[UnscopedRef]
		internal unsafe ref char this[int index] => ref Value[index];

		internal readonly unsafe void CopyTo(Span<char> target, int length = SpanLength)
		{
			fixed (char* p0 = Value)
				new ReadOnlySpan<char>(p0, SpanLength).Slice(0, length).CopyTo(target);
		}

		internal readonly unsafe char[] ToArray(int length = SpanLength)
		{
			fixed (char* p0 = Value)
				return new ReadOnlySpan<char>(p0, SpanLength).Slice(0, length).ToArray();
		}

		internal readonly unsafe bool Equals(ReadOnlySpan<char> value)
		{
			fixed (char* p0 = Value)
			{
				ReadOnlySpan<char> span = new ReadOnlySpan<char>(p0, SpanLength);
				return value.Length == SpanLength ? span.SequenceEqual(value) : span.SliceAtNull().SequenceEqual(value);
			}
		}

		internal readonly bool Equals(string value) => Equals(value.AsSpan());

		/// <summary>
		/// Copies the fixed array to a new string up to the specified length regardless of whether there are null terminating characters.
		/// </summary>
		/// <exception cref="ArgumentOutOfRangeException">
		/// Thrown when <paramref name="length"/> is less than <c>0</c> or greater than <see cref="Length"/>.
		/// </exception>
		internal readonly unsafe string ToString(int length)
		{
			fixed (char* p0 = Value)
				return new ReadOnlySpan<char>(p0, SpanLength).Slice(0, length).ToString();
		}

		/// <summary>
		/// Copies the fixed array to a new string, stopping before the first null terminator character or at the end of the fixed array (whichever is shorter).
		/// </summary>
		public override readonly unsafe string ToString()
		{
			fixed (char* p0 = Value)
				return new ReadOnlySpan<char>(p0, SpanLength).SliceAtNull().ToString();
		}

		public static implicit operator __char_32(string value) => value.AsSpan();

		public static unsafe implicit operator __char_32(ReadOnlySpan<char> value)
		{
			Unsafe.SkipInit(out __char_32 result);
			Span<char> target = new Span<char>(result.Value, SpanLength);
			value.CopyTo(target);
			int initLength = value.Length;
			target.Slice(initLength, SpanLength - initLength).Clear();
			return result;
		}
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	internal partial struct __char_260
	{
		private const int SpanLength = 260;

		/// <summary>The length of the inline array.</summary>
		internal readonly int Length => SpanLength;

		internal unsafe fixed char Value[SpanLength];

		/// <summary>
		/// Gets a ref to an individual element of the inline array.
		/// ⚠ Important ⚠: When this struct is on the stack, do not let the returned reference outlive the stack frame that defines it.
		/// </summary>
		[UnscopedRef]
		internal unsafe ref char this[int index] => ref Value[index];

		internal readonly unsafe void CopyTo(Span<char> target, int length = SpanLength)
		{
			fixed (char* p0 = Value)
				new ReadOnlySpan<char>(p0, SpanLength).Slice(0, length).CopyTo(target);
		}

		internal readonly unsafe char[] ToArray(int length = SpanLength)
		{
			fixed (char* p0 = Value)
				return new ReadOnlySpan<char>(p0, SpanLength).Slice(0, length).ToArray();
		}

		internal readonly unsafe bool Equals(ReadOnlySpan<char> value)
		{
			fixed (char* p0 = Value)
			{
				ReadOnlySpan<char> span = new ReadOnlySpan<char>(p0, SpanLength);
				return value.Length == SpanLength ? span.SequenceEqual(value) : span.SliceAtNull().SequenceEqual(value);
			}
		}

		internal readonly bool Equals(string value) => Equals(value.AsSpan());

		/// <summary>
		/// Copies the fixed array to a new string up to the specified length regardless of whether there are null terminating characters.
		/// </summary>
		/// <exception cref="ArgumentOutOfRangeException">
		/// Thrown when <paramref name="length"/> is less than <c>0</c> or greater than <see cref="Length"/>.
		/// </exception>
		internal readonly unsafe string ToString(int length)
		{
			fixed (char* p0 = Value)
				return new ReadOnlySpan<char>(p0, SpanLength).Slice(0, length).ToString();
		}

		/// <summary>
		/// Copies the fixed array to a new string, stopping before the first null terminator character or at the end of the fixed array (whichever is shorter).
		/// </summary>
		public override readonly unsafe string ToString()
		{
			fixed (char* p0 = Value)
				return new ReadOnlySpan<char>(p0, SpanLength).SliceAtNull().ToString();
		}

		public static implicit operator __char_260(string value) => value.AsSpan();

		public static unsafe implicit operator __char_260(ReadOnlySpan<char> value)
		{
			Unsafe.SkipInit(out __char_260 result);
			Span<char> target = new Span<char>(result.Value, SpanLength);
			value.CopyTo(target);
			int initLength = value.Length;
			target.Slice(initLength, SpanLength - initLength).Clear();
			return result;
		}
	}
}