Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions src/libs/Simli/Generated/Simli.AnyOf.2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
namespace Simli
{
/// <summary>
///
///
/// </summary>
public readonly partial struct AnyOf<T1, T2> : global::System.IEquatable<AnyOf<T1, T2>>
{
/// <summary>
///
///
/// </summary>
#if NET6_0_OR_GREATER
public T1? Value1 { get; init; }
Expand All @@ -18,15 +18,15 @@ namespace Simli
#endif

/// <summary>
///
///
/// </summary>
#if NET6_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value1))]
#endif
public bool IsValue1 => Value1 != null;

/// <summary>
///
///
/// </summary>
public bool TryPickValue1(
#if NET6_0_OR_GREATER
Expand All @@ -39,14 +39,14 @@ public bool TryPickValue1(
}

/// <summary>
///
///
/// </summary>
public T1 PickValue1() => IsValue1
? Value1!
: throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}.");

/// <summary>
///
///
/// </summary>
#if NET6_0_OR_GREATER
public T2? Value2 { get; init; }
Expand All @@ -55,15 +55,15 @@ public T1 PickValue1() => IsValue1
#endif

/// <summary>
///
///
/// </summary>
#if NET6_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value2))]
#endif
public bool IsValue2 => Value2 != null;

/// <summary>
///
///
/// </summary>
public bool TryPickValue2(
#if NET6_0_OR_GREATER
Expand All @@ -76,59 +76,59 @@ public bool TryPickValue2(
}

/// <summary>
///
///
/// </summary>
public T2 PickValue2() => IsValue2
? Value2!
: throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}.");
/// <summary>
///
///
/// </summary>
public static implicit operator AnyOf<T1, T2>(T1 value) => new AnyOf<T1, T2>((T1?)value);

/// <summary>
///
///
/// </summary>
public static implicit operator T1?(AnyOf<T1, T2> @this) => @this.Value1;

/// <summary>
///
///
/// </summary>
public AnyOf(T1? value)
{
Value1 = value;
}

/// <summary>
///
///
/// </summary>
public static AnyOf<T1, T2> FromValue1(T1? value) => new AnyOf<T1, T2>(value);

/// <summary>
///
///
/// </summary>
public static implicit operator AnyOf<T1, T2>(T2 value) => new AnyOf<T1, T2>((T2?)value);

/// <summary>
///
///
/// </summary>
public static implicit operator T2?(AnyOf<T1, T2> @this) => @this.Value2;

/// <summary>
///
///
/// </summary>
public AnyOf(T2? value)
{
Value2 = value;
}

/// <summary>
///
///
/// </summary>
public static AnyOf<T1, T2> FromValue2(T2? value) => new AnyOf<T1, T2>(value);

/// <summary>
///
///
/// </summary>
public AnyOf(
T1? value1,
Expand All @@ -140,31 +140,31 @@ public AnyOf(
}

/// <summary>
///
///
/// </summary>
public object? Object =>
Value2 as object ??
Value1 as object
Value1 as object
;

/// <summary>
///
///
/// </summary>
public override string? ToString() =>
Value1?.ToString() ??
Value2?.ToString()
Value2?.ToString()
;

/// <summary>
///
///
/// </summary>
public bool Validate()
{
return IsValue1 || IsValue2;
}

/// <summary>
///
///
/// </summary>
public TResult? Match<TResult>(
global::System.Func<T1, TResult>? value1 = null,
Expand All @@ -189,7 +189,7 @@ public bool Validate()
}

/// <summary>
///
///
/// </summary>
public void Match(
global::System.Action<T1>? value1 = null,
Expand All @@ -213,7 +213,7 @@ public void Match(
}

/// <summary>
///
///
/// </summary>
public void Switch(
global::System.Action<T1>? value1 = null,
Expand All @@ -236,7 +236,7 @@ public void Switch(
}

/// <summary>
///
///
/// </summary>
public override int GetHashCode()
{
Expand All @@ -257,34 +257,34 @@ static int HashCodeAggregator(int hashCode, object? value) => value == null
}

/// <summary>
///
///
/// </summary>
public bool Equals(AnyOf<T1, T2> other)
{
return
global::System.Collections.Generic.EqualityComparer<T1?>.Default.Equals(Value1, other.Value1) &&
global::System.Collections.Generic.EqualityComparer<T2?>.Default.Equals(Value2, other.Value2)
global::System.Collections.Generic.EqualityComparer<T2?>.Default.Equals(Value2, other.Value2)
;
}

/// <summary>
///
///
/// </summary>
public static bool operator ==(AnyOf<T1, T2> obj1, AnyOf<T1, T2> obj2)
{
return global::System.Collections.Generic.EqualityComparer<AnyOf<T1, T2>>.Default.Equals(obj1, obj2);
}

/// <summary>
///
///
/// </summary>
public static bool operator !=(AnyOf<T1, T2> obj1, AnyOf<T1, T2> obj2)
{
return !(obj1 == obj2);
}

/// <summary>
///
///
/// </summary>
public override bool Equals(object? obj)
{
Expand Down
Loading