Skip to content

Commit 673f7af

Browse files
committed
fix: Fixed issue with named OneOf JsonConverters.
1 parent d34c6b2 commit 673f7af

File tree

56 files changed

+191
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+191
-191
lines changed

src/libs/AutoSDK/Sources/Sources.JsonConverters.AnyOf.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public static string GenerateAnyOfJsonConverter(
5454
{(anyOfData.IsTrimming ? $@"
5555
var typeInfo = typeInfoResolver.GetTypeInfo(typeof({x.Type.CSharpTypeWithoutNullability}), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<{x.Type.CSharpTypeWithoutNullability}> ??
5656
throw new global::System.InvalidOperationException($""Cannot get type info for {{nameof({x.Type.CSharpTypeWithoutNullability})}}"");
57-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
57+
{x.ParameterName} = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
5858
" : $@"
59-
_ = global::System.Text.Json.JsonSerializer.Deserialize<{x.Type.CSharpTypeWithoutNullability}>(ref reader, options);
59+
{x.ParameterName} = global::System.Text.Json.JsonSerializer.Deserialize<{x.Type.CSharpTypeWithoutNullability}>(ref reader, options);
6060
")}
6161
}}
6262
").Inject().TrimEnd(',')}

src/tests/AutoSDK.SnapshotTests/Snapshots/Ai21/SystemTextJson/_#JsonConverters.MessagesItem.g.verified.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@ public class MessagesItemJsonConverter : global::System.Text.Json.Serialization.
2727
{
2828
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.UserMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.UserMessage> ??
2929
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.UserMessage)}");
30-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
30+
userMessage = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3131
}
3232
global::G.AssistantMessage? assistantMessage = default;
3333
if (discriminator?.Role == global::G.LanguageStudioApiServerDataTypesChatChatRequestMessageDiscriminatorRole.Assistant)
3434
{
3535
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.AssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.AssistantMessage> ??
3636
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.AssistantMessage)}");
37-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
37+
assistantMessage = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3838
}
3939
global::G.ToolMessage? toolMessage = default;
4040
if (discriminator?.Role == global::G.LanguageStudioApiServerDataTypesChatChatRequestMessageDiscriminatorRole.Tool)
4141
{
4242
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.ToolMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.ToolMessage> ??
4343
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.ToolMessage)}");
44-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
44+
toolMessage = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
4545
}
4646
global::G.SystemMessage? systemMessage = default;
4747
if (discriminator?.Role == global::G.LanguageStudioApiServerDataTypesChatChatRequestMessageDiscriminatorRole.System)
4848
{
4949
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.SystemMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.SystemMessage> ??
5050
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.SystemMessage)}");
51-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
51+
systemMessage = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
5252
}
5353

5454
var result = new global::G.MessagesItem(

src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/SystemTextJson/_#JsonConverters.Block.g.verified.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@ public class BlockJsonConverter : global::System.Text.Json.Serialization.JsonCon
2727
{
2828
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.TextBlock), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.TextBlock> ??
2929
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.TextBlock)}");
30-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
30+
text = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3131
}
3232
global::G.ImageBlock? image = default;
3333
if (discriminator?.Type == global::G.BlockDiscriminatorType.Image)
3434
{
3535
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.ImageBlock), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.ImageBlock> ??
3636
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.ImageBlock)}");
37-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
37+
image = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3838
}
3939
global::G.ToolUseBlock? toolUse = default;
4040
if (discriminator?.Type == global::G.BlockDiscriminatorType.ToolUse)
4141
{
4242
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.ToolUseBlock), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.ToolUseBlock> ??
4343
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.ToolUseBlock)}");
44-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
44+
toolUse = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
4545
}
4646
global::G.ToolResultBlock? toolResult = default;
4747
if (discriminator?.Type == global::G.BlockDiscriminatorType.ToolResult)
4848
{
4949
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.ToolResultBlock), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.ToolResultBlock> ??
5050
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.ToolResultBlock)}");
51-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
51+
toolResult = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
5252
}
5353

5454
var result = new global::G.Block(

src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/SystemTextJson/_#JsonConverters.BlockDelta.g.verified.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public class BlockDeltaJsonConverter : global::System.Text.Json.Serialization.Js
2727
{
2828
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.TextBlockDelta), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.TextBlockDelta> ??
2929
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.TextBlockDelta)}");
30-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
30+
text = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3131
}
3232
global::G.InputJsonBlockDelta? inputJson = default;
3333
if (discriminator?.Type == global::G.BlockDeltaDiscriminatorType.InputJsonDelta)
3434
{
3535
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.InputJsonBlockDelta), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.InputJsonBlockDelta> ??
3636
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.InputJsonBlockDelta)}");
37-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
37+
inputJson = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3838
}
3939

