From 9255b943fb9f4f3931b3c4bb81f720f2b9623da4 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Tue, 18 Jun 2024 19:40:55 +0300 Subject: [PATCH 1/7] wip --- src/Compiler/AbstractIL/il.fs | 42 ++++++--- src/Compiler/AbstractIL/il.fsi | 20 +++- src/Compiler/AbstractIL/ilmorph.fs | 2 +- src/Compiler/AbstractIL/ilread.fs | 92 +++++++++++++++---- src/Compiler/Checking/NameResolution.fs | 5 +- src/Compiler/CodeGen/EraseClosures.fs | 8 +- src/Compiler/CodeGen/EraseUnions.fs | 4 +- src/Compiler/CodeGen/IlxGen.fs | 68 ++++++++------ ...ervice.SurfaceArea.netstandard20.debug.bsl | 14 ++- ...vice.SurfaceArea.netstandard20.release.bsl | 14 ++- .../ModuleReaderCancellationTests.fs | 6 +- 11 files changed, 199 insertions(+), 76 deletions(-) diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 48cee265fdc..66b736f87c3 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -1258,6 +1258,9 @@ let storeILCustomAttrs (attrs: ILAttributes) = else ILAttributesStored.Given attrs +let mkILCustomAttrsComputed f = + ILAttributesStored.Reader(fun _ -> f ()) + let mkILCustomAttrsReader f = ILAttributesStored.Reader f type ILCodeLabel = int @@ -2611,6 +2614,14 @@ let convertInitSemantics (init: ILTypeInit) = | ILTypeInit.BeforeField -> TypeAttributes.BeforeFieldInit | ILTypeInit.OnAny -> enum 0 +[] +type ILTypeDefAdditionalFlags = + | None = 0 + | IsKnownToBeAttribute = 1 + /// The type can contain extension methods, + /// or this information may not be available at the time the ILTypeDef is created + | CanContainExtensionMethods = 2 + [] type ILTypeDef ( @@ -2626,7 +2637,7 @@ type ILTypeDef methodImpls: ILMethodImplDefs, events: ILEventDefs, properties: ILPropertyDefs, - isKnownToBeAttribute: bool, + additionalFlags: ILTypeDefAdditionalFlags, securityDeclsStored: ILSecurityDeclsStored, customAttrsStored: ILAttributesStored, metadataIndex: int32 @@ -2634,6 +2645,8 @@ type ILTypeDef let mutable customAttrsStored = customAttrsStored + let hasFlag flag = additionalFlags &&& flag = flag + new(name, attributes, layout, @@ -2646,7 +2659,7 @@ type ILTypeDef methodImpls, events, properties, - isKnownToBeAttribute, + additionalFlags, securityDecls, customAttrs) = ILTypeDef( @@ -2662,9 +2675,9 @@ type ILTypeDef methodImpls, events, properties, - isKnownToBeAttribute, + additionalFlags, storeILSecurityDecls securityDecls, - storeILCustomAttrs customAttrs, + customAttrs, NoMetadataIdx ) @@ -2694,7 +2707,10 @@ type ILTypeDef member _.Properties = properties - member _.IsKnownToBeAttribute = isKnownToBeAttribute + member _.IsKnownToBeAttribute = hasFlag ILTypeDefAdditionalFlags.IsKnownToBeAttribute + + member _.CanContainExtensionMethods = + hasFlag ILTypeDefAdditionalFlags.CanContainExtensionMethods member _.CustomAttrsStored = customAttrsStored @@ -2714,7 +2730,7 @@ type ILTypeDef ?methodImpls, ?events, ?properties, - ?isKnownToBeAttribute, + ?newAdditionalFlags, ?customAttrs, ?securityDecls ) = @@ -2732,11 +2748,11 @@ type ILTypeDef methodImpls = defaultArg methodImpls x.MethodImpls, events = defaultArg events x.Events, properties = defaultArg properties x.Properties, - isKnownToBeAttribute = defaultArg isKnownToBeAttribute x.IsKnownToBeAttribute, - customAttrs = defaultArg customAttrs x.CustomAttrs + additionalFlags = defaultArg newAdditionalFlags additionalFlags, + customAttrs = defaultArg customAttrs (storeILCustomAttrs x.CustomAttrs) ) - member x.CustomAttrs = + member x.CustomAttrs: ILAttributes = match customAttrsStored with | ILAttributesStored.Reader f -> let res = ILAttributes(f x.MetadataIndex) @@ -4220,11 +4236,11 @@ let mkILGenericClass (nm, access, genparams, extends, impl, methods, fields, nes methods = methods, fields = fields, nestedTypes = nestedTypes, - customAttrs = attrs, + customAttrs = storeILCustomAttrs attrs, methodImpls = emptyILMethodImpls, properties = props, events = events, - isKnownToBeAttribute = false, + additionalFlags = ILTypeDefAdditionalFlags.None, securityDecls = emptyILSecurityDecls ) @@ -4244,11 +4260,11 @@ let mkRawDataValueTypeDef (iltyp_ValueType: ILType) (nm, size, pack) = methods = emptyILMethods, fields = emptyILFields, nestedTypes = emptyILTypeDefs, - customAttrs = emptyILCustomAttrs, + customAttrs = emptyILCustomAttrsStored, methodImpls = emptyILMethodImpls, properties = emptyILProperties, events = emptyILEvents, - isKnownToBeAttribute = false, + additionalFlags = ILTypeDefAdditionalFlags.None, securityDecls = emptyILSecurityDecls ) diff --git a/src/Compiler/AbstractIL/il.fsi b/src/Compiler/AbstractIL/il.fsi index 5e02f4c0c1e..d6673131060 100644 --- a/src/Compiler/AbstractIL/il.fsi +++ b/src/Compiler/AbstractIL/il.fsi @@ -4,6 +4,7 @@ module rec FSharp.Compiler.AbstractIL.IL +open System open FSharp.Compiler.IO open System.Collections.Generic open System.Reflection @@ -1481,6 +1482,12 @@ type ILTypeDefs = /// Calls to ExistsByName will result in all the ILPreTypeDefs being read. member internal ExistsByName: string -> bool +[] +type ILTypeDefAdditionalFlags = + | None = 0 + | IsKnownToBeAttribute = 1 + | CanContainExtensionMethods = 2 + /// Represents IL Type Definitions. [] type ILTypeDef = @@ -1499,7 +1506,7 @@ type ILTypeDef = methodImpls: ILMethodImplDefs * events: ILEventDefs * properties: ILPropertyDefs * - isKnownToBeAttribute: bool * + additionalFlags: ILTypeDefAdditionalFlags * securityDeclsStored: ILSecurityDeclsStored * customAttrsStored: ILAttributesStored * metadataIndex: int32 -> @@ -1519,9 +1526,9 @@ type ILTypeDef = methodImpls: ILMethodImplDefs * events: ILEventDefs * properties: ILPropertyDefs * - isKnownToBeAttribute: bool * + additionalFlags: ILTypeDefAdditionalFlags * securityDecls: ILSecurityDecls * - customAttrs: ILAttributes -> + customAttrs: ILAttributesStored -> ILTypeDef member Name: string @@ -1556,6 +1563,7 @@ type ILTypeDef = member HasSecurity: bool member Encoding: ILDefaultPInvokeEncoding member IsKnownToBeAttribute: bool + member CanContainExtensionMethods: bool member internal WithAccess: ILTypeDefAccess -> ILTypeDef member internal WithNestedAccess: ILMemberAccess -> ILTypeDef @@ -1584,8 +1592,8 @@ type ILTypeDef = ?methodImpls: ILMethodImplDefs * ?events: ILEventDefs * ?properties: ILPropertyDefs * - ?isKnownToBeAttribute: bool * - ?customAttrs: ILAttributes * + ?newAdditionalFlags: ILTypeDefAdditionalFlags * + ?customAttrs: ILAttributesStored * ?securityDecls: ILSecurityDecls -> ILTypeDef @@ -2212,8 +2220,10 @@ val internal mkILTypeForGlobalFunctions: ILScopeRef -> ILType val mkILCustomAttrs: ILAttribute list -> ILAttributes val mkILCustomAttrsFromArray: ILAttribute[] -> ILAttributes val storeILCustomAttrs: ILAttributes -> ILAttributesStored +val mkILCustomAttrsComputed: (unit -> ILAttribute[]) -> ILAttributesStored val internal mkILCustomAttrsReader: (int32 -> ILAttribute[]) -> ILAttributesStored val emptyILCustomAttrs: ILAttributes +val emptyILCustomAttrsStored: ILAttributesStored val mkILSecurityDecls: ILSecurityDecl list -> ILSecurityDecls val emptyILSecurityDecls: ILSecurityDecls diff --git a/src/Compiler/AbstractIL/ilmorph.fs b/src/Compiler/AbstractIL/ilmorph.fs index b4305791076..334ed93d212 100644 --- a/src/Compiler/AbstractIL/ilmorph.fs +++ b/src/Compiler/AbstractIL/ilmorph.fs @@ -378,7 +378,7 @@ let rec tdef_ty2ty_ilmbody2ilmbody_mdefs2mdefs isInKnownSet enc fs (tdef: ILType methodImpls = mimpls_ty2ty fTyInCtxtR tdef.MethodImpls, events = edefs_ty2ty fTyInCtxtR tdef.Events, properties = pdefs_ty2ty fTyInCtxtR tdef.Properties, - customAttrs = cattrs_ty2ty fTyInCtxtR tdef.CustomAttrs + customAttrs = storeILCustomAttrs (cattrs_ty2ty fTyInCtxtR tdef.CustomAttrs) ) and tdefs_ty2ty_ilmbody2ilmbody_mdefs2mdefs isInKnownSet enc fs tdefs = diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 61c04f8e4ba..81a653da069 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -2112,9 +2112,64 @@ and typeDefReader ctxtH : ILTypeDefStored = let layout = typeLayoutOfFlags ctxt mdv flags idx let hasLayout = - (match layout with - | ILTypeDefLayout.Explicit _ -> true - | _ -> false) + match layout with + | ILTypeDefLayout.Explicit _ -> true + | _ -> false + + let containsExtensionMethods = + let mutable containsExtensionMethods = false + let searchedKey = TaggedIndex(hca_TypeDef, idx) + + let attributesSearcher = + { new ISeekReadIndexedRowReader with + member _.GetRow(i, row) = + seekReadCustomAttributeRow ctxt mdv i &row + + member _.GetKey(row) = row + member _.CompareKey(key) = hcaCompare searchedKey key.parentIndex + member _.ConvertRow(row) = row + } + + let attrsStartIdx, attrsEndIdx = + seekReadIndexedRowsRange + (ctxt.getNumRows TableNames.CustomAttribute) + (isSorted ctxt TableNames.CustomAttribute) + attributesSearcher + + let hasAttributes = attrsStartIdx > 0 && attrsEndIdx >= attrsStartIdx + let mutable attrIdx = attrsStartIdx + + while hasAttributes && attrIdx <= attrsEndIdx && not containsExtensionMethods do + let mutable attr = Unchecked.defaultof<_> + attributesSearcher.GetRow(attrIdx, &attr) + let attrCtorIdx = attr.typeIndex.index + + let name = + if attr.typeIndex.tag = cat_MethodDef then + let idx = seekMethodDefParent ctxt attrCtorIdx + let _, nameIdx, namespaceIdx, _, _, _ = seekReadTypeDefRow ctxt idx + readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx) + else + let mrpTag, _, _ = seekReadMemberRefRow ctxt mdv attrCtorIdx + + if mrpTag.tag <> mrp_TypeRef then + "" + else + let _, nameIdx, namespaceIdx = seekReadTypeRefRow ctxt mdv mrpTag.index + readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx) + + if name = "System.Runtime.CompilerServices.ExtensionAttribute" then + containsExtensionMethods <- true + + attrIdx <- attrIdx + 1 + + containsExtensionMethods + + let additionalFlags = + if containsExtensionMethods then + ILTypeDefAdditionalFlags.CanContainExtensionMethods + else + ILTypeDefAdditionalFlags.None let mdefs = seekReadMethods ctxt numTypars methodsIdx endMethodsIdx let fdefs = seekReadFields ctxt (numTypars, hasLayout) fieldsIdx endFieldsIdx @@ -2138,7 +2193,7 @@ and typeDefReader ctxtH : ILTypeDefStored = methodImpls = mimpls, events = events, properties = props, - isKnownToBeAttribute = false, + additionalFlags = additionalFlags, customAttrsStored = ctxt.customAttrsReader_TypeDef, metadataIndex = idx )) @@ -2797,22 +2852,27 @@ and seekReadMemberRefAsFieldSpecUncached ctxtH (MemberRefAsFspecIdx(numTypars, i // method-range and field-range start/finish indexes and seekReadMethodDefAsMethodData ctxt idx = ctxt.seekReadMethodDefAsMethodData idx +and seekMethodDefParent (ctxt: ILMetadataReader) methodIdx = + seekReadIndexedRow ( + ctxt.getNumRows TableNames.TypeDef, + (fun i -> i, seekReadTypeDefRowWithExtents ctxt i), + id, + (fun (_, ((_, _, _, _, _, methodsIdx), (_, endMethodsIdx))) -> + if endMethodsIdx <= methodIdx then + 1 + elif methodsIdx <= methodIdx && methodIdx < endMethodsIdx then + 0 + else + -1), + true, + fst + ) + and seekReadMethodDefAsMethodDataUncached ctxtH idx = let (ctxt: ILMetadataReader) = getHole ctxtH let mdv = ctxt.mdfile.GetView() // Look for the method def parent. - let tidx = - seekReadIndexedRow ( - ctxt.getNumRows TableNames.TypeDef, - (fun i -> i, seekReadTypeDefRowWithExtents ctxt i), - id, - (fun (_, ((_, _, _, _, _, methodsIdx), (_, endMethodsIdx))) -> - if endMethodsIdx <= idx then 1 - elif methodsIdx <= idx && idx < endMethodsIdx then 0 - else -1), - true, - fst - ) + let tidx = seekMethodDefParent ctxt idx // Create a formal instantiation if needed let typeGenericArgs = seekReadGenericParams ctxt 0 (tomd_TypeDef, tidx) let typeGenericArgsCount = typeGenericArgs.Length diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 780824e3ead..6605ae861f2 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -524,7 +524,10 @@ let NextExtensionMethodPriority() = uint64 (newStamp()) /// Checks if the type is used for C# style extension members. let IsTyconRefUsedForCSharpStyleExtensionMembers g m (tcref: TyconRef) = // Type must be non-generic and have 'Extension' attribute - isNil(tcref.Typars m) && TyconRefHasAttribute g m g.attrib_ExtensionAttribute tcref + match metadataOfTycon tcref.Deref with + | ILTypeMetadata(TILObjectReprData(_, _, tdef)) -> tdef.CanContainExtensionMethods + | _ -> true + && isNil(tcref.Typars m) && TyconRefHasAttribute g m g.attrib_ExtensionAttribute tcref /// Checks if the type is used for C# style extension members. let IsTypeUsedForCSharpStyleExtensionMembers g m ty = diff --git a/src/Compiler/CodeGen/EraseClosures.fs b/src/Compiler/CodeGen/EraseClosures.fs index cf1499f0c30..7eddfd9b820 100644 --- a/src/Compiler/CodeGen/EraseClosures.fs +++ b/src/Compiler/CodeGen/EraseClosures.fs @@ -578,11 +578,11 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = extends = Some cenv.mkILTyFuncTy, methods = mkILMethods (ctorMethodDef :: nowApplyMethDef :: nowMethods), fields = mkILFields (mkILCloFldDefs cenv nowFields @ td.Fields.AsList()), - customAttrs = emptyILCustomAttrs, + customAttrs = emptyILCustomAttrsStored, methodImpls = emptyILMethodImpls, properties = emptyILProperties, events = emptyILEvents, - isKnownToBeAttribute = false, + additionalFlags = ILTypeDefAdditionalFlags.None, securityDecls = emptyILSecurityDecls ) .WithSpecialName(false) @@ -712,11 +712,11 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = extends = Some nowEnvParentClass, methods = mkILMethods (ctorMethodDef :: nowApplyMethDef :: nowMethods), fields = mkILFields (mkILCloFldDefs cenv nowFields @ td.Fields.AsList()), - customAttrs = emptyILCustomAttrs, + customAttrs = emptyILCustomAttrsStored, methodImpls = emptyILMethodImpls, properties = emptyILProperties, events = emptyILEvents, - isKnownToBeAttribute = false, + additionalFlags = ILTypeDefAdditionalFlags.None, securityDecls = emptyILSecurityDecls ) .WithHasSecurity(false) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index e21f76b3071..d5670ed3fdf 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -1452,8 +1452,8 @@ let mkClassUnionDef methodImpls = emptyILMethodImpls, events = emptyILEvents, properties = emptyILProperties, - isKnownToBeAttribute = false, - customAttrs = emptyILCustomAttrs + additionalFlags = ILTypeDefAdditionalFlags.None, + customAttrs = emptyILCustomAttrsStored ) .WithNestedAccess(cud.UnionCasesAccessibility) .WithAbstract(true) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 9be96f680b7..c152a0f239a 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -6202,19 +6202,21 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel yield fdef ] + let customAttrs = + [ + g.CompilerGeneratedAttribute + mkCompilationMappingAttr g (int SourceConstructFlags.Closure) + ] + |> mkILCustomAttrs + |> storeILCustomAttrs + let cloTypeDef = ILTypeDef( name = ilCloTypeRef.Name, layout = ILTypeDefLayout.Auto, attributes = enum 0, genericParams = ilCloGenericFormals, - customAttrs = - mkILCustomAttrs ( - [ - g.CompilerGeneratedAttribute - mkCompilationMappingAttr g (int SourceConstructFlags.Closure) - ] - ), + customAttrs = customAttrs, fields = mkILFields fdefs, events = emptyILEvents, properties = emptyILProperties, @@ -6223,7 +6225,7 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel nestedTypes = emptyILTypeDefs, implements = ilInterfaceTys, extends = Some super, - isKnownToBeAttribute = false, + additionalFlags = ILTypeDefAdditionalFlags.None, securityDecls = emptyILSecurityDecls ) .WithSealed(true) @@ -6636,13 +6638,18 @@ and GenClosureTypeDefs else mdefs, [] + let customAttrs = + attrs @ [ mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ] + |> mkILCustomAttrs + |> storeILCustomAttrs + let tdef = ILTypeDef( name = tref.Name, layout = ILTypeDefLayout.Auto, attributes = enum 0, genericParams = ilGenParams, - customAttrs = mkILCustomAttrs (attrs @ [ mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ]), + customAttrs = customAttrs, fields = mkILFields fdefs, events = emptyILEvents, properties = emptyILProperties, @@ -6651,7 +6658,7 @@ and GenClosureTypeDefs nestedTypes = emptyILTypeDefs, implements = ilIntfTys, extends = Some ext, - isKnownToBeAttribute = false, + additionalFlags = ILTypeDefAdditionalFlags.None, securityDecls = emptyILSecurityDecls ) .WithSealed(true) @@ -11327,8 +11334,9 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option | TILObjectRepr _ -> let tdef = tycon.ILTyconRawMetadata.WithAccess tyconAccess - let tdef = - tdef.With(customAttrs = mkILCustomAttrs ilCustomAttrs, genericParams = ilGenParams) + let customAttrs = ilCustomAttrs |> mkILCustomAttrs |> storeILCustomAttrs + + let tdef = tdef.With(customAttrs = customAttrs, genericParams = ilGenParams) tdef, None @@ -11364,6 +11372,12 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option let isKnownToBeAttribute = ExistsSameHeadTypeInHierarchy g cenv.amap m super g.mk_Attribute_ty + let additionalFlags = + if isKnownToBeAttribute then + ILTypeDefAdditionalFlags.IsKnownToBeAttribute + else + ILTypeDefAdditionalFlags.None + let tdef = mkILGenericClass ( ilTypeName, @@ -11389,7 +11403,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option .WithSerializable(isSerializable) .WithAbstract(isAbstract) .WithImport(isComInteropTy g thisTy) - .With(methodImpls = mkILMethodImpls methodImpls, isKnownToBeAttribute = isKnownToBeAttribute) + .With(methodImpls = mkILMethodImpls methodImpls, newAdditionalFlags = additionalFlags) let tdLayout, tdEncoding = match TryFindFSharpAttribute g g.attrib_StructLayoutAttribute tycon.Attribs with @@ -11524,19 +11538,19 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option ILTypeDefLayout.Auto let cattrs = - mkILCustomAttrs ( - ilCustomAttrs - @ [ - mkCompilationMappingAttr - g - (int ( - if hiddenRepr then - SourceConstructFlags.SumType ||| SourceConstructFlags.NonPublicRepresentation - else - SourceConstructFlags.SumType - )) - ] - ) + ilCustomAttrs + @ [ + mkCompilationMappingAttr + g + (int ( + if hiddenRepr then + SourceConstructFlags.SumType ||| SourceConstructFlags.NonPublicRepresentation + else + SourceConstructFlags.SumType + )) + ] + |> mkILCustomAttrs + |> storeILCustomAttrs let tdef = ILTypeDef( @@ -11559,7 +11573,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option else g.ilg.typ_Object ), - isKnownToBeAttribute = false, + additionalFlags = ILTypeDefAdditionalFlags.None, securityDecls = emptyILSecurityDecls ) .WithLayout(layout) diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl index 909e42e2cdc..b6a0f20fb13 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.debug.bsl @@ -1483,6 +1483,7 @@ FSharp.Compiler.AbstractIL.IL+ILType: System.String QualifiedName FSharp.Compiler.AbstractIL.IL+ILType: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILType: System.String get_BasicQualifiedName() FSharp.Compiler.AbstractIL.IL+ILType: System.String get_QualifiedName() +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean CanContainExtensionMethods FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean HasSecurity FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsAbstract FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsClass @@ -1496,6 +1497,7 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsSerializable FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsSpecialName FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsStruct FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsStructOrEnum +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean get_CanContainExtensionMethods() FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean get_HasSecurity() FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean get_IsAbstract() FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean get_IsClass() @@ -1525,7 +1527,7 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILPropertyDefs Properties FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILPropertyDefs get_Properties() FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILSecurityDecls SecurityDecls FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILSecurityDecls get_SecurityDecls() -FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDef With(Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.TypeAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodImplDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILEventDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILPropertyDefs], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILSecurityDecls]) +FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDef With(Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.TypeAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodImplDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILEventDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILPropertyDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILAttributesStored], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILSecurityDecls]) FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefAccess Access FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefAccess get_Access() FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefLayout Layout @@ -1543,7 +1545,7 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.Reflection.TypeAttributes get_At FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String Name FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String get_Name() -FSharp.Compiler.AbstractIL.IL+ILTypeDef: Void .ctor(System.String, System.Reflection.TypeAttributes, ILTypeDefLayout, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType], ILMethodDefs, ILTypeDefs, ILFieldDefs, ILMethodImplDefs, ILEventDefs, ILPropertyDefs, Boolean, ILSecurityDecls, ILAttributes) +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Void .ctor(System.String, System.Reflection.TypeAttributes, ILTypeDefLayout, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType], ILMethodDefs, ILTypeDefs, ILFieldDefs, ILMethodImplDefs, ILEventDefs, ILPropertyDefs, ILTypeDefAdditionalFlags, ILSecurityDecls, ILAttributesStored) FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Nested: ILMemberAccess Item FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Nested: ILMemberAccess get_Item() FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Tags: Int32 Nested @@ -1574,6 +1576,10 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess: Int32 GetHashCode(System.Collecti FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess: Int32 Tag FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess: Int32 get_Tag() FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess: System.String ToString() +FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags: ILTypeDefAdditionalFlags CanContainExtensionMethods +FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags: ILTypeDefAdditionalFlags IsKnownToBeAttribute +FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags: ILTypeDefAdditionalFlags None +FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags: Int32 value__ FSharp.Compiler.AbstractIL.IL+ILTypeDefKind+Tags: Int32 Class FSharp.Compiler.AbstractIL.IL+ILTypeDefKind+Tags: Int32 Delegate FSharp.Compiler.AbstractIL.IL+ILTypeDefKind+Tags: Int32 Enum @@ -1853,6 +1859,7 @@ FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILThisConvention FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILType FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDef FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess +FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefKind FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefs @@ -1866,6 +1873,9 @@ FSharp.Compiler.AbstractIL.IL: ILAttributes emptyILCustomAttrs FSharp.Compiler.AbstractIL.IL: ILAttributes get_emptyILCustomAttrs() FSharp.Compiler.AbstractIL.IL: ILAttributes mkILCustomAttrs(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILAttribute]) FSharp.Compiler.AbstractIL.IL: ILAttributes mkILCustomAttrsFromArray(ILAttribute[]) +FSharp.Compiler.AbstractIL.IL: ILAttributesStored emptyILCustomAttrsStored +FSharp.Compiler.AbstractIL.IL: ILAttributesStored get_emptyILCustomAttrsStored() +FSharp.Compiler.AbstractIL.IL: ILAttributesStored mkILCustomAttrsComputed(Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.IL+ILAttribute[]]) FSharp.Compiler.AbstractIL.IL: ILAttributesStored storeILCustomAttrs(ILAttributes) FSharp.Compiler.AbstractIL.IL: ILEventDefs emptyILEvents FSharp.Compiler.AbstractIL.IL: ILEventDefs get_emptyILEvents() diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl index 909e42e2cdc..b6a0f20fb13 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl @@ -1483,6 +1483,7 @@ FSharp.Compiler.AbstractIL.IL+ILType: System.String QualifiedName FSharp.Compiler.AbstractIL.IL+ILType: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILType: System.String get_BasicQualifiedName() FSharp.Compiler.AbstractIL.IL+ILType: System.String get_QualifiedName() +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean CanContainExtensionMethods FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean HasSecurity FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsAbstract FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsClass @@ -1496,6 +1497,7 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsSerializable FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsSpecialName FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsStruct FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean IsStructOrEnum +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean get_CanContainExtensionMethods() FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean get_HasSecurity() FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean get_IsAbstract() FSharp.Compiler.AbstractIL.IL+ILTypeDef: Boolean get_IsClass() @@ -1525,7 +1527,7 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILPropertyDefs Properties FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILPropertyDefs get_Properties() FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILSecurityDecls SecurityDecls FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILSecurityDecls get_SecurityDecls() -FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDef With(Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.TypeAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodImplDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILEventDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILPropertyDefs], Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILSecurityDecls]) +FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDef With(Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.TypeAttributes], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef]], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILFieldDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILMethodImplDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILEventDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILPropertyDefs], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILAttributesStored], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILSecurityDecls]) FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefAccess Access FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefAccess get_Access() FSharp.Compiler.AbstractIL.IL+ILTypeDef: ILTypeDefLayout Layout @@ -1543,7 +1545,7 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.Reflection.TypeAttributes get_At FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String Name FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String ToString() FSharp.Compiler.AbstractIL.IL+ILTypeDef: System.String get_Name() -FSharp.Compiler.AbstractIL.IL+ILTypeDef: Void .ctor(System.String, System.Reflection.TypeAttributes, ILTypeDefLayout, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType], ILMethodDefs, ILTypeDefs, ILFieldDefs, ILMethodImplDefs, ILEventDefs, ILPropertyDefs, Boolean, ILSecurityDecls, ILAttributes) +FSharp.Compiler.AbstractIL.IL+ILTypeDef: Void .ctor(System.String, System.Reflection.TypeAttributes, ILTypeDefLayout, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILType], Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILGenericParameterDef], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.AbstractIL.IL+ILType], ILMethodDefs, ILTypeDefs, ILFieldDefs, ILMethodImplDefs, ILEventDefs, ILPropertyDefs, ILTypeDefAdditionalFlags, ILSecurityDecls, ILAttributesStored) FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Nested: ILMemberAccess Item FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Nested: ILMemberAccess get_Item() FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess+Tags: Int32 Nested @@ -1574,6 +1576,10 @@ FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess: Int32 GetHashCode(System.Collecti FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess: Int32 Tag FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess: Int32 get_Tag() FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess: System.String ToString() +FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags: ILTypeDefAdditionalFlags CanContainExtensionMethods +FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags: ILTypeDefAdditionalFlags IsKnownToBeAttribute +FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags: ILTypeDefAdditionalFlags None +FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags: Int32 value__ FSharp.Compiler.AbstractIL.IL+ILTypeDefKind+Tags: Int32 Class FSharp.Compiler.AbstractIL.IL+ILTypeDefKind+Tags: Int32 Delegate FSharp.Compiler.AbstractIL.IL+ILTypeDefKind+Tags: Int32 Enum @@ -1853,6 +1859,7 @@ FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILThisConvention FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILType FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDef FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefAccess +FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefAdditionalFlags FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefKind FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefLayout FSharp.Compiler.AbstractIL.IL: FSharp.Compiler.AbstractIL.IL+ILTypeDefs @@ -1866,6 +1873,9 @@ FSharp.Compiler.AbstractIL.IL: ILAttributes emptyILCustomAttrs FSharp.Compiler.AbstractIL.IL: ILAttributes get_emptyILCustomAttrs() FSharp.Compiler.AbstractIL.IL: ILAttributes mkILCustomAttrs(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.AbstractIL.IL+ILAttribute]) FSharp.Compiler.AbstractIL.IL: ILAttributes mkILCustomAttrsFromArray(ILAttribute[]) +FSharp.Compiler.AbstractIL.IL: ILAttributesStored emptyILCustomAttrsStored +FSharp.Compiler.AbstractIL.IL: ILAttributesStored get_emptyILCustomAttrsStored() +FSharp.Compiler.AbstractIL.IL: ILAttributesStored mkILCustomAttrsComputed(Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,FSharp.Compiler.AbstractIL.IL+ILAttribute[]]) FSharp.Compiler.AbstractIL.IL: ILAttributesStored storeILCustomAttrs(ILAttributes) FSharp.Compiler.AbstractIL.IL: ILEventDefs emptyILEvents FSharp.Compiler.AbstractIL.IL: ILEventDefs get_emptyILEvents() diff --git a/tests/FSharp.Compiler.Service.Tests/ModuleReaderCancellationTests.fs b/tests/FSharp.Compiler.Service.Tests/ModuleReaderCancellationTests.fs index 560dbceeb66..8038cb8ad38 100644 --- a/tests/FSharp.Compiler.Service.Tests/ModuleReaderCancellationTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/ModuleReaderCancellationTests.fs @@ -115,10 +115,10 @@ type PreTypeDefData = mkILMethods [] let typeAttributes = TypeAttributes.Public - let customAttrs = mkILCustomAttrs [] + ILTypeDef(this.Name, typeAttributes, ILTypeDefLayout.Auto, [], [], - None, methodsDefs, mkILTypeDefs [], mkILFields [], emptyILMethodImpls, mkILEvents [], mkILProperties [], false, - emptyILSecurityDecls, customAttrs) + None, methodsDefs, mkILTypeDefs [], mkILFields [], emptyILMethodImpls, mkILEvents [], mkILProperties [], + ILTypeDefAdditionalFlags.None, emptyILSecurityDecls, emptyILCustomAttrsStored) type PreTypeDef(data: PreTypeDefData) = let typeDef = data.TypeDef From 6a308135b4e29ac70175517953805593d305abc2 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Wed, 19 Jun 2024 16:32:23 +0300 Subject: [PATCH 2/7] release notes --- docs/release-notes/.FSharp.Compiler.Service/8.0.400.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md index 9033ff771f8..b8ffafff4c1 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md +++ b/docs/release-notes/.FSharp.Compiler.Service/8.0.400.md @@ -31,3 +31,4 @@ * Reduce allocations in compiler checking via `ValueOption` usage ([PR #16822](https://github.com/dotnet/fsharp/pull/16822)) * Use AsyncLocal instead of ThreadStatic to hold Cancellable.Token ([PR #17156](https://github.com/dotnet/fsharp/pull/17156)) * Showing and inserting correct name of entities from unopened namespace/module ([Issue #14375](https://github.com/dotnet/fsharp/issues/14375), [PR #17261](https://github.com/dotnet/fsharp/pull/17261)) +* Support lazy custom attributes calculation for `ILTypeDef` public API, improve `ExtensionAttribute` presence detecting perf. ([PR #16168](https://github.com/dotnet/fsharp/pull/16168)) From 860b97aab689ce6b58d0992ae5bebc3063886671 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Fri, 21 Jun 2024 04:14:22 +0300 Subject: [PATCH 3/7] wip --- src/Compiler/AbstractIL/ilread.fs | 49 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 81a653da069..04e1d8886db 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -2136,34 +2136,37 @@ and typeDefReader ctxtH : ILTypeDefStored = (isSorted ctxt TableNames.CustomAttribute) attributesSearcher - let hasAttributes = attrsStartIdx > 0 && attrsEndIdx >= attrsStartIdx - let mutable attrIdx = attrsStartIdx - - while hasAttributes && attrIdx <= attrsEndIdx && not containsExtensionMethods do - let mutable attr = Unchecked.defaultof<_> - attributesSearcher.GetRow(attrIdx, &attr) - let attrCtorIdx = attr.typeIndex.index - - let name = - if attr.typeIndex.tag = cat_MethodDef then - let idx = seekMethodDefParent ctxt attrCtorIdx - let _, nameIdx, namespaceIdx, _, _, _ = seekReadTypeDefRow ctxt idx - readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx) - else - let mrpTag, _, _ = seekReadMemberRefRow ctxt mdv attrCtorIdx + if attrsStartIdx <= 0 || attrsEndIdx < attrsStartIdx then + false + else - if mrpTag.tag <> mrp_TypeRef then - "" - else - let _, nameIdx, namespaceIdx = seekReadTypeRefRow ctxt mdv mrpTag.index + let mutable attrIdx = attrsStartIdx + + while attrIdx <= attrsEndIdx && not containsExtensionMethods do + let mutable attr = Unchecked.defaultof<_> + attributesSearcher.GetRow(attrIdx, &attr) + let attrCtorIdx = attr.typeIndex.index + + let name = + if attr.typeIndex.tag = cat_MethodDef then + let idx = seekMethodDefParent ctxt attrCtorIdx + let _, nameIdx, namespaceIdx, _, _, _ = seekReadTypeDefRow ctxt idx readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx) + else + let mrpTag, _, _ = seekReadMemberRefRow ctxt mdv attrCtorIdx + + if mrpTag.tag <> mrp_TypeRef then + "" + else + let _, nameIdx, namespaceIdx = seekReadTypeRefRow ctxt mdv mrpTag.index + readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx) - if name = "System.Runtime.CompilerServices.ExtensionAttribute" then - containsExtensionMethods <- true + if name = "System.Runtime.CompilerServices.ExtensionAttribute" then + containsExtensionMethods <- true - attrIdx <- attrIdx + 1 + attrIdx <- attrIdx + 1 - containsExtensionMethods + containsExtensionMethods let additionalFlags = if containsExtensionMethods then From 5f8d1db3d73775ac285105db2e2a95d8849c60ac Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Fri, 21 Jun 2024 10:00:15 +0300 Subject: [PATCH 4/7] optimize --- src/Compiler/AbstractIL/ilread.fs | 48 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 04e1d8886db..9381c331f00 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -2121,13 +2121,16 @@ and typeDefReader ctxtH : ILTypeDefStored = let searchedKey = TaggedIndex(hca_TypeDef, idx) let attributesSearcher = - { new ISeekReadIndexedRowReader with - member _.GetRow(i, row) = - seekReadCustomAttributeRow ctxt mdv i &row + { new ISeekReadIndexedRowReader with + member _.GetRow(i, rowIndex) = rowIndex <- i + member _.GetKey(rowIndex) = rowIndex - member _.GetKey(row) = row - member _.CompareKey(key) = hcaCompare searchedKey key.parentIndex - member _.ConvertRow(row) = row + member _.CompareKey(rowIndex) = + let mutable addr = ctxt.rowAddr TableNames.CustomAttribute rowIndex + let key = seekReadHasCustomAttributeIdx ctxt mdv &addr + hcaCompare searchedKey key + + member _.ConvertRow(i) = i } let attrsStartIdx, attrsEndIdx = @@ -2139,21 +2142,21 @@ and typeDefReader ctxtH : ILTypeDefStored = if attrsStartIdx <= 0 || attrsEndIdx < attrsStartIdx then false else - let mutable attrIdx = attrsStartIdx while attrIdx <= attrsEndIdx && not containsExtensionMethods do - let mutable attr = Unchecked.defaultof<_> - attributesSearcher.GetRow(attrIdx, &attr) - let attrCtorIdx = attr.typeIndex.index + let mutable addr = ctxt.rowAddr TableNames.CustomAttribute attrIdx + seekReadHasCustomAttributeIdx ctxt mdv &addr |> ignore + let attrTypeIndex = seekReadCustomAttributeTypeIdx ctxt mdv &addr + let attrCtorIdx = attrTypeIndex.index let name = - if attr.typeIndex.tag = cat_MethodDef then - let idx = seekMethodDefParent ctxt attrCtorIdx - let _, nameIdx, namespaceIdx, _, _, _ = seekReadTypeDefRow ctxt idx + if attrTypeIndex.tag = cat_MethodDef then + let _, (_, nameIdx, namespaceIdx, _, _, _) = seekMethodDefParent ctxt attrCtorIdx readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx) else - let mrpTag, _, _ = seekReadMemberRefRow ctxt mdv attrCtorIdx + let mutable addr = ctxt.rowAddr TableNames.MemberRef attrCtorIdx + let mrpTag = seekReadMemberRefParentIdx ctxt mdv &addr if mrpTag.tag <> mrp_TypeRef then "" @@ -2858,24 +2861,23 @@ and seekReadMethodDefAsMethodData ctxt idx = ctxt.seekReadMethodDefAsMethodData and seekMethodDefParent (ctxt: ILMetadataReader) methodIdx = seekReadIndexedRow ( ctxt.getNumRows TableNames.TypeDef, - (fun i -> i, seekReadTypeDefRowWithExtents ctxt i), + (fun i -> i, seekReadTypeDefRow ctxt i), id, - (fun (_, ((_, _, _, _, _, methodsIdx), (_, endMethodsIdx))) -> - if endMethodsIdx <= methodIdx then - 1 - elif methodsIdx <= methodIdx && methodIdx < endMethodsIdx then - 0 + (fun (i, (_, _, _, _, _, methodsIdx as info)) -> + if methodsIdx > methodIdx then + -1 else - -1), + let struct (_, endMethodsIdx) = seekReadTypeDefRowExtents ctxt info i + if endMethodsIdx <= methodIdx then 1 else 0), true, - fst + id ) and seekReadMethodDefAsMethodDataUncached ctxtH idx = let (ctxt: ILMetadataReader) = getHole ctxtH let mdv = ctxt.mdfile.GetView() // Look for the method def parent. - let tidx = seekMethodDefParent ctxt idx + let tidx, _ = seekMethodDefParent ctxt idx // Create a formal instantiation if needed let typeGenericArgs = seekReadGenericParams ctxt 0 (tomd_TypeDef, tidx) let typeGenericArgsCount = typeGenericArgs.Length From 385cb520f83302310841b875936d4e3a34d92ce3 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Fri, 21 Jun 2024 12:13:41 +0300 Subject: [PATCH 5/7] opt --- src/Compiler/AbstractIL/ilread.fs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 9381c331f00..5f333fd2bd2 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -2144,6 +2144,11 @@ and typeDefReader ctxtH : ILTypeDefStored = else let mutable attrIdx = attrsStartIdx + let looksLikeSystemAssembly = + ctxt.fileName.EndsWith("System.Runtime.dll") + || ctxt.fileName.EndsWith("mscorlib.dll") + || ctxt.fileName.EndsWith("netstandard.dll") + while attrIdx <= attrsEndIdx && not containsExtensionMethods do let mutable addr = ctxt.rowAddr TableNames.CustomAttribute attrIdx seekReadHasCustomAttributeIdx ctxt mdv &addr |> ignore @@ -2152,8 +2157,11 @@ and typeDefReader ctxtH : ILTypeDefStored = let name = if attrTypeIndex.tag = cat_MethodDef then - let _, (_, nameIdx, namespaceIdx, _, _, _) = seekMethodDefParent ctxt attrCtorIdx - readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx) + if not looksLikeSystemAssembly then + "" + else + let _, (_, nameIdx, namespaceIdx, _, _, _) = seekMethodDefParent ctxt attrCtorIdx + readBlobHeapAsTypeName ctxt (nameIdx, namespaceIdx) else let mutable addr = ctxt.rowAddr TableNames.MemberRef attrCtorIdx let mrpTag = seekReadMemberRefParentIdx ctxt mdv &addr From 295844f3f60732f429b56931905c538c764f7de6 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Wed, 26 Jun 2024 03:55:39 +0300 Subject: [PATCH 6/7] do not copy structs on compare --- src/Compiler/AbstractIL/ilread.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 5f333fd2bd2..f1d6d52767f 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -858,10 +858,10 @@ let hsCompare (TaggedIndex(t1: HasSemanticsTag, idx1: int)) (TaggedIndex(t2: Has elif idx1 > idx2 then 1 else compare t1.Tag t2.Tag -let hcaCompare (TaggedIndex(t1: HasCustomAttributeTag, idx1: int)) (TaggedIndex(t2: HasCustomAttributeTag, idx2)) = - if idx1 < idx2 then -1 - elif idx1 > idx2 then 1 - else compare t1.Tag t2.Tag +let inline hcaCompare (t1: TaggedIndex) (t2: TaggedIndex) = + if t1.index < t2.index then -1 + elif t1.index > t2.index then 1 + else compare t1.tag t2.tag let mfCompare (TaggedIndex(t1: MemberForwardedTag, idx1: int)) (TaggedIndex(t2: MemberForwardedTag, idx2)) = if idx1 < idx2 then -1 From f218af4eb896cd3ea8604eaa95f359445be508f2 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Wed, 26 Jun 2024 06:00:19 +0300 Subject: [PATCH 7/7] some comments --- src/Compiler/AbstractIL/ilread.fs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index f1d6d52767f..1535078bfe0 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -2127,6 +2127,7 @@ and typeDefReader ctxtH : ILTypeDefStored = member _.CompareKey(rowIndex) = let mutable addr = ctxt.rowAddr TableNames.CustomAttribute rowIndex + // read parentIndex let key = seekReadHasCustomAttributeIdx ctxt mdv &addr hcaCompare searchedKey key @@ -2151,12 +2152,15 @@ and typeDefReader ctxtH : ILTypeDefStored = while attrIdx <= attrsEndIdx && not containsExtensionMethods do let mutable addr = ctxt.rowAddr TableNames.CustomAttribute attrIdx + // skip parentIndex to read typeIndex seekReadHasCustomAttributeIdx ctxt mdv &addr |> ignore let attrTypeIndex = seekReadCustomAttributeTypeIdx ctxt mdv &addr let attrCtorIdx = attrTypeIndex.index let name = if attrTypeIndex.tag = cat_MethodDef then + // the ExtensionAttribute constructor can be cat_MethodDef if the metadata is read from the assembly + // in which the corresponding attribute is defined -- from the system library if not looksLikeSystemAssembly then "" else