Skip to content

ProjectFcsModuleReader: support lazy InterfaceImpls calculation #720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@
let mkDummyTypeDef (name: string) =
let attributes = enum 0
let layout = ILTypeDefLayout.Auto
let implements = []
let implements = emptyILInterfaceImpls

Check failure on line 173 in ReSharper.FSharp/src/FSharp/FSharp.Common/src/Shim/AssemblyReader/ProjectFcsModuleReader.fs

View workflow job for this annotation

GitHub Actions / test-backend (windows-latest)

The value or constructor 'emptyILInterfaceImpls' is not defined. Maybe you want one of the following:� emptyILCustomAttrsStored� emptyILProperties� emptyILFields� EmptyQualifier� emptyILTypeDefs

Check failure on line 173 in ReSharper.FSharp/src/FSharp/FSharp.Common/src/Shim/AssemblyReader/ProjectFcsModuleReader.fs

View workflow job for this annotation

GitHub Actions / test-backend (windows-latest)

The value or constructor 'emptyILInterfaceImpls' is not defined. Maybe you want one of the following:� emptyILCustomAttrsStored� emptyILProperties� emptyILFields� EmptyQualifier� emptyILTypeDefs
let genericParams = []
let extends = None
let nestedTypes = emptyILTypeDefs

ILTypeDef(name, attributes, layout, implements, None, genericParams, extends, emptyILMethods, nestedTypes,
ILTypeDef(name, attributes, layout, emptyILInterfaceImpls, genericParams, extends, emptyILMethods, nestedTypes,

Check failure on line 178 in ReSharper.FSharp/src/FSharp/FSharp.Common/src/Shim/AssemblyReader/ProjectFcsModuleReader.fs

View workflow job for this annotation

GitHub Actions / test-backend (windows-latest)

The value or constructor 'emptyILInterfaceImpls' is not defined. Maybe you want one of the following:� emptyILCustomAttrsStored� emptyILProperties� emptyILFields� EmptyQualifier� emptyILTypeDefs

Check failure on line 178 in ReSharper.FSharp/src/FSharp/FSharp.Common/src/Shim/AssemblyReader/ProjectFcsModuleReader.fs

View workflow job for this annotation

GitHub Actions / test-backend (windows-latest)

The object constructor 'ILTypeDef' takes 16 argument(s) but is here given 15. The required signature is 'new: name: string * attributes: TypeAttributes * layout: ILTypeDefLayout * implements: ILTypes * implementsCustomAttrs: (ILAttributesStored * int) list option * genericParams: ILGenericParameterDefs * extends: ILType option * methods: ILMethodDefs * nestedTypes: ILTypeDefs * fields: ILFieldDefs * methodImpls: ILMethodImplDefs * events: ILEventDefs * properties: ILPropertyDefs * additionalFlags: ILTypeDefAdditionalFlags * securityDecls: ILSecurityDecls * customAttrs: ILAttributesStored -> ILTypeDef'.

Check failure on line 178 in ReSharper.FSharp/src/FSharp/FSharp.Common/src/Shim/AssemblyReader/ProjectFcsModuleReader.fs

View workflow job for this annotation

GitHub Actions / test-backend (windows-latest)

The value or constructor 'emptyILInterfaceImpls' is not defined. Maybe you want one of the following:� emptyILCustomAttrsStored� emptyILProperties� emptyILFields� EmptyQualifier� emptyILTypeDefs
emptyILFields, emptyILMethodImpls, emptyILEvents, emptyILProperties, ILTypeDefAdditionalFlags.None,
emptyILSecurityDecls, emptyILCustomAttrsStored)

Expand Down Expand Up @@ -484,7 +484,9 @@
let mkTypeDefImplements (typeElement: ITypeElement) =
[ for declaredType in typeElement.GetSuperTypesWithoutCircularDependent() do
if declaredType.GetTypeElement() :? IInterface then
mkType declaredType ]
// TODO: Interface implementation can have attributes on it (not expressible in F#/C#, but in IL it is)
// and C# nullness metadata export makes use of it.
InterfaceImpl.Create(mkType declaredType) ]

Check failure on line 489 in ReSharper.FSharp/src/FSharp/FSharp.Common/src/Shim/AssemblyReader/ProjectFcsModuleReader.fs

View workflow job for this annotation

GitHub Actions / test-backend (windows-latest)

The value, namespace, type or module 'InterfaceImpl' is not defined. Maybe you want one of the following:� InterfaceMapping� Interfaces� Interface� InterfaceEx� Interactive

