Skip to content

Commit 45b6f85

Browse files
committed
Merge pull request #406 from dsyme/integrate-14
Integrate visualfsharp/master --> master
2 parents f7e00f7 + 602a4bc commit 45b6f85

File tree

10 files changed

+36
-38
lines changed

10 files changed

+36
-38
lines changed

src/absil/il.fs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4691,7 +4691,7 @@ type ILTypeSigParser(tstring : string) =
46914691
let ilty = x.ParseType()
46924692
ILAttribElem.Type(Some(ilty))
46934693

4694-
let decodeILAttribData ilg (ca: ILAttribute) scope =
4694+
let decodeILAttribData ilg (ca: ILAttribute) =
46954695
let bytes = ca.Data
46964696
let sigptr = 0
46974697
let bb0,sigptr = sigptr_get_byte bytes sigptr
@@ -4785,15 +4785,19 @@ let decodeILAttribData ilg (ca: ILAttribute) scope =
47854785
let et,sigptr = sigptr_get_u8 bytes sigptr
47864786
// We have a named value
47874787
let ty,sigptr =
4788-
// REVIEW: Post-M3, consider removing the restriction for scope - it's unnecessary
4789-
// because you can reconstruct scope using the qualified name from the CA Blob
4790-
if (0x50 = (int et) || 0x55 = (int et)) && Option.isSome scope then
4788+
if (0x50 = (int et) || 0x55 = (int et)) then
47914789
let qualified_tname,sigptr = sigptr_get_serstring bytes sigptr
4792-
// we're already getting the qualified name from the binary blob
4793-
// if we don't split out the unqualified name from the qualified name,
4794-
// we'll write the qualified assembly reference string twice to the binary blob
4795-
let unqualified_tname = qualified_tname.Split([|','|]).[0]
4796-
let scoref = Option.get scope
4790+
let unqualified_tname, rest =
4791+
let pieces = qualified_tname.Split(',')
4792+
if pieces.Length > 1 then
4793+
pieces.[0], Some (String.concat "," pieces.[1..])
4794+
else
4795+
pieces.[0], None
4796+
let scoref =
4797+
match rest with
4798+
| Some aname -> ILScopeRef.Assembly(ILAssemblyRef.FromAssemblyName(System.Reflection.AssemblyName(aname)))
4799+
| None -> ilg.traits.ScopeRef
4800+
47974801
let tref = mkILTyRef (scoref,unqualified_tname)
47984802
let tspec = mkILNonGenericTySpec tref
47994803
ILType.Value(tspec),sigptr

src/absil/il.fsi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,11 +1802,9 @@ val destTypeDefsWithGlobalFunctionsFirst: ILGlobals -> ILTypeDefs -> ILTypeDef l
18021802
/// Note: not all custom attribute data can be decoded without binding types. In particular
18031803
/// enums must be bound in order to discover the size of the underlying integer.
18041804
/// The following assumes enums have size int32.
1805-
/// It also does not completely decode System.Type attributes
18061805
val decodeILAttribData:
18071806
ILGlobals ->
18081807
ILAttribute ->
1809-
ILScopeRef option ->
18101808
ILAttribElem list * (* fixed args *)
18111809
ILAttributeNamedArg list (* named args: values and flags indicating if they are fields or properties *)
18121810

src/absil/ilmorph.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ let cattr_typ2typ ilg f c =
292292
// dev11 M3 defensive coding: if anything goes wrong with attribute decoding or encoding, then back out.
293293
if morphCustomAttributeData then
294294
try
295-
let elems,namedArgs = IL.decodeILAttribData ilg c (Some(meth.MethodRef.EnclosingTypeRef.Scope))
295+
let elems,namedArgs = IL.decodeILAttribData ilg c
296296
let elems = elems |> List.map (celem_typ2typ f)
297297
let namedArgs = namedArgs |> List.map (cnamedarg_typ2typ f)
298298
IL.mkILCustomAttribMethRef ilg (meth, elems, namedArgs)

src/fsharp/IlxGen.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5595,7 +5595,7 @@ and CreatePermissionSets g amap eenv (securityAttributes : Attrib list) =
55955595
let tref = tcref.CompiledRepresentationForNamedType
55965596
let ilattr = GenAttr amap g eenv attr
55975597
let _, ilNamedArgs =
5598-
match TryDecodeILAttribute g tref (Some(tref.Scope)) (mkILCustomAttrs [ilattr]) with
5598+
match TryDecodeILAttribute g tref (mkILCustomAttrs [ilattr]) with
55995599
| Some(ae,na) -> ae, na
56005600
| _ -> [],[]
56015601
let setArgs = ilNamedArgs |> List.map (fun (n,ilt,_,ilae) -> (n,ilt,ilae))

