提交 f57b97c1 编写于 作者: K Kevin Ransom (msft) 提交者: GitHub

Fix attribute references (#3530)

* Fix attribute references

* For attributes with type arguments only add reference to Nominal types
上级 4eba761a
......@@ -838,7 +838,8 @@ type ILAttribElem =
type ILAttributeNamedArg = (string * ILType * bool * ILAttribElem)
type ILAttribute =
{ Method: ILMethodSpec;
Data: byte[] }
Data: byte[]
Elements: ILAttribElem list}
[<NoEquality; NoComparison; Sealed>]
type ILAttributes(f: unit -> ILAttribute[]) =
......@@ -3088,12 +3089,12 @@ let rec decodeCustomAttrElemType (ilg: ILGlobals) bytes sigptr x =
let rec encodeCustomAttrPrimValue ilg c =
match c with
| ILAttribElem.Bool b -> [| (if b then 0x01uy else 0x00uy) |]
| ILAttribElem.String None
| ILAttribElem.Type None
| ILAttribElem.String None
| ILAttribElem.Type None
| ILAttribElem.TypeRef None
| ILAttribElem.Null -> [| 0xFFuy |]
| ILAttribElem.String (Some s) -> encodeCustomAttrString s
| ILAttribElem.Char x -> u16AsBytes (uint16 x)
| ILAttribElem.Char x -> u16AsBytes (uint16 x)
| ILAttribElem.SByte x -> i8AsBytes x
| ILAttribElem.Int16 x -> i16AsBytes x
| ILAttribElem.Int32 x -> i32AsBytes x
......@@ -3135,9 +3136,9 @@ let mkILCustomAttribMethRef (ilg: ILGlobals) (mspec:ILMethodSpec, fixedArgs: lis
yield! u16AsBytes (uint16 namedArgs.Length)
for namedArg in namedArgs do
yield! encodeCustomAttrNamedArg ilg namedArg |]
{ Method = mspec;
Data = args }
Data = args;
Elements = fixedArgs @ (namedArgs |> List.map(fun (_,_,_,e) -> e)) }
let mkILCustomAttribute ilg (tref,argtys,argvs,propvs) =
mkILCustomAttribMethRef ilg (mkILNonGenericCtorMethSpec (tref,argtys),argvs,propvs)
......
......@@ -852,7 +852,8 @@ type ILAttributeNamedArg = string * ILType * bool * ILAttribElem
/// to ILAttribElem's as best as possible.
type ILAttribute =
{ Method: ILMethodSpec;
Data: byte[] }
Data: byte[]
Elements: ILAttribElem list}
[<NoEquality; NoComparison; Sealed>]
type ILAttributes =
......
......@@ -2532,7 +2532,8 @@ and seekReadCustomAttrUncached ctxtH (CustomAttrIdx (cat,idx,valIdx)) =
Data=
match readBlobHeapOption ctxt valIdx with
| Some bytes -> bytes
| None -> Bytes.ofInt32Array [| |] }
| None -> Bytes.ofInt32Array [| |]
Elements = [] }
and seekReadSecurityDecls ctxt idx =
mkILLazySecurityDecls
......
......@@ -1413,10 +1413,17 @@ let rec GetCustomAttrDataAsBlobIdx cenv (data:byte[]) =
and GetCustomAttrRow cenv hca attr =
let cat = GetMethodRefAsCustomAttribType cenv attr.Method.MethodRef
UnsharedRow
[| HasCustomAttribute (fst hca, snd hca)
CustomAttributeType (fst cat, snd cat)
Blob (GetCustomAttrDataAsBlobIdx cenv attr.Data) |]
for element in attr.Elements do
match element with
| ILAttribElem.Type (Some ty) when ty.IsNominal -> GetTypeRefAsTypeRefIdx cenv ty.TypeRef |> ignore
| ILAttribElem.TypeRef (Some tref) -> GetTypeRefAsTypeRefIdx cenv tref |> ignore
| _ -> ()
UnsharedRow
[| HasCustomAttribute (fst hca, snd hca);
CustomAttributeType (fst cat, snd cat);
Blob (GetCustomAttrDataAsBlobIdx cenv attr.Data)
|]
and GenCustomAttrPass3Or4 cenv hca attr =
AddUnsharedRow cenv TableNames.CustomAttribute (GetCustomAttrRow cenv hca attr) |> ignore
......@@ -4323,4 +4330,3 @@ let WriteILBinary (outfile, (args: options), modul) =
args.ilg, args.pdbfile, args.signer, args.portablePDB, args.embeddedPDB, args.embedAllSource,
args.embedSourceList, args.sourceLink, args.emitTailcalls, args.deterministic, args.showTimes, args.dumpDebugInfo) modul
|> ignore
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册