let mkCompilerGeneratedAttribute (attrTypeName: IClrTypeName) (args: ILAttribElem list): ILAttribute option =
let attrType = TypeFactory.CreateTypeByCLRName(attrTypeName, psiModule, true)
Expand Down Expand Up @@ -1136,14 +1138,22 @@

List.forall2 isUpToDatePropertyDef properties propertyDefs

let isUpToDateInterfaceImpls (typeElement: ITypeElement) (typeDef: ILTypeDef) =
let expected = typeDef.Implements
if not expected.IsValueCreated then true else

Check failure on line 1143 in ReSharper.FSharp/src/FSharp/FSharp.Common/src/Shim/AssemblyReader/ProjectFcsModuleReader.fs

View workflow job for this annotation

GitHub Actions / test-backend (windows-latest)

The type 'List<_>' does not define the field, constructor or member 'IsValueCreated'.

let actual = mkTypeDefImplements typeElement

(expected.Value, actual)

Check failure on line 1147 in ReSharper.FSharp/src/FSharp/FSharp.Common/src/Shim/AssemblyReader/ProjectFcsModuleReader.fs

View workflow job for this annotation

GitHub Actions / test-backend (windows-latest)

The type 'List<_>' does not define the field, constructor or member 'Value'.
||> List.forall2 (fun i1 i2 -> i1.Type = i2.Type)

let rec isUpToDateTypeDef (typeElement: ITypeElement) (fcsTypeDef: FcsTypeDef) =
let typeDef = fcsTypeDef.TypeDef

let extends = mkTypeDefExtends typeElement
extends = typeDef.Extends &&

let implements = mkTypeDefImplements typeElement
implements = typeDef.Implements &&
isUpToDateInterfaceImpls typeElement typeDef &&

isUpToDateTypeParamDefs typeElement.TypeParameters typeDef.GenericParams &&
isUpToDateTypeDefCustomAttributes typeElement typeDef &&
Expand Down Expand Up @@ -1250,11 +1260,11 @@
let name = mkTypeDefName typeElement clrTypeName
let typeAttributes = mkTypeAttributes typeElement
let extends = mkTypeDefExtends typeElement
let implements = mkTypeDefImplements typeElement
let genericParams = mkGenericParamDefs typeElement

// todo: pass this table in nested types too?
let membersTable = FcsTypeDefMembers.Create()
let implements = InterruptibleLazy (fun _ -> usingTypeElement clrTypeName [] mkTypeDefImplements)
let nestedTypes = mkILTypeDefsComputed (fun _ -> getOrCreateNestedTypes membersTable this clrTypeName)
let methods = mkILMethodsComputed (fun _ -> getOrCreateMethods membersTable clrTypeName)
let fields = mkILFieldsLazy (InterruptibleLazy(fun _ -> getOrCreateFields membersTable clrTypeName))
Expand All @@ -1265,14 +1275,13 @@
let customAttrs = mkILCustomAttrsComputed (fun _ ->
usingTypeElement clrTypeName [||] mkTypeDefCustomAttrs
)
let implementsCustomAttrs = None // todo

let additionalFlags =
if hasExtensions then ILTypeDefAdditionalFlags.CanContainExtensionMethods
else ILTypeDefAdditionalFlags.None

let typeDef =
ILTypeDef(name, typeAttributes, ILTypeDefLayout.Auto, implements, implementsCustomAttrs,
ILTypeDef(name, typeAttributes, ILTypeDefLayout.Auto, implements,

Check failure on line 1284 in ReSharper.FSharp/src/FSharp/FSharp.Common/src/Shim/AssemblyReader/ProjectFcsModuleReader.fs

View workflow job for this annotation

GitHub Actions / test-backend (windows-latest)

The object constructor 'ILTypeDef' takes 16 argument(s) but is here given 15. The required signature is 'new: name: string * attributes: TypeAttributes * layout: ILTypeDefLayout * implements: ILTypes * implementsCustomAttrs: (ILAttributesStored * int) list option * genericParams: ILGenericParameterDefs * extends: ILType option * methods: ILMethodDefs * nestedTypes: ILTypeDefs * fields: ILFieldDefs * methodImpls: ILMethodImplDefs * events: ILEventDefs * properties: ILPropertyDefs * additionalFlags: ILTypeDefAdditionalFlags * securityDecls: ILSecurityDecls * customAttrs: ILAttributesStored -> ILTypeDef'.
genericParams, extends, methods, nestedTypes, fields, emptyILMethodImpls, events, properties,
additionalFlags, emptyILSecurityDecls, customAttrs)

Expand Down
Loading