提交 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 = ...@@ -838,7 +838,8 @@ type ILAttribElem =
type ILAttributeNamedArg = (string * ILType * bool * ILAttribElem) type ILAttributeNamedArg = (string * ILType * bool * ILAttribElem)
type ILAttribute = type ILAttribute =
{ Method: ILMethodSpec; { Method: ILMethodSpec;
Data: byte[] } Data: byte[]
Elements: ILAttribElem list}
[<NoEquality; NoComparison; Sealed>] [<NoEquality; NoComparison; Sealed>]
type ILAttributes(f: unit -> ILAttribute[]) = type ILAttributes(f: unit -> ILAttribute[]) =
...@@ -3135,9 +3136,9 @@ let mkILCustomAttribMethRef (ilg: ILGlobals) (mspec:ILMethodSpec, fixedArgs: lis ...@@ -3135,9 +3136,9 @@ let mkILCustomAttribMethRef (ilg: ILGlobals) (mspec:ILMethodSpec, fixedArgs: lis
yield! u16AsBytes (uint16 namedArgs.Length) yield! u16AsBytes (uint16 namedArgs.Length)
for namedArg in namedArgs do for namedArg in namedArgs do
yield! encodeCustomAttrNamedArg ilg namedArg |] yield! encodeCustomAttrNamedArg ilg namedArg |]
{ Method = mspec; { Method = mspec;
Data = args } Data = args;
Elements = fixedArgs @ (namedArgs |> List.map(fun (_,_,_,e) -> e)) }
let mkILCustomAttribute ilg (tref,argtys,argvs,propvs) = let mkILCustomAttribute ilg (tref,argtys,argvs,propvs) =
mkILCustomAttribMethRef ilg (mkILNonGenericCtorMethSpec (tref,argtys),argvs,propvs) mkILCustomAttribMethRef ilg (mkILNonGenericCtorMethSpec (tref,argtys),argvs,propvs)
......
...@@ -852,7 +852,8 @@ type ILAttributeNamedArg = string * ILType * bool * ILAttribElem ...@@ -852,7 +852,8 @@ type ILAttributeNamedArg = string * ILType * bool * ILAttribElem
/// to ILAttribElem's as best as possible. /// to ILAttribElem's as best as possible.
type ILAttribute = type ILAttribute =
{ Method: ILMethodSpec; { Method: ILMethodSpec;
Data: byte[] } Data: byte[]
Elements: ILAttribElem list}
[<NoEquality; NoComparison; Sealed>] [<NoEquality; NoComparison; Sealed>]
type ILAttributes = type ILAttributes =
......
...@@ -2532,7 +2532,8 @@ and seekReadCustomAttrUncached ctxtH (CustomAttrIdx (cat,idx,valIdx)) = ...@@ -2532,7 +2532,8 @@ and seekReadCustomAttrUncached ctxtH (CustomAttrIdx (cat,idx,valIdx)) =
Data= Data=
match readBlobHeapOption ctxt valIdx with match readBlobHeapOption ctxt valIdx with
| Some bytes -> bytes | Some bytes -> bytes
| None -> Bytes.ofInt32Array [| |] } | None -> Bytes.ofInt32Array [| |]
Elements = [] }
and seekReadSecurityDecls ctxt idx = and seekReadSecurityDecls ctxt idx =
mkILLazySecurityDecls mkILLazySecurityDecls
......
...@@ -1413,10 +1413,17 @@ let rec GetCustomAttrDataAsBlobIdx cenv (data:byte[]) = ...@@ -1413,10 +1413,17 @@ let rec GetCustomAttrDataAsBlobIdx cenv (data:byte[]) =
and GetCustomAttrRow cenv hca attr = and GetCustomAttrRow cenv hca attr =
let cat = GetMethodRefAsCustomAttribType cenv attr.Method.MethodRef let cat = GetMethodRefAsCustomAttribType cenv attr.Method.MethodRef
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 UnsharedRow
[| HasCustomAttribute (fst hca, snd hca) [| HasCustomAttribute (fst hca, snd hca);
CustomAttributeType (fst cat, snd cat) CustomAttributeType (fst cat, snd cat);
Blob (GetCustomAttrDataAsBlobIdx cenv attr.Data) |] Blob (GetCustomAttrDataAsBlobIdx cenv attr.Data)
|]
and GenCustomAttrPass3Or4 cenv hca attr = and GenCustomAttrPass3Or4 cenv hca attr =
AddUnsharedRow cenv TableNames.CustomAttribute (GetCustomAttrRow cenv hca attr) |> ignore AddUnsharedRow cenv TableNames.CustomAttribute (GetCustomAttrRow cenv hca attr) |> ignore
...@@ -4323,4 +4330,3 @@ let WriteILBinary (outfile, (args: options), modul) = ...@@ -4323,4 +4330,3 @@ let WriteILBinary (outfile, (args: options), modul) =
args.ilg, args.pdbfile, args.signer, args.portablePDB, args.embeddedPDB, args.embedAllSource, 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 args.embedSourceList, args.sourceLink, args.emitTailcalls, args.deterministic, args.showTimes, args.dumpDebugInfo) modul
|> ignore |> ignore
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册