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
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public class MaybeExpandedCommentJsonConverter : global::System.Text.Json.Serial
if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; }
if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; }

global::LabelStudio.Comment? value1 = default;
global::LabelStudio.CommentSerializerWithExpandedUser? value2 = default;
global::LabelStudio.Comment? comment = default;
global::LabelStudio.CommentSerializerWithExpandedUser? serializerWithUser = default;
if (__bestIndex >= 0)
{
if (__bestIndex == 0)
Expand All @@ -71,7 +71,7 @@ public class MaybeExpandedCommentJsonConverter : global::System.Text.Json.Serial
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::LabelStudio.Comment), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::LabelStudio.Comment> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::LabelStudio.Comment).Name}");
value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
comment = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
Expand All @@ -86,7 +86,7 @@ public class MaybeExpandedCommentJsonConverter : global::System.Text.Json.Serial
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::LabelStudio.CommentSerializerWithExpandedUser), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::LabelStudio.CommentSerializerWithExpandedUser> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::LabelStudio.CommentSerializerWithExpandedUser).Name}");
value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
serializerWithUser = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
Expand All @@ -97,13 +97,13 @@ public class MaybeExpandedCommentJsonConverter : global::System.Text.Json.Serial
}
}

if (value1 == null && value2 == null)
if (comment == null && serializerWithUser == null)
{
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::LabelStudio.Comment), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::LabelStudio.Comment> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::LabelStudio.Comment).Name}");
value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
comment = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
Expand All @@ -116,7 +116,7 @@ public class MaybeExpandedCommentJsonConverter : global::System.Text.Json.Serial
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::LabelStudio.CommentSerializerWithExpandedUser), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::LabelStudio.CommentSerializerWithExpandedUser> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::LabelStudio.CommentSerializerWithExpandedUser).Name}");
value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
serializerWithUser = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo);
}
catch (global::System.Text.Json.JsonException)
{
Expand All @@ -127,9 +127,9 @@ public class MaybeExpandedCommentJsonConverter : global::System.Text.Json.Serial
}

var __value = new global::LabelStudio.MaybeExpandedComment(
value1,
comment,

value2
serializerWithUser
);

return __value;
Expand All @@ -144,17 +144,17 @@ public override void Write(
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set.");

if (value.IsValue1)
if (value.IsComment)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::LabelStudio.Comment), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::LabelStudio.Comment?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::LabelStudio.Comment).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value1!, typeInfo);
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Comment!, typeInfo);
}
else if (value.IsValue2)
else if (value.IsSerializerWithUser)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::LabelStudio.CommentSerializerWithExpandedUser), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::LabelStudio.CommentSerializerWithExpandedUser?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::LabelStudio.CommentSerializerWithExpandedUser).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value2!, typeInfo);
global::System.Text.Json.JsonSerializer.Serialize(writer, value.SerializerWithUser!, typeInfo);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ namespace LabelStudio
/// - fflag_feat_fit_710_fsm_state_fields (state field display in APIs)
/// </summary>
#if NET6_0_OR_GREATER
public global::LabelStudio.Comment? Value1 { get; init; }
public global::LabelStudio.Comment? Comment { get; init; }
#else
public global::LabelStudio.Comment? Value1 { get; }
public global::LabelStudio.Comment? Comment { get; }
#endif

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

/// <summary>
/// Comment Serializer with FSM state support.<br/>
Expand All @@ -40,18 +40,18 @@ namespace LabelStudio
/// - fflag_feat_fit_710_fsm_state_fields (state field display in APIs)
/// </summary>
#if NET6_0_OR_GREATER
public global::LabelStudio.CommentSerializerWithExpandedUser? Value2 { get; init; }
public global::LabelStudio.CommentSerializerWithExpandedUser? SerializerWithUser { get; init; }
#else
public global::LabelStudio.CommentSerializerWithExpandedUser? Value2 { get; }
public global::LabelStudio.CommentSerializerWithExpandedUser? SerializerWithUser { get; }
#endif

/// <summary>
///
/// </summary>
#if NET6_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value2))]
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(SerializerWithUser))]
#endif
public bool IsValue2 => Value2 != null;
public bool IsSerializerWithUser => SerializerWithUser != null;
/// <summary>
///
/// </summary>
Expand All @@ -60,14 +60,14 @@ namespace LabelStudio
/// <summary>
///
/// </summary>
public static implicit operator global::LabelStudio.Comment?(MaybeExpandedComment @this) => @this.Value1;
public static implicit operator global::LabelStudio.Comment?(MaybeExpandedComment @this) => @this.Comment;