4040
var result = new global::G.BlockDelta(

src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/SystemTextJson/_#JsonConverters.MessageStreamEvent.g.verified.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,49 @@ public class MessageStreamEventJsonConverter : global::System.Text.Json.Serializ
2727
{
2828
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.MessageStartEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.MessageStartEvent> ??
2929
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.MessageStartEvent)}");
30-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
30+
start = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3131
}
3232
global::G.MessageDeltaEvent? delta = default;
3333
if (discriminator?.Type == global::G.MessageStreamEventDiscriminatorType.MessageStart)
3434
{
3535
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.MessageDeltaEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.MessageDeltaEvent> ??
3636
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.MessageDeltaEvent)}");
37-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
37+
delta = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3838
}
3939
global::G.MessageStopEvent? stop = default;
4040
if (discriminator?.Type == global::G.MessageStreamEventDiscriminatorType.MessageStart)
4141
{
4242
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.MessageStopEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.MessageStopEvent> ??
4343
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.MessageStopEvent)}");
44-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
44+
stop = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
4545
}
4646
global::G.ContentBlockStartEvent? contentBlockStart = default;
4747
if (discriminator?.Type == global::G.MessageStreamEventDiscriminatorType.MessageStart)
4848
{
4949
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.ContentBlockStartEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.ContentBlockStartEvent> ??
5050
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.ContentBlockStartEvent)}");
51-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
51+
contentBlockStart = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
5252
}
5353
global::G.ContentBlockDeltaEvent? contentBlockDelta = default;
5454
if (discriminator?.Type == global::G.MessageStreamEventDiscriminatorType.MessageStart)
5555
{
5656
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.ContentBlockDeltaEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.ContentBlockDeltaEvent> ??
5757
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.ContentBlockDeltaEvent)}");
58-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
58+
contentBlockDelta = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
5959
}
6060
global::G.ContentBlockStopEvent? contentBlockStop = default;
6161
if (discriminator?.Type == global::G.MessageStreamEventDiscriminatorType.MessageStart)
6262
{
6363
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.ContentBlockStopEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.ContentBlockStopEvent> ??
6464
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.ContentBlockStopEvent)}");
65-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
65+
contentBlockStop = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
6666
}
6767
global::G.PingEvent? ping = default;
6868
if (discriminator?.Type == global::G.MessageStreamEventDiscriminatorType.MessageStart)
6969
{
7070
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.PingEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.PingEvent> ??
7171
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.PingEvent)}");
72-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
72+
ping = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
7373
}
7474

7575
var result = new global::G.MessageStreamEvent(

src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/SystemTextJson/_#JsonConverters.ChatMessageV2.g.verified.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@ public class ChatMessageV2JsonConverter : global::System.Text.Json.Serialization
2727
{
2828
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.UserMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.UserMessage> ??
2929
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.UserMessage)}");
30-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
30+
user = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3131
}
3232
global::G.AssistantMessage? assistant = default;
3333
if (discriminator?.Role == global::G.ChatMessageV2DiscriminatorRole.Assistant)
3434
{
3535
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.AssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.AssistantMessage> ??
3636
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.AssistantMessage)}");
37-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
37+
assistant = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3838
}
3939
global::G.SystemMessage? system = default;
4040
if (discriminator?.Role == global::G.ChatMessageV2DiscriminatorRole.System)
4141
{
4242
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.SystemMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.SystemMessage> ??
4343
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.SystemMessage)}");
44-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
44+
system = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
4545
}
4646
global::G.ToolMessageV2? tool = default;
4747
if (discriminator?.Role == global::G.ChatMessageV2DiscriminatorRole.Tool)
4848
{
4949
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.ToolMessageV2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.ToolMessageV2> ??
5050
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.ToolMessageV2)}");
51-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
51+
tool = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
5252
}
5353

5454
var result = new global::G.ChatMessageV2(

src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/SystemTextJson/_#JsonConverters.ContentItem.g.verified.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ContentItemJsonConverter : global::System.Text.Json.Serialization.J
2727
{
2828
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.TextContent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.TextContent> ??
2929
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.TextContent)}");
30-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
30+
text = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3131
}
3232

3333
var result = new global::G.ContentItem(

src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/SystemTextJson/_#JsonConverters.ResponseFormatV2.g.verified.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public class ResponseFormatV2JsonConverter : global::System.Text.Json.Serializat
2727
{
2828
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.TextResponseFormatV2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.TextResponseFormatV2> ??
2929
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.TextResponseFormatV2)}");
30-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
30+
text = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3131
}
3232
global::G.JsonResponseFormatV2? json = default;
3333
if (discriminator?.Type == global::G.ResponseFormatV2DiscriminatorType.Text)
3434
{
3535
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.JsonResponseFormatV2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.JsonResponseFormatV2> ??
3636
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.JsonResponseFormatV2)}");
37-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
37+
json = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3838
}
3939

4040
var result = new global::G.ResponseFormatV2(

src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/SystemTextJson/_#JsonConverters.ToolContent.g.verified.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public class ToolContentJsonConverter : global::System.Text.Json.Serialization.J
2727
{
2828
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.TextContent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.TextContent> ??
2929
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.TextContent)}");
30-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
30+
text = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3131
}
3232
global::G.DocumentContent? document = default;
3333
if (discriminator?.Type == global::G.ToolContentDiscriminatorType.Document)
3434
{
3535
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::G.DocumentContent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::G.DocumentContent> ??
3636
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::G.DocumentContent)}");
37-
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
37+
document = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
3838
}
3939

4040
var result = new global::G.ToolContent(

0 commit comments

Comments
 (0)