src/fsharp/TastOps.fs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,8 +2522,8 @@ let isILAttrib (tref:ILTypeRef) (attr: ILAttribute) =
25222522
// results of attribute lookups in the TAST
25232523
let HasILAttribute tref (attrs: ILAttributes) = List.exists (isILAttrib tref) attrs.AsList
25242524

2525-
let TryDecodeILAttribute g tref scope (attrs: ILAttributes) =
2526-
attrs.AsList |> List.tryPick(fun x -> if isILAttrib tref x then Some(decodeILAttribData g.ilg x scope) else None)
2525+
let TryDecodeILAttribute g tref (attrs: ILAttributes) =
2526+
attrs.AsList |> List.tryPick(fun x -> if isILAttrib tref x then Some(decodeILAttribData g.ilg x) else None)
25272527

25282528
// This one is done by name to ensure the compiler doesn't take a dependency on dereferencing a type that only exists in .NET 3.5
25292529
let ILThingHasExtensionAttribute (attrs : ILAttributes) =
@@ -2590,7 +2590,7 @@ let TryBindTyconRefAttribute g (m:range) (AttribInfo (atref,_) as args) (tcref:T
25902590
| None -> None
25912591
#endif
25922592
| ILTypeMetadata (_,tdef) ->
2593-
match TryDecodeILAttribute g atref (Some(atref.Scope)) tdef.CustomAttrs with
2593+
match TryDecodeILAttribute g atref tdef.CustomAttrs with
25942594
| Some attr -> f1 attr
25952595
| _ -> None
25962596
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata ->
@@ -6111,8 +6111,7 @@ let isTypeProviderAssemblyAttr (cattr:ILAttribute) =
61116111

61126112
let TryDecodeTypeProviderAssemblyAttr ilg (cattr:ILAttribute) =
61136113
if isTypeProviderAssemblyAttr cattr then
6114-
// ok to use ecmaILGlobals here since we're querying metadata, not making it
6115-
let parms, _args = decodeILAttribData ilg cattr None
6114+
let parms, _args = decodeILAttribData ilg cattr
61166115
match parms with // The first parameter to the attribute is the name of the assembly with the compiler extensions.
61176116
| (ILAttribElem.String (Some assemblyName))::_ -> Some assemblyName
61186117
| (ILAttribElem.String None)::_ -> Some null
@@ -6144,8 +6143,7 @@ let tref_AutoOpenAttr () = mkILTyRef(IlxSettings.ilxFsharpCoreLibScopeRef (), tn
61446143
let IsSignatureDataVersionAttr cattr = isILAttrib (tref_SignatureDataVersionAttr ()) cattr
61456144
let TryFindAutoOpenAttr (ilg : IL.ILGlobals) cattr =
61466145
if isILAttrib (tref_AutoOpenAttr ()) cattr then
6147-
// ok to use ecmaILGlobals here since we're querying metadata, not making it
6148-
match decodeILAttribData ilg cattr None with
6146+
match decodeILAttribData ilg cattr with
61496147
| [ILAttribElem.String s],_ -> s
61506148
| [],_ -> None
61516149
| _ ->
@@ -6159,8 +6157,7 @@ let tref_InternalsVisibleToAttr (ilg : IL.ILGlobals) =
61596157

61606158
let TryFindInternalsVisibleToAttr ilg cattr =
61616159
if isILAttrib (tref_InternalsVisibleToAttr ilg) cattr then
6162-
// ok to use ecmaILGlobals here since we're querying metadata, not making it
6163-
match decodeILAttribData ilg cattr None with
6160+
match decodeILAttribData ilg cattr with
61646161
| [ILAttribElem.String s],_ -> s
61656162
| [],_ -> None
61666163
| _ ->
@@ -6171,8 +6168,7 @@ let TryFindInternalsVisibleToAttr ilg cattr =
61716168

61726169
let IsMatchingSignatureDataVersionAttr ilg ((v1,v2,v3,_) : ILVersionInfo) cattr =
61736170
IsSignatureDataVersionAttr cattr &&
6174-
// ok to use ecmaILGlobals here since we're querying metadata, not making it
6175-
match decodeILAttribData ilg cattr None with
6171+
match decodeILAttribData ilg cattr with
61766172
| [ILAttribElem.Int32 u1; ILAttribElem.Int32 u2;ILAttribElem.Int32 u3 ],_ ->
61776173
(v1 = uint16 u1) && (v2 = uint16 u2) && (v3 = uint16 u3)
61786174
| _ ->

src/fsharp/TastOps.fsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ val mkLdelem : TcGlobals -> range -> TType -> Expr -> Expr -> Expr
11971197
// Analyze attribute sets
11981198
//-------------------------------------------------------------------------
11991199

1200-
val TryDecodeILAttribute : TcGlobals -> ILTypeRef -> ILScopeRef option -> ILAttributes -> (ILAttribElem list * ILAttributeNamedArg list) option
1200+
val TryDecodeILAttribute : TcGlobals -> ILTypeRef -> ILAttributes -> (ILAttribElem list * ILAttributeNamedArg list) option
12011201
val TryFindILAttribute : BuiltinAttribInfo -> ILAttributes -> bool
12021202
val TryFindILAttributeOpt : BuiltinAttribInfo option -> ILAttributes -> bool
12031203

src/fsharp/TypeChecker.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9764,7 +9764,7 @@ and TcAttribute cenv (env: TcEnv) attrTgt (synAttr: SynAttribute) =
97649764
let tdef = tcref.ILTyconRawMetadata
97659765
let tref = cenv.g.attrib_AttributeUsageAttribute.TypeRef
97669766

9767-
match TryDecodeILAttribute cenv.g tref (Some(tref.Scope)) tdef.CustomAttrs with
9767+
match TryDecodeILAttribute cenv.g tref tdef.CustomAttrs with
97689768
| Some ([ILAttribElem.Int32 validOn ],named) ->
97699769
let inherited =
97709770
match List.tryPick (function ("Inherited",_,_,ILAttribElem.Bool res) -> Some res | _ -> None) named with

src/fsharp/fsc.fsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ open Microsoft.FSharp.Compiler.TcGlobals
1111
open Microsoft.FSharp.Compiler.Tast
1212
open Microsoft.FSharp.Compiler.TypeChecker
1313

14-
type SigningInfo = SigningInfo of (* delaysign:*) bool * (*signer:*) string option * (*container:*) string option
15-
1614
[<AbstractClass>]
1715
type ErrorLoggerProvider =
1816
new : unit -> ErrorLoggerProvider
@@ -24,6 +22,8 @@ val internal ProcessCommandLineArgsAndImportAssemblies : (string -> unit) * stri
2422
#if NO_COMPILER_BACKEND
2523
#else
2624

25+
type SigningInfo = SigningInfo of (* delaysign:*) bool * (*signer:*) string option * (*container:*) string option
26+
2727
val EncodeInterfaceData: tcConfig:TcConfig * tcGlobals:TcGlobals * exportRemapping:Tastops.Remap * generatedCcu: Tast.CcuThunk * outfile: string -> ILAttribute list * ILResource list
2828
val ValidateKeySigningAttributes : tcConfig:TcConfig * tcGlobals:TcGlobals * TypeChecker.TopAttribs -> SigningInfo
2929
val GetSigner : SigningInfo -> ILBinaryWriter.ILStrongNameSigner option

src/fsharp/infos.fs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ type ILMethInfo =
763763
member x.IsDllImport g =
764764
match g.attrib_DllImportAttribute with
765765
| None -> false
766-
| Some (AttribInfo(tref,_)) ->x.RawMetadata.CustomAttrs |> TryDecodeILAttribute g tref (Some tref.Scope) |> isSome
766+
| Some (AttribInfo(tref,_)) ->x.RawMetadata.CustomAttrs |> TryDecodeILAttribute g tref |> isSome
767767

768768
/// Get the (zero or one) 'self'/'this'/'object' arguments associated with an IL method.
769769
/// An instance extension method returns one object argument.
@@ -1252,7 +1252,7 @@ type MethInfo =
12521252
[ [ for p in ilMethInfo.ParamMetadata do
12531253
let isParamArrayArg = TryFindILAttribute g.attrib_ParamArrayAttribute p.CustomAttrs
12541254
let reflArgInfo =
1255-
match TryDecodeILAttribute g g.attrib_ReflectedDefinitionAttribute.TypeRef (Some(g.attrib_ReflectedDefinitionAttribute.TypeRef.Scope)) p.CustomAttrs with
1255+
match TryDecodeILAttribute g g.attrib_ReflectedDefinitionAttribute.TypeRef p.CustomAttrs with
12561256
| Some ([ILAttribElem.Bool b ],_) -> ReflectedArgInfo.Quote b
12571257
| Some _ -> ReflectedArgInfo.Quote false
12581258
| _ -> ReflectedArgInfo.None
@@ -2651,7 +2651,7 @@ type AttribInfo =
26512651
let obj = evalFSharpAttribArg g evaluatedExpr
26522652
ty,obj)
26532653
| ILAttribInfo (g, amap, scoref, cattr, m) ->
2654-
let parms, _args = decodeILAttribData g.ilg cattr (Some scoref)
2654+
let parms, _args = decodeILAttribData g.ilg cattr
26552655
[ for (argty,argval) in Seq.zip cattr.Method.FormalArgTypes parms ->
26562656
let ty = ImportType scoref amap m [] argty
26572657
let obj = evalILAttribElem argval
@@ -2666,7 +2666,7 @@ type AttribInfo =
26662666
let obj = evalFSharpAttribArg g evaluatedExpr
26672667
ty, nm, isField, obj)
26682668
| ILAttribInfo (g, amap, scoref, cattr, m) ->
2669-
let _parms, namedArgs = decodeILAttribData g.ilg cattr (Some scoref)
2669+
let _parms, namedArgs = decodeILAttribData g.ilg cattr
26702670
[ for (nm, argty, isProp, argval) in namedArgs ->
26712671
let ty = ImportType scoref amap m [] argty
26722672
let obj = evalILAttribElem argval
@@ -2753,7 +2753,7 @@ module AttributeChecking =
27532753
| None -> None
27542754
#endif
27552755
| ILTypeMetadata (_,tdef) ->
2756-
match TryDecodeILAttribute g atref (Some(atref.Scope)) tdef.CustomAttrs with
2756+
match TryDecodeILAttribute g atref tdef.CustomAttrs with
27572757
| Some attr -> f1 attr
27582758
| _ -> None
27592759
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata ->
@@ -2782,7 +2782,7 @@ module AttributeChecking =
27822782
ignore f3
27832783
#endif
27842784
BindMethInfoAttributes m minfo
2785-
(fun ilAttribs -> TryDecodeILAttribute g atref (Some(atref.Scope)) ilAttribs |> Option.bind f1)
2785+
(fun ilAttribs -> TryDecodeILAttribute g atref ilAttribs |> Option.bind f1)
27862786
(fun fsAttribs -> TryFindFSharpAttribute g attribSpec fsAttribs |> Option.bind f2)
27872787
#if EXTENSIONTYPING
27882788
(fun provAttribs ->
@@ -2815,7 +2815,7 @@ module AttributeChecking =
28152815
/// Check IL attributes for 'ObsoleteAttribute', returning errors and warnings as data
28162816
let private CheckILAttributes g cattrs m =
28172817
let (AttribInfo(tref,_)) = g.attrib_SystemObsolete
2818-
match TryDecodeILAttribute g tref (Some(tref.Scope)) cattrs with
2818+
match TryDecodeILAttribute g tref cattrs with
28192819
| Some ([ILAttribElem.String (Some msg) ],_) ->
28202820
WarnD(ObsoleteWarning(msg,m))
28212821
| Some ([ILAttribElem.String (Some msg); ILAttribElem.Bool isError ],_) ->
@@ -2900,7 +2900,7 @@ module AttributeChecking =
29002900
/// Indicate if a list of IL attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense.
29012901
let CheckILAttributesForUnseen g cattrs _m =
29022902
let (AttribInfo(tref,_)) = g.attrib_SystemObsolete
2903-
isSome (TryDecodeILAttribute g tref (Some(tref.Scope)) cattrs)
2903+
isSome (TryDecodeILAttribute g tref cattrs)
29042904

29052905
/// Checks the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows
29062906
/// items to be suppressed from intellisense.

src/fsharp/vs/Symbols.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,8 +1737,8 @@ and FSharpAttribute(cenv: cenv, attrib: AttribInfo) =
17371737
match attrib with
17381738
| AttribInfo.FSAttribInfo(g, attrib) ->
17391739
NicePrint.stringOfFSAttrib (denv.Contents g) attrib
1740-
| AttribInfo.ILAttribInfo (g, _, scoref, cattr, _) ->
1741-
let parms, _args = decodeILAttribData g.ilg cattr (Some scoref)
1740+
| AttribInfo.ILAttribInfo (g, _, _scoref, cattr, _) ->
1741+
let parms, _args = decodeILAttribData g.ilg cattr
17421742
NicePrint.stringOfILAttrib (denv.Contents g) (cattr.Method.EnclosingType, parms)
17431743

17441744
override __.ToString() =

0 commit comments

Comments
 (0)