Skip to content

Commit f154efb

Browse files
HavenDVclaude
andcommitted
fix: register concrete List<T> types in JsonSerializerContextTypes (#106)
When IList<T> types are registered in the JsonSerializerContext, the concrete List<T> counterpart was missing, causing serialization failures when System.Text.Json encounters a List<T> at runtime. Now generates ListType properties alongside existing IList-based Type properties. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c934b85 commit f154efb

51 files changed

Lines changed: 8211 additions & 3 deletions

File tree

Some content is hidden

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

src/libs/AutoSDK/Sources/Sources.JsonSerializerContextTypes.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ public static string GenerateJsonSerializerContextTypes(
1717
return string.Empty;
1818
}
1919

20+
var distinctTypes = types
21+
.Select(x => x.CSharpTypeWithNullability)
22+
.Distinct()
23+
.ToArray();
24+
25+
// Generate concrete List<T> counterparts for IList<T> types
26+
var concreteListTypes = distinctTypes
27+
.Where(x => x.Contains("System.Collections.Generic.IList<"))
28+
.Select(x => x.Replace(
29+
"System.Collections.Generic.IList<",
30+
"System.Collections.Generic.List<"))
31+
.Distinct()
32+
.ToArray();
33+
2034
return $@"
2135
#nullable enable
2236
@@ -29,16 +43,20 @@ public sealed partial class JsonSerializerContextTypes
2943
{{
3044
{string.Empty.ToXmlDocumentationSummary(level: 8)}
3145
public global::System.Collections.Generic.Dictionary<string, string>? StringStringDictionary {{ get; set; }}
32-
46+
3347
{string.Empty.ToXmlDocumentationSummary(level: 8)}
3448
public global::System.Collections.Generic.Dictionary<string, object>? StringObjectDictionary {{ get; set; }}
35-
49+
3650
{string.Empty.ToXmlDocumentationSummary(level: 8)}
3751
public global::System.Text.Json.JsonElement? JsonElement {{ get; set; }}
3852
39-
{types.Select(x => x.CSharpTypeWithNullability).Distinct().Select((type, i) => @$"
53+
{distinctTypes.Select((type, i) => @$"
4054
{string.Empty.ToXmlDocumentationSummary(level: 8)}
4155
public {type} Type{i} {{ get; set; }}").Inject()}
56+
57+
{concreteListTypes.Select((type, i) => @$"
58+
{string.Empty.ToXmlDocumentationSummary(level: 8)}
59+
public {type} ListType{i} {{ get; set; }}").Inject()}
4260
}}
4361
}}".RemoveBlankLinesWhereOnlyWhitespaces();
4462
}

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.JsonSerializerContextTypes.g.verified.cs

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ public sealed partial class JsonSerializerContextTypes
1515
///
1616
/// </summary>
1717
public global::System.Collections.Generic.Dictionary<string, string>? StringStringDictionary { get; set; }
18+
1819
/// <summary>
1920
///
2021
/// </summary>
2122
public global::System.Collections.Generic.Dictionary<string, object>? StringObjectDictionary { get; set; }
23+
2224
/// <summary>
2325
///
2426
/// </summary>
@@ -2088,5 +2090,138 @@ public sealed partial class JsonSerializerContextTypes
20882090
///
20892091
/// </summary>
20902092
public global::G.BetaInputContentBlockDiscriminatorType? Type515 { get; set; }
2093+
2094+
/// <summary>
2095+
///
2096+
/// </summary>
2097+
public global::G.AnyOf<string, global::System.Collections.Generic.List<global::G.ContentVariant2Item>>? ListType0 { get; set; }
2098+
/// <summary>
2099+
///
2100+
/// </summary>
2101+
public global::System.Collections.Generic.List<global::G.ContentVariant2Item>? ListType1 { get; set; }
2102+
/// <summary>
2103+
///
2104+
/// </summary>
2105+
public global::System.Collections.Generic.List<global::G.OneOf<global::G.BetaTool, global::G.BetaComputerUseTool20241022, global::G.BetaBashTool20241022, global::G.BetaTextEditor20241022, global::G.BetaComputerUseTool20250124, global::G.BetaBashTool20250124, global::G.BetaTextEditor20250124>>? ListType2 { get; set; }
2106+
/// <summary>
2107+
///
2108+
/// </summary>
2109+
public global::System.Collections.Generic.List<global::G.BetaInputMessage>? ListType3 { get; set; }
2110+
/// <summary>
2111+
///
2112+
/// </summary>
2113+
public global::G.AnyOf<string, global::System.Collections.Generic.List<global::G.BetaRequestTextBlock>>? ListType4 { get; set; }
2114+
/// <summary>
2115+
///
2116+
/// </summary>
2117+
public global::System.Collections.Generic.List<global::G.BetaRequestTextBlock>? ListType5 { get; set; }
2118+
/// <summary>
2119+
///
2120+
/// </summary>
2121+
public global::System.Collections.Generic.List<global::G.BetaMessageBatchIndividualRequestParams>? ListType6 { get; set; }
2122+
/// <summary>
2123+
///
2124+
/// </summary>
2125+
public global::System.Collections.Generic.List<string>? ListType7 { get; set; }
2126+
/// <summary>
2127+
///
2128+
/// </summary>
2129+
public global::G.AnyOf<string, global::System.Collections.Generic.List<global::G.BetaInputContentBlock>>? ListType8 { get; set; }
2130+
/// <summary>
2131+
///
2132+
/// </summary>
2133+
public global::System.Collections.Generic.List<global::G.BetaInputContentBlock>? ListType9 { get; set; }
2134+
/// <summary>
2135+
///
2136+
/// </summary>
2137+
public global::System.Collections.Generic.List<global::G.BetaMessageBatch>? ListType10 { get; set; }
2138+
/// <summary>
2139+
///
2140+
/// </summary>
2141+
public global::System.Collections.Generic.List<global::G.BetaModelInfo>? ListType11 { get; set; }
2142+
/// <summary>
2143+
///
2144+
/// </summary>
2145+
public global::System.Collections.Generic.List<global::G.BetaContentBlock>? ListType12 { get; set; }
2146+
/// <summary>
2147+
///
2148+
/// </summary>
2149+
public global::System.Collections.Generic.List<global::G.CitationsVariant1Item>? ListType13 { get; set; }
2150+
/// <summary>
2151+
///
2152+
/// </summary>
2153+
public global::G.AnyOf<string, global::System.Collections.Generic.List<global::G.ContentVariant2Item2>>? ListType14 { get; set; }
2154+
/// <summary>
2155+
///
2156+
/// </summary>
2157+
public global::System.Collections.Generic.List<global::G.ContentVariant2Item2>? ListType15 { get; set; }
2158+
/// <summary>
2159+
///
2160+
/// </summary>
2161+
public global::System.Collections.Generic.List<global::G.CitationsVariant1Item2>? ListType16 { get; set; }
2162+
/// <summary>
2163+
///
2164+
/// </summary>
2165+
public global::G.AnyOf<string, global::System.Collections.Generic.List<global::G.ContentVariant2Item3>>? ListType17 { get; set; }
2166+
/// <summary>
2167+
///
2168+
/// </summary>
2169+
public global::System.Collections.Generic.List<global::G.ContentVariant2Item3>? ListType18 { get; set; }
2170+
/// <summary>
2171+
///
2172+
/// </summary>
2173+
public global::System.Collections.Generic.List<global::G.OneOf<global::G.Tool, global::G.BashTool20250124, global::G.TextEditor20250124>>? ListType19 { get; set; }
2174+
/// <summary>
2175+
///
2176+
/// </summary>
2177+
public global::System.Collections.Generic.List<global::G.InputMessage>? ListType20 { get; set; }
2178+
/// <summary>
2179+
///
2180+
/// </summary>
2181+
public global::G.AnyOf<string, global::System.Collections.Generic.List<global::G.RequestTextBlock>>? ListType21 { get; set; }
2182+
/// <summary>
2183+
///
2184+
/// </summary>
2185+
public global::System.Collections.Generic.List<global::G.RequestTextBlock>? ListType22 { get; set; }
2186+
/// <summary>
2187+
///
2188+
/// </summary>
2189+
public global::System.Collections.Generic.List<global::G.MessageBatchIndividualRequestParams>? ListType23 { get; set; }
2190+
/// <summary>
2191+
///
2192+
/// </summary>
2193+
public global::G.AnyOf<string, global::System.Collections.Generic.List<global::G.InputContentBlock>>? ListType24 { get; set; }
2194+
/// <summary>
2195+
///
2196+
/// </summary>
2197+
public global::System.Collections.Generic.List<global::G.InputContentBlock>? ListType25 { get; set; }
2198+
/// <summary>
2199+
///
2200+
/// </summary>
2201+
public global::System.Collections.Generic.List<global::G.MessageBatch>? ListType26 { get; set; }
2202+
/// <summary>
2203+
///
2204+
/// </summary>
2205+
public global::System.Collections.Generic.List<global::G.ModelInfo>? ListType27 { get; set; }
2206+
/// <summary>
2207+
///
2208+
/// </summary>
2209+
public global::System.Collections.Generic.List<global::G.ContentBlock3>? ListType28 { get; set; }
2210+
/// <summary>
2211+
///
2212+
/// </summary>
2213+
public global::System.Collections.Generic.List<global::G.CitationsVariant1Item3>? ListType29 { get; set; }
2214+
/// <summary>
2215+
///
2216+
/// </summary>
2217+
public global::G.AnyOf<string, global::System.Collections.Generic.List<global::G.ContentVariant2Item4>>? ListType30 { get; set; }
2218+
/// <summary>
2219+
///
2220+
/// </summary>
2221+
public global::System.Collections.Generic.List<global::G.ContentVariant2Item4>? ListType31 { get; set; }
2222+
/// <summary>
2223+
///
2224+
/// </summary>
2225+
public global::System.Collections.Generic.List<global::G.CitationsVariant1Item4>? ListType32 { get; set; }
20912226
}
20922227
}

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/assemblyai/_#G.JsonSerializerContextTypes.g.verified.cs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ public sealed partial class JsonSerializerContextTypes
1515
///
1616
/// </summary>
1717
public global::System.Collections.Generic.Dictionary<string, string>? StringStringDictionary { get; set; }
18+
1819
/// <summary>
1920
///
2021
/// </summary>
2122
public global::System.Collections.Generic.Dictionary<string, object>? StringObjectDictionary { get; set; }
23+
2224
/// <summary>
2325
///
2426
/// </summary>
@@ -504,5 +506,98 @@ public sealed partial class JsonSerializerContextTypes
504506
///
505507
/// </summary>
506508
public global::G.Error? Type119 { get; set; }
509+
510+
/// <summary>
511+
///
512+
/// </summary>
513+
public global::System.Collections.Generic.List<global::G.WordSearchMatch>? ListType0 { get; set; }
514+
/// <summary>
515+
///
516+
/// </summary>
517+
public global::System.Collections.Generic.List<global::System.Collections.Generic.List<int>>? ListType1 { get; set; }
518+
/// <summary>
519+
///
520+
/// </summary>
521+
public global::System.Collections.Generic.List<int>? ListType2 { get; set; }
522+
/// <summary>
523+
///
524+
/// </summary>
525+
public global::System.Collections.Generic.List<string>? ListType3 { get; set; }
526+
/// <summary>
527+
///
528+
/// </summary>
529+
public global::System.Collections.Generic.List<global::G.PiiPolicy>? ListType4 { get; set; }
530+
/// <summary>
531+
///
532+
/// </summary>
533+
public global::System.Collections.Generic.List<global::G.TranscriptCustomSpelling>? ListType5 { get; set; }
534+
/// <summary>
535+
///
536+
/// </summary>
537+
public global::System.Collections.Generic.List<global::G.TranscriptWord>? ListType6 { get; set; }
538+
/// <summary>
539+
///
540+
/// </summary>
541+
public global::System.Collections.Generic.List<global::G.TranscriptUtterance>? ListType7 { get; set; }
542+
/// <summary>
543+
///
544+
/// </summary>
545+
public global::System.Collections.Generic.List<global::G.Chapter>? ListType8 { get; set; }
546+
/// <summary>
547+
///
548+
/// </summary>
549+
public global::System.Collections.Generic.List<global::G.SentimentAnalysisResult>? ListType9 { get; set; }
550+
/// <summary>
551+
///
552+
/// </summary>
553+
public global::System.Collections.Generic.List<global::G.Entity>? ListType10 { get; set; }
554+
/// <summary>
555+
///
556+
/// </summary>
557+
public global::System.Collections.Generic.List<global::G.TopicDetectionResult>? ListType11 { get; set; }
558+
/// <summary>
559+
///
560+
/// </summary>
561+
public global::System.Collections.Generic.List<global::G.ContentSafetyLabelResult>? ListType12 { get; set; }
562+
/// <summary>
563+
///
564+
/// </summary>
565+
public global::System.Collections.Generic.List<global::G.TopicDetectionResultLabel>? ListType13 { get; set; }
566+
/// <summary>
567+
///
568+
/// </summary>
569+
public global::System.Collections.Generic.List<global::G.ContentSafetyLabel>? ListType14 { get; set; }
570+
/// <summary>
571+
///
572+
/// </summary>
573+
public global::System.Collections.Generic.List<global::G.AutoHighlightResult>? ListType15 { get; set; }
574+
/// <summary>
575+
///
576+
/// </summary>
577+
public global::System.Collections.Generic.List<global::G.Timestamp>? ListType16 { get; set; }
578+
/// <summary>
579+
///
580+
/// </summary>
581+
public global::System.Collections.Generic.List<global::G.TranscriptSentence>? ListType17 { get; set; }
582+
/// <summary>
583+
///
584+
/// </summary>
585+
public global::System.Collections.Generic.List<global::G.TranscriptParagraph>? ListType18 { get; set; }
586+
/// <summary>
587+
///
588+
/// </summary>
589+
public global::System.Collections.Generic.List<global::G.TranscriptListItem>? ListType19 { get; set; }
590+
/// <summary>
591+
///
592+
/// </summary>
593+
public global::System.Collections.Generic.List<global::G.LemurQuestionAnswer>? ListType20 { get; set; }
594+
/// <summary>
595+
///
596+
/// </summary>
597+
public global::System.Collections.Generic.List<global::System.Guid>? ListType21 { get; set; }
598+
/// <summary>
599+
///
600+
/// </summary>
601+
public global::System.Collections.Generic.List<global::G.LemurQuestion>? ListType22 { get; set; }
507602
}
508603
}

0 commit comments

Comments
 (0)