From 480f1b3243d5881d16664bb3e560baf684dce989 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 26 Feb 2026 15:32:44 +0000 Subject: [PATCH 1/2] Fix custom attribute encoding: implement array support and apply transValue to all attribute args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Implement encodeCustomAttrElemTypeForObject for obj[] — previously threw 'TODO: can't yet emit arrays in attrs'. Now infers element type from the runtime array type and encodes SZARRAY + element type byte per ECMA-335. - Apply transValue to constructorArgs and named property/field values in defineCustomAttrs. Previously transValue was defined but never called, meaning System.Type values in attribute constructor arguments were not translated to their target ILType — potentially encoding design-time type names instead of target names. Tests: 104 passed, 0 failed Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/ProvidedTypes.fs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/ProvidedTypes.fs b/src/ProvidedTypes.fs index 4dc07c0..b2f3139 100644 --- a/src/ProvidedTypes.fs +++ b/src/ProvidedTypes.fs @@ -6431,7 +6431,26 @@ module internal AssemblyReader = | null -> [| et_STRING |]// yes, the 0xe prefix is used when passing a "null" to a property or argument of type "object" here | :? single -> [| et_R4 |] | :? double -> [| et_R8 |] - | :? (obj[]) -> failwith "TODO: can't yet emit arrays in attrs" // [| yield et_SZARRAY; yield! encodeCustomAttrElemType elemTy |] + | :? (obj[]) as arr -> + // Infer element type from the runtime array element type + let elemTy = arr.GetType().GetElementType() + let elemTypeCode = + if elemTy = typeof then [| et_STRING |] + elif elemTy = typeof then [| et_BOOLEAN |] + elif elemTy = typeof then [| et_CHAR |] + elif elemTy = typeof then [| et_I1 |] + elif elemTy = typeof then [| et_I2 |] + elif elemTy = typeof then [| et_I4 |] + elif elemTy = typeof then [| et_I8 |] + elif elemTy = typeof then [| et_U1 |] + elif elemTy = typeof then [| et_U2 |] + elif elemTy = typeof then [| et_U4 |] + elif elemTy = typeof then [| et_U8 |] + elif elemTy = typeof then [| et_R4 |] + elif elemTy = typeof then [| et_R8 |] + elif elemTy = typeof then [| 0x51uy |] // OBJECT + else failwithf "encodeCustomAttrElemTypeForObject: unsupported array element type %O" elemTy + [| yield et_SZARRAY; yield! elemTypeCode |] | _ -> failwith "unexpected value in custom attribute" /// Given a custom attribute element, encode it to a binary representation according to the rules in Ecma 335 Partition II. @@ -15642,13 +15661,13 @@ namespace ProviderImplementation.ProvidedTypes let defineCustomAttrs f (cattrs: IList) = for attr in cattrs do - let constructorArgs = [ for x in attr.ConstructorArguments -> x.Value ] let transValue (o:obj) = match o with | :? Type as t -> box (transType t) | v -> v - let namedProps = [ for x in attr.NamedArguments do match x.MemberInfo with :? PropertyInfo as pi -> yield ILCustomAttrNamedArg(pi.Name, transType x.TypedValue.ArgumentType, x.TypedValue.Value) | _ -> () ] - let namedFields = [ for x in attr.NamedArguments do match x.MemberInfo with :? FieldInfo as pi -> yield ILCustomAttrNamedArg(pi.Name, transType x.TypedValue.ArgumentType, x.TypedValue.Value) | _ -> () ] + let constructorArgs = [ for x in attr.ConstructorArguments -> transValue x.Value ] + let namedProps = [ for x in attr.NamedArguments do match x.MemberInfo with :? PropertyInfo as pi -> yield ILCustomAttrNamedArg(pi.Name, transType x.TypedValue.ArgumentType, transValue x.TypedValue.Value) | _ -> () ] + let namedFields = [ for x in attr.NamedArguments do match x.MemberInfo with :? FieldInfo as pi -> yield ILCustomAttrNamedArg(pi.Name, transType x.TypedValue.ArgumentType, transValue x.TypedValue.Value) | _ -> () ] let ca = mkILCustomAttribMethRef (transCtorSpec attr.Constructor, constructorArgs, namedProps, namedFields) f ca From 29211948dffc28d56c178b9dc03e70e37256f15d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 26 Feb 2026 15:37:40 +0000 Subject: [PATCH 2/2] ci: trigger CI checks