[Repo Assist] Fix decodeILCustomAttribData: read correct byte width for non-int32 enum fixed args#472
Conversation
… enum fixed args Previously the catch-all ILType.Value arm in parseVal always read 4 bytes (int32) for any enum-typed fixed argument in a custom attribute blob. ECMA-335 requires that enum values are stored using the width of the enum's underlying type, so a byte-backed enum attribute argument encodes in 1 byte and an int64-backed one in 8 bytes. Fix: add a resolveEnumUnderlyingILType resolver that is threaded through decodeILCustomAttribData. At the txCustomAttributesDatum call site the resolver uses txILType to get the runtime System.Type for the enum, calls Enum.GetUnderlyingType, and maps back to the correct ILType. Any resolution failure falls back to ilg.typ_Int32 (preserving prior behaviour). For the common case (int32 enums) the resolver returns ilg.typ_Int32 and behaviour is identical to before. The fix benefits type providers that reference assemblies containing attributes with byte, int16, uint16, uint32, int64, or uint64 enum parameters. All 110 existing tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
/repo-assist we need tests added for this case - unit tests would be fine if they can be arranged, even better integration tests |
…m fixed args Three new tests in BasicGenerativeProvisionTests.fs verify that decodeILCustomAttribData correctly reads byte-, int16-, and int64-backed enum custom attribute arguments via ReadRelatedAssembly (the path that exercises the IL blob decoder). Also fixes TargetTypeDefinition.GetEnumUnderlyingType() which previously always returned Int32 (noted as a TODO). It now reads the 'value__' field from the ILTypeDef to determine the actual underlying type. This is required for resolveEnumUnderlyingILType (introduced in the main fix) to work correctly for target types. All 113 tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
|
🤖 This is an automated response from Repo Assist. I've pushed a commit to this PR with the tests you asked for. What was added ( Three integration tests:
Each test creates a generative type provider that attaches a custom attribute backed by a non-int32 enum, generates the assembly, then reads it back via Also fixed (
All 113 tests pass (110 pre-existing + 3 new).
|
🤖 This PR was created by Repo Assist, an automated AI assistant.
Problem
decodeILCustomAttribDatahad a catch-all arm for enum-typed fixed arguments that always read 4 bytes regardless of the enum's actual underlying type:All 110 existing tests pass. This fix addresses the "Future Work" item noted in #465 (
decodeILCustomAttribDataenum-size bug).