Interop: the edited variant overrides its name, as a variant must

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-03 11:03:17 +02:00
commit a935d15cc2
2 changed files with 7 additions and 3 deletions

View file

@ -1399,7 +1399,7 @@ test("C# writes an edit made in place, and Rust and Python read the new value",
await csharp("csharp-write", ["write", "--file", override, "--runtime-id", "csharp-writer"]);
await edit(override, "override");
const variant = (await dump(override)).find((record: any) => record.key === "note:variant");
assert.deepEqual(variant.overrides, ["VARIANT title"]);
assert.deepEqual(variant.overrides, ["note:variant", "VARIANT title"]);
const object = join(tempDir, "object.cc");
await csharp("csharp-write-deck", ["write-deck", "--file", object]);

View file

@ -148,11 +148,15 @@ static async Task EditInPlaceAsync(string file, string kind)
await cache.UpsertVariantAsync(
new CultRecordKey("note:variant"),
new CultRecordKey(note.DocumentId),
new[] { cache.Override<CultCacheInteropNote>(nameof(CultCacheInteropNote.Title), "variant title") });
new[]
{
cache.Override<CultCacheInteropNote>(nameof(CultCacheInteropNote.DocumentId), "note:variant"),
cache.Override<CultCacheInteropNote>(nameof(CultCacheInteropNote.Title), "variant title")
});
cache.FlushAllBackingStores();
var snapshot = CultDocumentMessagePackSerialization.DeserializeSnapshot(File.ReadAllBytes(file));
var variant = snapshot.Records.Single(record => record.Variant != null).Variant!;
OverwriteInPlace(variant.Overrides.Single().Value, "variant", "VARIANT");
OverwriteInPlace(variant.Overrides.Single(entry => entry.Path[0].Slot == 3).Value, "variant", "VARIANT");
File.WriteAllBytes(file, CultDocumentMessagePackSerialization.SerializeSnapshot(snapshot));
break;
}