Skip to content

Commit 6d20a9f

Browse files
fix(generator): use tempDict for ReadOnlyDictionary with unmanaged KVP
When deserializing ReadOnlyDictionary with unmanaged key-value pairs, the generated code was incorrectly trying to assign to value[kvp.Key] which fails because ReadOnlyDictionary doesn't support indexer assignment. Now correctly assigns to tempDict instead. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 67a2313 commit 6d20a9f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Nino.Generator/BuiltInType/DictionaryGenerator.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,15 @@ protected override void GenerateDeserializer(ITypeSymbol typeSymbol, Writer writ
191191
writer.Append(" reader.UnsafeRead(out ");
192192
writer.Append(kvpTypeName);
193193
writer.AppendLine(" kvp);");
194-
writer.AppendLine(" value[kvp.Key] = kvp.Value;");
194+
195+
if (isReadOnlyDictionary)
196+
{
197+
writer.AppendLine(" tempDict[kvp.Key] = kvp.Value;");
198+
}
199+
else
200+
{
201+
writer.AppendLine(" value[kvp.Key] = kvp.Value;");
202+
}
195203
}
196204
else
197205
{

0 commit comments

Comments
 (0)