From 657491b38e0ff690d5f6ea4d6eced2e278cb3bd5 Mon Sep 17 00:00:00 2001 From: hhang <169027046+xu91102@users.noreply.github.com> Date: Thu, 29 Oct 2026 16:47:54 +0800 Subject: [PATCH] test(dotnet): guard field default comparison warning Compare actual ordinary and constant-bearing observations independently of the limitation producer. Preserve warning delivery and unchanged matching assertions while allowing harmless wording changes. Refs #5150 --- .../managedFieldConstantsComparison.test.ts | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/boundary/providers/managed/managedFieldConstantsComparison.test.ts b/tests/boundary/providers/managed/managedFieldConstantsComparison.test.ts index 0a177aeee5..1473071c04 100644 --- a/tests/boundary/providers/managed/managedFieldConstantsComparison.test.ts +++ b/tests/boundary/providers/managed/managedFieldConstantsComparison.test.ts @@ -8,10 +8,13 @@ import { executeManagedMemberComparison } from "../../../../src/application/mana import { managedMemberComparisonResultSchema } from "../../../../src/domain/managed/managedMemberComparison.js"; it("keeps field comparison policy and delivers its owning limitation for changed defaults", () => { - const observe = (hex: string) => { + const observe = (hex: string, hasDefault = true, moduleByte = 0) => { const bytes = buildManagedPeFixture({ - fields: [{ name: "Default", flags: 0x8056 }], - constants: [{ typeCode: 8, value: Buffer.from(hex, "hex") }], + mvid: Buffer.alloc(16, moduleByte), + fields: [{ name: "Default", flags: hasDefault ? 0x8056 : 0x56 }], + constants: hasDefault + ? [{ typeCode: 8, value: Buffer.from(hex, "hex") }] + : [], }); const target = managedPeFixtureTarget(bytes); const report = inspectManagedMembersBytes(bytes, target); @@ -57,4 +60,20 @@ it("keeps field comparison policy and delivers its owning limitation for changed expect(comparison.limitations).toEqual( expect.arrayContaining(comparisonLimitations(left.report, right.report)), ); + const ordinary = observe("", false, 1); + const otherOrdinary = observe("", false, 2); + expect(ordinary.report.fields[0]?.constant).toBeNull(); + const baseline = executeManagedMemberComparison({ + left: ordinary.evidence, + right: otherOrdinary.evidence, + }); + if (!baseline.ok) throw baseline.error; + const baselineComparison = managedMemberComparisonResultSchema.parse( + baseline.value.evidence.normalized_result, + ); + expect( + comparison.limitations.filter( + (limitation) => !baselineComparison.limitations.includes(limitation), + ), + ).toHaveLength(1); });