/// <summary>
///
/// </summary>
public MaybeExpandedComment(global::LabelStudio.Comment? value)
{
Value1 = value;
Comment = value;
}

/// <summary>
Expand All @@ -78,72 +78,72 @@ public MaybeExpandedComment(global::LabelStudio.Comment? value)
/// <summary>
///
/// </summary>
public static implicit operator global::LabelStudio.CommentSerializerWithExpandedUser?(MaybeExpandedComment @this) => @this.Value2;
public static implicit operator global::LabelStudio.CommentSerializerWithExpandedUser?(MaybeExpandedComment @this) => @this.SerializerWithUser;

/// <summary>
///
/// </summary>
public MaybeExpandedComment(global::LabelStudio.CommentSerializerWithExpandedUser? value)
{
Value2 = value;
SerializerWithUser = value;
}

/// <summary>
///
/// </summary>
public MaybeExpandedComment(
global::LabelStudio.Comment? value1,
global::LabelStudio.CommentSerializerWithExpandedUser? value2
global::LabelStudio.Comment? comment,
global::LabelStudio.CommentSerializerWithExpandedUser? serializerWithUser
)
{
Value1 = value1;
Value2 = value2;
Comment = comment;
SerializerWithUser = serializerWithUser;
}

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

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

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

/// <summary>
///
/// </summary>
public TResult? Match<TResult>(
global::System.Func<global::LabelStudio.Comment?, TResult>? value1 = null,
global::System.Func<global::LabelStudio.CommentSerializerWithExpandedUser?, TResult>? value2 = null,
global::System.Func<global::LabelStudio.Comment?, TResult>? comment = null,
global::System.Func<global::LabelStudio.CommentSerializerWithExpandedUser?, TResult>? serializerWithUser = null,
bool validate = true)
{
if (validate)
{
Validate();
}

if (IsValue1 && value1 != null)
if (IsComment && comment != null)
{
return value1(Value1!);
return comment(Comment!);
}
else if (IsValue2 && value2 != null)
else if (IsSerializerWithUser && serializerWithUser != null)
{
return value2(Value2!);
return serializerWithUser(SerializerWithUser!);
}

return default(TResult);
Expand All @@ -153,22 +153,22 @@ public bool Validate()
///
/// </summary>
public void Match(
global::System.Action<global::LabelStudio.Comment?>? value1 = null,
global::System.Action<global::LabelStudio.CommentSerializerWithExpandedUser?>? value2 = null,
global::System.Action<global::LabelStudio.Comment?>? comment = null,
global::System.Action<global::LabelStudio.CommentSerializerWithExpandedUser?>? serializerWithUser = null,
bool validate = true)
{
if (validate)
{
Validate();
}

if (IsValue1)
if (IsComment)
{
value1?.Invoke(Value1!);
comment?.Invoke(Comment!);
}
else if (IsValue2)
else if (IsSerializerWithUser)
{
value2?.Invoke(Value2!);
serializerWithUser?.Invoke(SerializerWithUser!);
}
}

Expand All @@ -179,9 +179,9 @@ public override int GetHashCode()
{
var fields = new object?[]
{
Value1,
Comment,
typeof(global::LabelStudio.Comment),
Value2,
SerializerWithUser,
typeof(global::LabelStudio.CommentSerializerWithExpandedUser),
};
const int offset = unchecked((int)2166136261);
Expand All @@ -199,8 +199,8 @@ static int HashCodeAggregator(int hashCode, object? value) => value == null
public bool Equals(MaybeExpandedComment other)
{
return
global::System.Collections.Generic.EqualityComparer<global::LabelStudio.Comment?>.Default.Equals(Value1, other.Value1) &&
global::System.Collections.Generic.EqualityComparer<global::LabelStudio.CommentSerializerWithExpandedUser?>.Default.Equals(Value2, other.Value2)
global::System.Collections.Generic.EqualityComparer<global::LabelStudio.Comment?>.Default.Equals(Comment, other.Comment) &&
global::System.Collections.Generic.EqualityComparer<global::LabelStudio.CommentSerializerWithExpandedUser?>.Default.Equals(SerializerWithUser, other.SerializerWithUser)
;
}

Expand Down