diff --git a/src/ProvidedTypes.fs b/src/ProvidedTypes.fs index faf955d..26ee965 100644 --- a/src/ProvidedTypes.fs +++ b/src/ProvidedTypes.fs @@ -177,7 +177,7 @@ module Utils = let gtype = typedefof>.MakeGenericType([| typ |]) // the Empty member is private due to the presence of the fsi file // but when getting rid of the fsi for diagnostic purpose, it becomes public - // this is the reason for having both Public and NonPublic flag bellow + // this is the reason for having both Public and NonPublic flag below let gmethod = gtype.GetMethod("Empty", BindingFlags.Static ||| BindingFlags.Public ||| BindingFlags.NonPublic) gmethod.Invoke(null, [||]) :?> obj array @@ -322,7 +322,7 @@ module Utils = // // - However, these quotation values are a bit fragile. Using existing FSharp.Core.Quotations.Patterns // active patterns on these quotation nodes will generally work correctly. But using ExprShape.RebuildShapeCombination -// on these new nodes will not succed, nor will operations that build new quotations such as Expr.Call. +// on these new nodes will not succeed, nor will operations that build new quotations such as Expr.Call. // Instead, use the replacement provided in this module. // // - Likewise, some operations in these quotation values like "expr.Type" may be a bit fragile, possibly returning non cross-targeted types in @@ -774,7 +774,7 @@ type ProvidedTypeSymbol(kind: ProvidedTypeSymbolKind, typeArgs: Type list, typeB | ProvidedTypeSymbolKind.Generic gty -> gty.MetadataToken | ProvidedTypeSymbolKind.FSharpTypeAbbreviation _ -> typeof.MetadataToken - override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegting implementation of this, and we are self-delegating + override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegating implementation of this, and we are self-delegating override this.ToString() = this.FullName @@ -888,12 +888,12 @@ module Misc = let mutable hasReflectedDefinition = false // XML doc text that we only compute once, if any. This must _not_ be forced until the ConstructorArguments - // property of the custom attribute is foced. + // property of the custom attribute is forced. let xmlDocDelayedText = lazy (match xmlDocDelayed with None -> assert false; "" | Some f -> f()) - // Custom atttributes that we only compute once + // Custom attributes that we only compute once let customAttributesOnce = lazy [| @@ -1725,8 +1725,8 @@ and ProvidedTypeDefinition(isTgt: bool, container:TypeContainer, className: stri override __.GetElementType() = notRequired this "Module" this.Name override __.InvokeMember(_name, _invokeAttr, _binder, _target, _args, _modifiers, _culture, _namedParameters) = notRequired this "Module" this.Name override __.AssemblyQualifiedName = notRequired this "Module" this.Name - // Needed because TypeDelegator.cs provides a delegting implementation of this, and we are self-delegating - override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegting implementation of this, and we are self-delegating + // Needed because TypeDelegator.cs provides a delegating implementation of this, and we are self-delegating + override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegating implementation of this, and we are self-delegating // Get the model member __.BelongsToTargetModel = isTgt @@ -1912,7 +1912,7 @@ and ProvidedTypeDefinition(isTgt: bool, container:TypeContainer, className: stri // AssemblyReader for ProvidedTypesContext // // A lightweight .NET assembly reader that fits in a single F# file. Based on the well-tested Abstract IL -// binary reader code. Used by the type provider to read referenced asssemblies. +// binary reader code. Used by the type provider to read referenced assemblies. module internal AssemblyReader = @@ -4755,8 +4755,8 @@ module internal AssemblyReader = let subsys = seekReadUInt16 is (peOptionalHeaderPhysLoc + 68) (* SubSystem Subsystem required to run this image. Shall be either IMAGE_SUBSYSTEM_WINDOWS_CE_GUI (!0x3) or IMAGE_SUBSYSTEM_WINDOWS_GUI (!0x2). QUERY: Why is this 3 on the images ILASM produces??? *) let useHighEntropyVA = let n = seekReadUInt16 is (peOptionalHeaderPhysLoc + 70) - let highEnthropyVA = 0x20us - (n &&& highEnthropyVA) = highEnthropyVA + let highEntropyVA = 0x20us + (n &&& highEntropyVA) = highEntropyVA (* x86: 000000e0 *) (* x86: 000000f0, x64: 00000100 *) @@ -5897,12 +5897,12 @@ module internal AssemblyReader = and byteAsCallConv b = let cc = - let ccMaxked = b &&& 0x0Fuy - if ccMaxked = e_IMAGE_CEE_CS_CALLCONV_FASTCALL then ILArgConvention.FastCall - elif ccMaxked = e_IMAGE_CEE_CS_CALLCONV_STDCALL then ILArgConvention.StdCall - elif ccMaxked = e_IMAGE_CEE_CS_CALLCONV_THISCALL then ILArgConvention.ThisCall - elif ccMaxked = e_IMAGE_CEE_CS_CALLCONV_CDECL then ILArgConvention.CDecl - elif ccMaxked = e_IMAGE_CEE_CS_CALLCONV_VARARG then ILArgConvention.VarArg + let ccMasked = b &&& 0x0Fuy + if ccMasked = e_IMAGE_CEE_CS_CALLCONV_FASTCALL then ILArgConvention.FastCall + elif ccMasked = e_IMAGE_CEE_CS_CALLCONV_STDCALL then ILArgConvention.StdCall + elif ccMasked = e_IMAGE_CEE_CS_CALLCONV_THISCALL then ILArgConvention.ThisCall + elif ccMasked = e_IMAGE_CEE_CS_CALLCONV_CDECL then ILArgConvention.CDecl + elif ccMasked = e_IMAGE_CEE_CS_CALLCONV_VARARG then ILArgConvention.VarArg else ILArgConvention.Default let generic = (b &&& e_IMAGE_CEE_CS_CALLCONV_GENERIC) <> 0x0uy generic, Callconv (byteAsHasThis b, cc) @@ -6602,7 +6602,7 @@ module internal AssemblyReader = | None -> [| |] | Some(genericArgs) -> genericArgs let tspec = ILTypeSpec(tref, genericArgs) - let ilty = + let ilTy = match tspec.Name with | "System.SByte" | "System.Byte" @@ -6620,8 +6620,8 @@ module internal AssemblyReader = // if it's an array, wrap it - otherwise, just return the IL type match rank with - | Some(r) -> ILType.Array(r, ilty) - | _ -> ilty + | Some(r) -> ILType.Array(r, ilTy) + | _ -> ilTy let sigptr_get_bytes n (bytes:byte[]) sigptr = @@ -6894,7 +6894,7 @@ namespace ProviderImplementation.ProvidedTypes // implementation must support the operations used by the F# compiler to interrogate the reflection objects. // // For a System.Assembly, the information must be sufficient to allow the Assembly --> ILScopeRef conversion - // in ExtensionTyping.fs of the F# compiler. This requires: + // in TypeProviders.fs of the F# compiler. This requires: // Assembly.GetName() // // For a System.Type representing a reference to a named type definition, the information must be sufficient @@ -7539,7 +7539,7 @@ namespace ProviderImplementation.ProvidedTypes override this.MakePointerType() = TypeSymbol(TypeSymbolKind.Pointer, [| this |], typeBuilder) :> Type override this.MakeByRefType() = TypeSymbol(TypeSymbolKind.ByRef, [| this |], typeBuilder) :> Type - override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegting implementation of this, and we are self-delegating + override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegating implementation of this, and we are self-delegating override this.ToString() = this.FullName @@ -7616,7 +7616,7 @@ namespace ProviderImplementation.ProvidedTypes override this.Module = notRequired this "txILGenericParam: Module" this.Name: Module override this.GetElementType() = notRequired this "txILGenericParam: GetElementType" this.Name override this.InvokeMember(_name, _invokeAttr, _binder, _target, _args, _modifiers, _culture, _namedParameters) = notRequired this "txILGenericParam: InvokeMember" this.Name - override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegting implementation of this, and we are self-delegating + override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegating implementation of this, and we are self-delegating /// Clones namespaces, type providers, types and members provided by tp, renaming namespace nsp1 into namespace nsp2. @@ -8030,7 +8030,7 @@ namespace ProviderImplementation.ProvidedTypes override __.GetEnumUnderlyingType() = if this.IsEnum then - txILType ([| |], [| |]) ilGlobals.typ_Int32 // TODO: in theory the assumption of "Int32" is not accurate for all enums, howver in practice .NET only uses enums with backing field Int32 + txILType ([| |], [| |]) ilGlobals.typ_Int32 // TODO: in theory the assumption of "Int32" is not accurate for all enums, however in practice .NET only uses enums with backing field Int32 else failwithf "not enum type %O" this override __.IsArrayImpl() = false @@ -8078,7 +8078,7 @@ namespace ProviderImplementation.ProvidedTypes member __.MakeEventInfo (declTy: Type) md = txILEventDef declTy md member __.MakeFieldInfo (declTy: Type) md = txILFieldDef declTy md member __.MakeNestedTypeInfo (declTy: Type) md = asm.TxILTypeDef (Some declTy) md - override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegting implementation of this, and we are self-delegating + override this.GetEvents() = this.GetEvents(BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.Static) // Needed because TypeDelegator.cs provides a delegating implementation of this, and we are self-delegating #if NETCOREAPP || NETSTANDARD2_1_OR_GREATER // See bug https://github.com/fsprojects/FSharp.TypeProviders.SDK/issues/236 override __.IsSZArray = false @@ -9336,7 +9336,7 @@ namespace ProviderImplementation.ProvidedTypes | ShapeVarUnchecked v -> Expr.Var (convVarToTgt v) | ShapeLambdaUnchecked _ as d -> - failwithf "It's not possible to use construct %O when cross targetting to a different FSharp.Core. Make sure you're not calling a function with signature A->(B->C) instead of A->B->C (using |> causes this)." d + failwithf "It's not possible to use construct %O when cross targeting to a different FSharp.Core. Make sure you're not calling a function with signature A->(B->C) instead of A->B->C (using |> causes this)." d | ShapeCombinationUnchecked (o, exprs) -> RebuildShapeCombinationUnchecked (o, List.map convExprToTgt exprs) @@ -10297,7 +10297,7 @@ namespace ProviderImplementation.ProvidedTypes else failwith "getTypeDefOrRefAsUncodedToken" getUncodedToken tab idx - // REVIEW: write into an accumuating buffer + // REVIEW: write into an accumulating buffer let EmitArrayShape (bb: ByteBuffer) (ILArrayShape shape) = let sized = Array.filter (function (_, USome _) -> true | _ -> false) shape let lobounded = Array.filter (function (USome _, _) -> true | _ -> false) shape @@ -10325,7 +10325,7 @@ namespace ProviderImplementation.ProvidedTypes | ILArgConvention.VarArg -> e_IMAGE_CEE_CS_CALLCONV_VARARG) - // REVIEW: write into an accumuating buffer + // REVIEW: write into an accumulating buffer let rec EmitTypeSpec cenv env (bb: ByteBuffer) (et, tspec:ILTypeSpec) = if isEmpty tspec.GenericArgs then bb.EmitByte et @@ -10364,8 +10364,6 @@ namespace ProviderImplementation.ProvidedTypes and EmitType cenv env bb ty = match ty with | ElementType et -> bb.EmitByte et - | _ -> - match ty with | ILType.Boxed tspec -> EmitTypeSpec cenv env bb (et_CLASS, tspec) | ILType.Value tspec -> EmitTypeSpec cenv env bb (et_VALUETYPE, tspec) | ILType.Array (shape, ty) -> @@ -10437,7 +10435,7 @@ namespace ProviderImplementation.ProvidedTypes let rec GetFieldInitAsBlobIdx cenv (x:ILFieldInit) = GetBytesAsBlobIdx cenv (emitBytesViaBuffer (fun bb -> GetFieldInit bb x)) - // REVIEW: write into an accumuating buffer + // REVIEW: write into an accumulating buffer and GetFieldInit (bb: ByteBuffer) x = match x with | :? string as b -> bb.EmitBytes (Encoding.Unicode.GetBytes b) @@ -10498,7 +10496,7 @@ namespace ProviderImplementation.ProvidedTypes | ILTypeDefAccess.Nested ILMemberAccess.FamilyAndAssembly -> 0x00000006 | ILTypeDefAccess.Nested ILMemberAccess.FamilyOrAssembly -> 0x00000007 | ILTypeDefAccess.Nested ILMemberAccess.Assembly -> 0x00000005 - | ILTypeDefAccess.Nested ILMemberAccess.CompilerControlled -> failwith "bad type acccess" + | ILTypeDefAccess.Nested ILMemberAccess.CompilerControlled -> failwith "bad type access" let rec GetTypeDefAsRow cenv env _enc (td:ILTypeDef) = let nselem, nelem = GetTypeNameAsElemPair cenv (td.Namespace, td.Name) @@ -10677,7 +10675,7 @@ namespace ProviderImplementation.ProvidedTypes // -------------------------------------------------------------------- // ILMethodRef --> ILMethodDef. // - // Only successfuly converts ILMethodRef's referring to + // Only successfully converts ILMethodRef's referring to // methods in the module being emitted. // -------------------------------------------------------------------- @@ -10858,7 +10856,7 @@ namespace ProviderImplementation.ProvidedTypes let fenv = envForFieldSpec fspec FindOrAddSharedRow cenv ILTableNames.MemberRef (GetFieldSpecAsMemberRefRow cenv env fenv fspec) - // REVIEW: write into an accumuating buffer + // REVIEW: write into an accumulating buffer and EmitFieldSpecSig cenv env (bb: ByteBuffer) (fspec:ILFieldSpec) = bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_FIELD EmitType cenv env bb fspec.FormalType @@ -12277,7 +12275,7 @@ namespace ProviderImplementation.ProvidedTypes // manifest --> generate Assembly row // -------------------------------------------------------------------- - and GetManifsetAsAssemblyRow cenv m = + and GetManifestAsAssemblyRow cenv m = UnsharedRow [|ULong m.AuxModuleHashAlgorithm UShort (match m.Version with UNone -> 0us | USome v -> uint16 v.Major) @@ -12302,7 +12300,7 @@ namespace ProviderImplementation.ProvidedTypes (match m.Locale with UNone -> StringE 0 | USome x -> StringE (GetStringHeapIdx cenv x)) |] and GenManifestPass3 cenv m = - let aidx = AddUnsharedRow cenv ILTableNames.Assembly (GetManifsetAsAssemblyRow cenv m) + let aidx = AddUnsharedRow cenv ILTableNames.Assembly (GetManifestAsAssemblyRow cenv m) #if EMIT_SECURITY_DECLS GenSecurityDeclsPass3 cenv (hds_Assembly, aidx) m.SecurityDecls.Entries #endif @@ -12491,7 +12489,7 @@ namespace ProviderImplementation.ProvidedTypes let pdbData = () #endif - let idxForNextedTypeDef (tds:ILTypeDef list, td:ILTypeDef) = + let idxForNestedTypeDef (tds:ILTypeDef list, td:ILTypeDef) = let enc = tds |> List.map (fun td -> td.Name) GetIdxForTypeDef cenv (TdKey(enc, td.Namespace, td.Name)) @@ -12504,18 +12502,18 @@ namespace ProviderImplementation.ProvidedTypes // turn idx tbls into token maps let mappings = { TypeDefTokenMap = (fun t -> - getUncodedToken ILTableNames.TypeDef (idxForNextedTypeDef t)) + getUncodedToken ILTableNames.TypeDef (idxForNestedTypeDef t)) FieldDefTokenMap = (fun t fd -> - let tidx = idxForNextedTypeDef t + let tidx = idxForNestedTypeDef t getUncodedToken ILTableNames.Field (GetFieldDefAsFieldDefIdx cenv tidx fd)) MethodDefTokenMap = (fun t md -> - let tidx = idxForNextedTypeDef t + let tidx = idxForNestedTypeDef t getUncodedToken ILTableNames.Method (FindMethodDefIdx cenv (GetKeyForMethodDef tidx md))) PropertyTokenMap = (fun t pd -> - let tidx = idxForNextedTypeDef t + let tidx = idxForNestedTypeDef t getUncodedToken ILTableNames.Property (cenv.propertyDefs.GetTableEntry (GetKeyForPropertyDef tidx pd))) EventTokenMap = (fun t ed -> - let tidx = idxForNextedTypeDef t + let tidx = idxForNestedTypeDef t getUncodedToken ILTableNames.Event (cenv.eventDefs.GetTableEntry (EventKey (tidx, ed.Name)))) } // New return the results let data = cenv.data.Close() @@ -13263,7 +13261,7 @@ namespace ProviderImplementation.ProvidedTypes let timestamp = int final.[16] ||| (int final.[17] <<< 8) ||| (int final.[18] <<< 16) ||| (int (final.[19] ||| 128uy) <<< 24) writeInt32 os timestamp // Update pdbData with new guid and timestamp. Portable and embedded PDBs don't need the ModuleID - // Full and PdbOnly aren't supported under deterministic builds currently, they rely on non-determinsitic Windows native code + // Full and PdbOnly aren't supported under deterministic builds currently, they rely on non-deterministic Windows native code { pdbData with ModuleID = final.[0..15] ; Timestamp = timestamp } else writeInt32 os timestamp // date since 1970 @@ -14280,8 +14278,8 @@ namespace ProviderImplementation.ProvidedTypes let unitType = transType (convTypeToTgt (typeof)) let expectedState = if (retType = ILType.Void || retType.QualifiedName = unitType.QualifiedName) then ExpectedStackState.Empty else ExpectedStackState.Value - let lambadParamVars = [| Var("this", typeof); v|] - let codeGen = CodeGenerator(assemblyMainModule, genUniqueTypeName, implicitCtorArgsAsFields, convTypeToTgt, transType, transFieldSpec, transMeth, transMethRef, transCtorSpec, ilg, lambdaLocals, lambadParamVars) + let lambdaParamVars = [| Var("this", typeof); v|] + let codeGen = CodeGenerator(assemblyMainModule, genUniqueTypeName, implicitCtorArgsAsFields, convTypeToTgt, transType, transFieldSpec, transMeth, transMethRef, transCtorSpec, ilg, lambdaLocals, lambdaParamVars) codeGen.EmitExpr (expectedState, body) if retType.QualifiedName = unitType.QualifiedName then ilg.Emit(I_ldnull) @@ -14310,7 +14308,7 @@ namespace ProviderImplementation.ProvidedTypes ilg.Emit(I_conv DT_I1) elif Type.(=)(t1, typeof) then ilg.Emit(I_conv DT_U1) - /// emits given expression to corresponding IL + // emits given expression to corresponding IL match expr with | ForIntegerRangeLoop(loopVar, first, last, body) -> // for(loopVar = first..last) body @@ -15682,14 +15680,14 @@ namespace ProviderImplementation.ProvidedTypes |> Seq.choose (function :? ProvidedConstructor as pcinfo when not pcinfo.IsTypeInitializer -> Some pcinfo | _ -> None) |> Seq.toList - let implictCtorArgs = + let implicitCtorArgs = match ctors |> List.filter (fun x -> x.IsImplicitConstructor) with | [] -> [] | [ pcinfo ] -> [ for p in pcinfo.GetParameters() -> p ] | _ -> failwith "at most one implicit constructor allowed" let implicitCtorArgsAsFields = - [ for ctorArg in implictCtorArgs -> + [ for ctorArg in implicitCtorArgs -> tb.DefineField(ctorArg.Name, transType ctorArg.ParameterType, FieldAttributes.Private) ] diff --git a/src/ProvidedTypes.fsi b/src/ProvidedTypes.fsi index 921b60d..b1f2692 100644 --- a/src/ProvidedTypes.fsi +++ b/src/ProvidedTypes.fsi @@ -40,7 +40,7 @@ type ProvidedParameter = type ProvidedStaticParameter = inherit ParameterInfo - /// Create a new provided static parameter, for use with DefineStaticParamaeters on a provided type definition. + /// Create a new provided static parameter, for use with DefineStaticParameters on a provided type definition. new: parameterName: string * parameterType: Type * ?parameterDefaultValue: obj -> ProvidedStaticParameter /// Add XML documentation information to this provided constructor @@ -424,7 +424,7 @@ type ProvidedTypesContext = /// this method should not be used directly when authoring a type provider. member ConvertTargetTypeToSource: Type -> Type - /// Returns a quotation rebuilt with resepct to the types from the target referenced assemblies. Normally + /// Returns a quotation rebuilt with respect to the types from the target referenced assemblies. Normally /// this method should not be used directly when authoring a type provider. member ConvertSourceExprToTarget: Expr -> Expr @@ -488,7 +488,7 @@ type TypeProviderForNamespaces = /// Invoked by the host of the type provider to get the static parameters for a method. member GetStaticParametersForMethod: MethodBase -> ParameterInfo[] - /// Invoked by the host of the type provider to apply the static argumetns for a method. + /// Invoked by the host of the type provider to apply the static arguments for a method. member ApplyStaticArgumentsForMethod: MethodBase * string * obj[] -> MethodBase #if !FX_NO_LOCAL_FILESYSTEM @@ -506,7 +506,8 @@ type TypeProviderForNamespaces = #if !NO_GENERATIVE /// Register that a given file is a provided generated target assembly, e.g. an assembly produced by an external - /// code generation tool. This assembly should be a target assembly. + /// code generation tool. This assembly should be a target assembly, i.e. use the same assembly references + /// as given by TargetContext.ReferencedAssemblyPaths member RegisterGeneratedTargetAssembly: fileName: string -> Assembly #endif