From ac4d4ea4991ea16a10748e978c1cef325ad0b43c Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 14 Sep 2023 14:03:00 +0200 Subject: [PATCH 01/33] attribute embedding --- src/Compiler/AbstractIL/il.fs | 6 +++++- src/Compiler/AbstractIL/il.fsi | 1 + src/Compiler/CodeGen/IlxGenSupport.fs | 18 ++++++++++++++++++ src/Compiler/CodeGen/IlxGenSupport.fsi | 1 + src/Compiler/TypedTree/TcGlobals.fs | 4 ++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 2c96d10f528..409a6f5a057 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -3412,6 +3412,8 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly let mkSysILTypeRef nm = mkILTyRef (primaryScopeRef, nm) + let byteIlType = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_Byte)) + member _.primaryAssemblyScopeRef = primaryScopeRef member x.primaryAssemblyRef = @@ -3443,7 +3445,9 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly member val typ_Int64 = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_Int64)) - member val typ_Byte = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_Byte)) + member val typ_Byte = byteIlType + + member val typ_ByteArray = mkILBoxedType (mkILTySpec (mkSysILTypeRef tname_Array, [ byteIlType ])) member val typ_UInt16 = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_UInt16)) diff --git a/src/Compiler/AbstractIL/il.fsi b/src/Compiler/AbstractIL/il.fsi index 34e7d8584e2..1861e9e2d57 100644 --- a/src/Compiler/AbstractIL/il.fsi +++ b/src/Compiler/AbstractIL/il.fsi @@ -1881,6 +1881,7 @@ type internal ILGlobals = member typ_IntPtr: ILType member typ_UIntPtr: ILType member typ_Byte: ILType + member typ_ByteArray: ILType member typ_Int16: ILType member typ_Int32: ILType member typ_Int64: ILType diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index 6fd2074c4e6..59946e86a29 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -229,6 +229,24 @@ let GetDynamicDependencyAttribute (g: TcGlobals) memberTypes (ilType: ILType) = [] ) +let GetNullableAttribute (g: TcGlobals) (ni: TypedTree.NullnessInfo) = + let tref = g.attrib_NullableAttribute.TypeRef + + g.TryEmbedILType( + tref, + (fun () -> + let properties = Some [ "NullableFlags", g.ilg.typ_ByteArray ] + mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, properties)) + ) + + let byteValue = + match ni with + | TypedTree.NullnessInfo.WithNull -> 2uy + | TypedTree.NullnessInfo.AmbivalentToNull -> 0uy + | TypedTree.NullnessInfo.WithoutNull -> 1uy + + mkILCustomAttribute (tref, [ g.ilg.typ_ByteArray ], [ ILAttribElem.Array(g.ilg.typ_Byte, [ ILAttribElem.Byte byteValue ]) ], []) + /// Generate "modreq([mscorlib]System.Runtime.InteropServices.InAttribute)" on inref types. let GenReadOnlyModReqIfNecessary (g: TcGlobals) ty ilTy = let add = isInByrefTy g ty && g.attrib_InAttribute.TyconRef.CanDeref diff --git a/src/Compiler/CodeGen/IlxGenSupport.fsi b/src/Compiler/CodeGen/IlxGenSupport.fsi index 24968a25ec6..f3d51c238ea 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fsi +++ b/src/Compiler/CodeGen/IlxGenSupport.fsi @@ -22,3 +22,4 @@ val GenReadOnlyModReqIfNecessary: g: TcGlobals -> ty: TypedTree.TType -> ilTy: I val GenReadOnlyAttributeIfNecessary: g: TcGlobals -> ty: TypedTree.TType -> ILAttribute option val GetReadOnlyAttribute: g: TcGlobals -> ILAttribute val GetIsUnmanagedAttribute: g: TcGlobals -> ILAttribute +val GetNullableAttribute: g: TcGlobals -> ni: TypedTree.NullnessInfo -> ILAttribute diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index d8a0084db96..d5b6eece644 100755 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -347,6 +347,8 @@ type TcGlobals( match name with | "System.Runtime.CompilerServices.IsReadOnlyAttribute" | "System.Runtime.CompilerServices.IsUnmanagedAttribute" + | "System.Runtime.CompilerServices.NullableAttribute" + | "System.Runtime.CompilerServices.NullableContextAttribute" | "System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute" | "System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes" -> true | _ -> false @@ -1448,6 +1450,8 @@ type TcGlobals( member val attrib_IsReadOnlyAttribute = findOrEmbedSysPublicType "System.Runtime.CompilerServices.IsReadOnlyAttribute" member val attrib_IsUnmanagedAttribute = findOrEmbedSysPublicType "System.Runtime.CompilerServices.IsUnmanagedAttribute" member val attrib_DynamicDependencyAttribute = findOrEmbedSysPublicType "System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute" + member val attrib_NullableAttribute = findOrEmbedSysPublicType "System.Runtime.CompilerServices.NullableAttribute" + member val attrib_NullableContextAttribute = findOrEmbedSysPublicType "System.Runtime.CompilerServices.NullableContextAttribute" member val enum_DynamicallyAccessedMemberTypes = findOrEmbedSysPublicType "System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes" member val attrib_SystemObsolete = findSysAttrib "System.ObsoleteAttribute" From d1f7ec6037af3cef430bc5eede30f7fa901832c8 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 14 Sep 2023 15:10:40 +0200 Subject: [PATCH 02/33] Emitting nullness attribute for typer constraints --- src/Compiler/CodeGen/IlxGen.fs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 33b39ce7f73..7e133e675e6 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -5565,6 +5565,19 @@ and GenGenericParam cenv eenv (tp: Typar) = | TyparConstraint.IsNonNullableStruct _ -> true | _ -> false) + let notNullReferenceTypeConstraint = + if g.langFeatureNullness && g.checkNullness then + tp.Constraints + |> List.exists (function + | TyparConstraint.NotSupportsNull _ -> true + | _ -> false) + |> (function + | true -> NullnessInfo.WithoutNull + | false -> NullnessInfo.WithNull) + |> Some + else + None + let defaultConstructorConstraint = tp.Constraints |> List.exists (function @@ -5606,12 +5619,14 @@ and GenGenericParam cenv eenv (tp: Typar) = nm let attributeList = - let defined = GenAttrs cenv eenv tp.Attribs - - if emitUnmanagedInIlOutput then - (GetIsUnmanagedAttribute g) :: defined - else - defined + [ + yield! GenAttrs cenv eenv tp.Attribs + if emitUnmanagedInIlOutput then + yield (GetIsUnmanagedAttribute g) + match notNullReferenceTypeConstraint with + | Some nullness -> yield GetNullableAttribute g nullness + | None -> () + ] let tpAttrs = mkILCustomAttrs (attributeList) From 5fd0bafe3442e5eee7919218129ea06898f8d57e Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 14 Sep 2023 15:29:08 +0200 Subject: [PATCH 03/33] IlxGen reshuffle to generate parameter and return type attributes --- src/Compiler/CodeGen/IlxGen.fs | 12 ++++++------ src/Compiler/CodeGen/IlxGenSupport.fs | 19 ++++++++++++------- src/Compiler/CodeGen/IlxGenSupport.fsi | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 7e133e675e6..b85532d87d2 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -5663,7 +5663,7 @@ and GenSlotParam m cenv eenv slotParam : ILParameter = let ilAttribs = GenAttrs cenv eenv attribs let ilAttribs = - match GenReadOnlyAttributeIfNecessary cenv.g ty with + match GenAdditionalAttributesForTy cenv.g ty with | Some attr -> ilAttribs @ [ attr ] | None -> ilAttribs @@ -5721,7 +5721,7 @@ and GenFormalReturnType m cenv eenvFormal returnTy : ILReturn = match returnTy with | None -> ilRet | Some ty -> - match GenReadOnlyAttributeIfNecessary cenv.g ty with + match GenAdditionalAttributesForTy cenv.g ty with | Some attr -> ilRet.WithCustomAttrs(mkILCustomAttrs (ilRet.CustomAttrs.AsList() @ [ attr ])) | None -> ilRet @@ -8768,7 +8768,7 @@ and GenParams let ilAttribs = GenAttrs cenv eenv attribs let ilAttribs = - match GenReadOnlyAttributeIfNecessary cenv.g methodArgTy with + match GenAdditionalAttributesForTy cenv.g methodArgTy with | Some attr -> ilAttribs @ [ attr ] | None -> ilAttribs @@ -8797,7 +8797,7 @@ and GenReturnInfo cenv eenv returnTy ilRetTy (retInfo: ArgReprInfo) : ILReturn = let ilAttribs = match returnTy with | Some retTy -> - match GenReadOnlyAttributeIfNecessary cenv.g retTy with + match GenAdditionalAttributesForTy cenv.g retTy with | Some attr -> ilAttribs @ [ attr ] | None -> ilAttribs | _ -> ilAttribs @@ -9134,7 +9134,7 @@ and GenMethodForBinding || memberInfo.MemberFlags.MemberKind = SynMemberKind.PropertySet || memberInfo.MemberFlags.MemberKind = SynMemberKind.PropertyGetSet -> - match GenReadOnlyAttributeIfNecessary cenv.g returnTy with + match GenAdditionalAttributesForTy cenv.g returnTy with | Some ilAttr -> ilAttr | _ -> () | _ -> () @@ -10384,7 +10384,7 @@ and GenAbstractBinding cenv eenv tref (vref: ValRef) = || memberInfo.MemberFlags.MemberKind = SynMemberKind.PropertySet || memberInfo.MemberFlags.MemberKind = SynMemberKind.PropertyGetSet -> - match GenReadOnlyAttributeIfNecessary cenv.g returnTy with + match GenAdditionalAttributesForTy cenv.g returnTy with | Some ilAttr -> ilAttr | _ -> () | _ -> () diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index 59946e86a29..0185cef2b1c 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -166,13 +166,6 @@ let GetReadOnlyAttribute (g: TcGlobals) = let GetIsUnmanagedAttribute (g: TcGlobals) = getPotentiallyEmbedableAttribute g g.attrib_IsUnmanagedAttribute -let GenReadOnlyAttributeIfNecessary g ty = - if isInByrefTy g ty then - let attr = GetReadOnlyAttribute g - Some attr - else - None - let GetDynamicallyAccessedMemberTypes (g: TcGlobals) = let tref = g.enum_DynamicallyAccessedMemberTypes.TypeRef @@ -247,6 +240,18 @@ let GetNullableAttribute (g: TcGlobals) (ni: TypedTree.NullnessInfo) = mkILCustomAttribute (tref, [ g.ilg.typ_ByteArray ], [ ILAttribElem.Array(g.ilg.typ_Byte, [ ILAttribElem.Byte byteValue ]) ], []) +let GenReadOnlyIfNecessary g ty = + if isInByrefTy g ty then + let attr = GetReadOnlyAttribute g + Some attr + else + None + +let GenAdditionalAttributesForTy g ty = + match GenReadOnlyIfNecessary g ty with + | Some a -> Some a + | None -> None + /// Generate "modreq([mscorlib]System.Runtime.InteropServices.InAttribute)" on inref types. let GenReadOnlyModReqIfNecessary (g: TcGlobals) ty ilTy = let add = isInByrefTy g ty && g.attrib_InAttribute.TyconRef.CanDeref diff --git a/src/Compiler/CodeGen/IlxGenSupport.fsi b/src/Compiler/CodeGen/IlxGenSupport.fsi index f3d51c238ea..f11ffa9c56c 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fsi +++ b/src/Compiler/CodeGen/IlxGenSupport.fsi @@ -19,7 +19,7 @@ val mkLdfldMethodDef: val GetDynamicDependencyAttribute: g: TcGlobals -> memberTypes: int32 -> ilType: ILType -> ILAttribute val GenReadOnlyModReqIfNecessary: g: TcGlobals -> ty: TypedTree.TType -> ilTy: ILType -> ILType -val GenReadOnlyAttributeIfNecessary: g: TcGlobals -> ty: TypedTree.TType -> ILAttribute option +val GenAdditionalAttributesForTy: g: TcGlobals -> ty: TypedTree.TType -> ILAttribute option val GetReadOnlyAttribute: g: TcGlobals -> ILAttribute val GetIsUnmanagedAttribute: g: TcGlobals -> ILAttribute val GetNullableAttribute: g: TcGlobals -> ni: TypedTree.NullnessInfo -> ILAttribute From 15276477d00f6c86aba85b6f1f93482a6099b7d6 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 14 Sep 2023 15:31:19 +0200 Subject: [PATCH 04/33] Prepare for nullness attr inclusion --- src/Compiler/CodeGen/IlxGenSupport.fs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index 0185cef2b1c..c61d9a867c0 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -247,10 +247,16 @@ let GenReadOnlyIfNecessary g ty = else None +let GenNullnessIfNecessary (g: TcGlobals) _ty = + if g.langFeatureNullness && g.checkNullness then + Some 42 + else + None + let GenAdditionalAttributesForTy g ty = - match GenReadOnlyIfNecessary g ty with - | Some a -> Some a - | None -> None + match GenReadOnlyIfNecessary g ty, GenNullnessIfNecessary g ty with + | Some a, _ -> Some a + | None, _ -> None /// Generate "modreq([mscorlib]System.Runtime.InteropServices.InAttribute)" on inref types. let GenReadOnlyModReqIfNecessary (g: TcGlobals) ty ilTy = From 5a3f87938ae181b36dce6774f1436b093d01d144 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 15 Sep 2023 13:13:43 +0200 Subject: [PATCH 05/33] Initial emission of Nullable attribute, without NullableContext optimization to reduce metadata overload --- src/Compiler/CodeGen/IlxGen.fs | 32 +++------ src/Compiler/CodeGen/IlxGenSupport.fs | 93 +++++++++++++++++++++++--- src/Compiler/CodeGen/IlxGenSupport.fsi | 4 +- 3 files changed, 93 insertions(+), 36 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index b85532d87d2..ed5894d6fd5 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -5624,7 +5624,7 @@ and GenGenericParam cenv eenv (tp: Typar) = if emitUnmanagedInIlOutput then yield (GetIsUnmanagedAttribute g) match notNullReferenceTypeConstraint with - | Some nullness -> yield GetNullableAttribute g nullness + | Some nullness -> yield GetNullableAttribute g [nullness] | None -> () ] @@ -5661,11 +5661,7 @@ and GenSlotParam m cenv eenv slotParam : ILParameter = GenParamAttribs cenv ty attribs let ilAttribs = GenAttrs cenv eenv attribs - - let ilAttribs = - match GenAdditionalAttributesForTy cenv.g ty with - | Some attr -> ilAttribs @ [ attr ] - | None -> ilAttribs + let ilAttribs = ilAttribs @ GenAdditionalAttributesForTy cenv.g ty { Name = nm @@ -5722,8 +5718,9 @@ and GenFormalReturnType m cenv eenvFormal returnTy : ILReturn = | None -> ilRet | Some ty -> match GenAdditionalAttributesForTy cenv.g ty with - | Some attr -> ilRet.WithCustomAttrs(mkILCustomAttrs (ilRet.CustomAttrs.AsList() @ [ attr ])) - | None -> ilRet + | [] -> ilRet + | attrs -> ilRet.WithCustomAttrs(mkILCustomAttrs (ilRet.CustomAttrs.AsList() @ attrs)) + and instSlotParam inst (TSlotParam (nm, ty, inFlag, fl2, fl3, attrs)) = TSlotParam(nm, instType inst ty, inFlag, fl2, fl3, attrs) @@ -8766,11 +8763,7 @@ and GenParams | None -> None, takenNames let ilAttribs = GenAttrs cenv eenv attribs - - let ilAttribs = - match GenAdditionalAttributesForTy cenv.g methodArgTy with - | Some attr -> ilAttribs @ [ attr ] - | None -> ilAttribs + let ilAttribs = ilAttribs @ GenAdditionalAttributesForTy cenv.g methodArgTy let param: ILParameter = { @@ -8796,10 +8789,7 @@ and GenReturnInfo cenv eenv returnTy ilRetTy (retInfo: ArgReprInfo) : ILReturn = let ilAttribs = match returnTy with - | Some retTy -> - match GenAdditionalAttributesForTy cenv.g retTy with - | Some attr -> ilAttribs @ [ attr ] - | None -> ilAttribs + | Some retTy -> ilAttribs @ GenAdditionalAttributesForTy cenv.g retTy | _ -> ilAttribs let ilAttrs = mkILCustomAttrs ilAttribs @@ -9134,9 +9124,7 @@ and GenMethodForBinding || memberInfo.MemberFlags.MemberKind = SynMemberKind.PropertySet || memberInfo.MemberFlags.MemberKind = SynMemberKind.PropertyGetSet -> - match GenAdditionalAttributesForTy cenv.g returnTy with - | Some ilAttr -> ilAttr - | _ -> () + yield! GenAdditionalAttributesForTy cenv.g returnTy | _ -> () ] @@ -10384,9 +10372,7 @@ and GenAbstractBinding cenv eenv tref (vref: ValRef) = || memberInfo.MemberFlags.MemberKind = SynMemberKind.PropertySet || memberInfo.MemberFlags.MemberKind = SynMemberKind.PropertyGetSet -> - match GenAdditionalAttributesForTy cenv.g returnTy with - | Some ilAttr -> ilAttr - | _ -> () + yield! GenAdditionalAttributesForTy cenv.g returnTy | _ -> () ] diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index c61d9a867c0..fffb9027384 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -8,6 +8,7 @@ open Internal.Utilities.Library open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.TcGlobals open FSharp.Compiler.TypedTreeOps +open FSharp.Compiler.TypedTree /// Make a method that simply loads a field let mkLdfldMethodDef (ilMethName, iLAccess, isStatic, ilTy, ilFieldName, ilPropType, customAttrs) = @@ -222,7 +223,7 @@ let GetDynamicDependencyAttribute (g: TcGlobals) memberTypes (ilType: ILType) = [] ) -let GetNullableAttribute (g: TcGlobals) (ni: TypedTree.NullnessInfo) = +let GetNullableAttribute (g: TcGlobals) (nullnessInfos: TypedTree.NullnessInfo list) = let tref = g.attrib_NullableAttribute.TypeRef g.TryEmbedILType( @@ -232,13 +233,15 @@ let GetNullableAttribute (g: TcGlobals) (ni: TypedTree.NullnessInfo) = mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, properties)) ) - let byteValue = + let byteValue ni = match ni with - | TypedTree.NullnessInfo.WithNull -> 2uy - | TypedTree.NullnessInfo.AmbivalentToNull -> 0uy - | TypedTree.NullnessInfo.WithoutNull -> 1uy + | NullnessInfo.WithNull -> 2uy + | NullnessInfo.AmbivalentToNull -> 0uy + | NullnessInfo.WithoutNull -> 1uy - mkILCustomAttribute (tref, [ g.ilg.typ_ByteArray ], [ ILAttribElem.Array(g.ilg.typ_Byte, [ ILAttribElem.Byte byteValue ]) ], []) + let bytes = nullnessInfos |> List.map (fun ni -> byteValue ni |> ILAttribElem.Byte) + + mkILCustomAttribute (tref, [ g.ilg.typ_ByteArray ], [ ILAttribElem.Array(g.ilg.typ_Byte, bytes) ], []) let GenReadOnlyIfNecessary g ty = if isInByrefTy g ty then @@ -247,16 +250,84 @@ let GenReadOnlyIfNecessary g ty = else None -let GenNullnessIfNecessary (g: TcGlobals) _ty = +(* Nullness metadata format in C#: https://github.com/dotnet/roslyn/blob/main/docs/features/nullable-metadata.md +Each type reference in metadata may have an associated NullableAttribute with a byte[] where each byte represents nullability: 0 for oblivious, 1 for not annotated, and 2 for annotated. + +The byte[] is constructed as follows: + +Reference type: the nullability (0, 1, or 2), followed by the representation of the type arguments in order including containing types +Nullable value type: the representation of the type argument only +Non-generic value type: skipped +Generic value type: 0, followed by the representation of the type arguments in order including containing types +Array: the nullability (0, 1, or 2), followed by the representation of the element type +Tuple: the representation of the underlying constructed type +Type parameter reference: the nullability (0, 1, or 2, with 0 for unconstrained type parameter) +*) +let rec GetNullnessFromTType (g: TcGlobals) ty = + match ty |> stripTyEqns g with + | TType_app (tcref, tinst, nullness) -> + let isValueType = tcref.IsStructOrEnumTycon + let isNonGeneric = tinst.IsEmpty + if isNonGeneric && isValueType then + // Non-generic value type: skipped + [] + else + [ if isValueType then + // Generic value type: 0, followed by the representation of the type arguments in order including containing types + yield NullnessInfo.AmbivalentToNull + else if tyconRefEq g g.system_Nullable_tcref tcref then + // Nullable value type: the representation of the type argument only + () + else + // Reference type: the nullability (0, 1, or 2), followed by the representation of the type arguments in order including containing types + yield nullness.Evaluate() + + for tt in tinst do + yield! GetNullnessFromTType g tt ] + + | TType_fun (domainTy, retTy, nullness) -> + // FsharpFunc + [ yield nullness.Evaluate() + yield! GetNullnessFromTType g domainTy + yield! GetNullnessFromTType g retTy] + + | TType_tuple (tupInfo,elementTypes) -> + // Tuple: the representation of the underlying constructed type + [ if evalTupInfoIsStruct tupInfo then + yield NullnessInfo.AmbivalentToNull + else + yield NullnessInfo.WithoutNull + for t in elementTypes do + yield! GetNullnessFromTType g t] + + | TType_anon (anonInfo,tys) -> + [ if evalAnonInfoIsStruct anonInfo then + yield NullnessInfo.AmbivalentToNull + else + yield NullnessInfo.WithoutNull + for t in tys do + yield! GetNullnessFromTType g t] + | TType_forall _ + | TType_ucase _ + | TType_var _ + | TType_measure _ -> [] + +let GenNullnessIfNecessary (g: TcGlobals) ty = if g.langFeatureNullness && g.checkNullness then - Some 42 + let nullnessList = GetNullnessFromTType g ty + match nullnessList with + // Optimizations as done in C# :: If the byte[] is empty, the NullableAttribute is omitted. + | [] -> None + // Optimizations as done in C# :: If all values in the byte[] are the same, the NullableAttribute is constructed with that single byte value. + | head :: tail when tail |> List.forall ((=) head) -> GetNullableAttribute g [head] |> Some + | nonUniformList -> GetNullableAttribute g nonUniformList |> Some else None let GenAdditionalAttributesForTy g ty = - match GenReadOnlyIfNecessary g ty, GenNullnessIfNecessary g ty with - | Some a, _ -> Some a - | None, _ -> None + let readOnly = GenReadOnlyIfNecessary g ty |> Option.toList + let nullable = GenNullnessIfNecessary g ty |> Option.toList + readOnly @ nullable /// Generate "modreq([mscorlib]System.Runtime.InteropServices.InAttribute)" on inref types. let GenReadOnlyModReqIfNecessary (g: TcGlobals) ty ilTy = diff --git a/src/Compiler/CodeGen/IlxGenSupport.fsi b/src/Compiler/CodeGen/IlxGenSupport.fsi index f11ffa9c56c..7310d245b25 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fsi +++ b/src/Compiler/CodeGen/IlxGenSupport.fsi @@ -19,7 +19,7 @@ val mkLdfldMethodDef: val GetDynamicDependencyAttribute: g: TcGlobals -> memberTypes: int32 -> ilType: ILType -> ILAttribute val GenReadOnlyModReqIfNecessary: g: TcGlobals -> ty: TypedTree.TType -> ilTy: ILType -> ILType -val GenAdditionalAttributesForTy: g: TcGlobals -> ty: TypedTree.TType -> ILAttribute option +val GenAdditionalAttributesForTy: g: TcGlobals -> ty: TypedTree.TType -> ILAttribute list val GetReadOnlyAttribute: g: TcGlobals -> ILAttribute val GetIsUnmanagedAttribute: g: TcGlobals -> ILAttribute -val GetNullableAttribute: g: TcGlobals -> ni: TypedTree.NullnessInfo -> ILAttribute +val GetNullableAttribute: g: TcGlobals -> nullnessInfos: TypedTree.NullnessInfo list -> ILAttribute From 8ce201ebadf6d784e80a5388a35ce708ea6e66bc Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 15 Sep 2023 14:25:35 +0200 Subject: [PATCH 06/33] nullable attribute IL emit test --- .../EmittedIL/Nullness/NullnessMetadata.fs | 138 ++++++++++++++++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + 2 files changed, 139 insertions(+) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs new file mode 100644 index 00000000000..def24daa79c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace EmittedIL + +open Xunit +open FSharp.Test.Compiler + +module NullnessMetadata = + + [] + let ``Nullable attribute gets generated``() = + FSharp """ +module MyTestModule + +let nonNullableInputOutputFunc (x:string) = x +let nullableStringInputOutputFunc (x: string | null) = x +let nonNullableIntFunc (x:int) = x +let nullableIntFunc (x:System.Nullable) = x +let genericValueTypeTest (x: struct(string * (string|null) * int * int * int * int)) = x +let genericRefTypeTest (x: string * (string|null) * int * int * int * int) = x +let nestedGenericsTest (x: list | null> | null) = x +let multiArgumentTest (x:string) (y:string | null) = 42 + """ + |> withLangVersionPreview + |> withOptions ["--checknulls"] + |> compile + |> shouldSucceed + |> verifyIL [""" +.method public static string nonNullableInputOutputFunc(string x) cil managed +{ +.param [0] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 01 00 00 ) +.param [1] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 01 00 00 ) + +.maxstack 8 +IL_0000: ldarg.0 +IL_0001: ret +} """;""" +.method public static string nullableStringInputOutputFunc(string x) cil managed +{ +.param [0] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) +.param [1] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) + +.maxstack 8 +IL_0000: ldarg.0 +IL_0001: ret +} """;""" +.method public static int32 nonNullableIntFunc(int32 x) cil managed +{ + +.maxstack 8 +IL_0000: ldarg.0 +IL_0001: ret +} """;""" +.method public static valuetype [runtime]System.Nullable`1 + nullableIntFunc(valuetype [runtime]System.Nullable`1 x) cil managed +{ +.param [0] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 00 00 00 ) +.param [1] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 00 00 00 ) + +.maxstack 8 +IL_0000: ldarg.0 +IL_0001: ret +} """;""" +.method public static valuetype [runtime]System.ValueTuple`6 + genericValueTypeTest(valuetype [runtime]System.ValueTuple`6 x) cil managed +{ +.param [0] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) +.param [1] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + +.maxstack 8 +IL_0000: ldarg.0 +IL_0001: ret +} """;""" +.method public static class [runtime]System.Tuple`6 + genericRefTypeTest(string x_0, + string x_1, + int32 x_2, + int32 x_3, + int32 x_4, + int32 x_5) cil managed +{ +.param [0] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) +.param [1] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 01 00 00 ) +.param [2] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) + +.maxstack 8 +IL_0000: ldarg.0 +IL_0001: ldarg.1 +IL_0002: ldarg.2 +IL_0003: ldarg.3 +IL_0004: ldarg.s x_4 +IL_0006: ldarg.s x_5 +IL_0008: newobj instance void class [runtime]System.Tuple`6::.ctor(!0, + !1, + !2, + !3, + !4, + !5) +IL_000d: ret +} """;""" +.method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + nestedGenericsTest(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> x) cil managed +{ +.param [0] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) +.param [1] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) + +.maxstack 8 +IL_0000: ldarg.0 +IL_0001: ret +} """;""" +.method public static int32 multiArgumentTest(string x, + string y) cil managed +{ +.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) +.param [1] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 01 00 00 ) +.param [2] +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) + +.maxstack 8 +IL_0000: ldc.i4.s 42 +IL_0002: ret +} """;] + + \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index c44ce76ff6b..f5a1b336130 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -157,6 +157,7 @@ + From 329241d6ed9b11d307fcd64775207e9ea99696c2 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 15 Sep 2023 14:33:02 +0200 Subject: [PATCH 07/33] Fix special case for System.Nullable --- src/Compiler/CodeGen/IlxGenSupport.fs | 8 ++++---- .../EmittedIL/Nullness/NullnessMetadata.fs | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index fffb9027384..2865ef27927 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -272,12 +272,12 @@ let rec GetNullnessFromTType (g: TcGlobals) ty = // Non-generic value type: skipped [] else - [ if isValueType then - // Generic value type: 0, followed by the representation of the type arguments in order including containing types - yield NullnessInfo.AmbivalentToNull - else if tyconRefEq g g.system_Nullable_tcref tcref then + [ if tyconRefEq g g.system_Nullable_tcref tcref then // Nullable value type: the representation of the type argument only () + else if isValueType then + // Generic value type: 0, followed by the representation of the type arguments in order including containing types + yield NullnessInfo.AmbivalentToNull else // Reference type: the nullability (0, 1, or 2), followed by the representation of the type arguments in order including containing types yield nullness.Evaluate() diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index def24daa79c..6aeb84da226 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -58,10 +58,6 @@ IL_0001: ret .method public static valuetype [runtime]System.Nullable`1 nullableIntFunc(valuetype [runtime]System.Nullable`1 x) cil managed { -.param [0] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 00 00 00 ) -.param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 From 1a8e288120e2e176ea690555bf51733a53aec99c Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 18 Sep 2023 10:47:24 +0200 Subject: [PATCH 08/33] formatting --- src/Compiler/CodeGen/IlxGen.fs | 3 +- src/Compiler/CodeGen/IlxGenSupport.fs | 96 +++++++++++++++------------ 2 files changed, 54 insertions(+), 45 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index ed5894d6fd5..a63a1523833 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -5624,7 +5624,7 @@ and GenGenericParam cenv eenv (tp: Typar) = if emitUnmanagedInIlOutput then yield (GetIsUnmanagedAttribute g) match notNullReferenceTypeConstraint with - | Some nullness -> yield GetNullableAttribute g [nullness] + | Some nullness -> yield GetNullableAttribute g [ nullness ] | None -> () ] @@ -5720,7 +5720,6 @@ and GenFormalReturnType m cenv eenvFormal returnTy : ILReturn = match GenAdditionalAttributesForTy cenv.g ty with | [] -> ilRet | attrs -> ilRet.WithCustomAttrs(mkILCustomAttrs (ilRet.CustomAttrs.AsList() @ attrs)) - and instSlotParam inst (TSlotParam (nm, ty, inFlag, fl2, fl3, attrs)) = TSlotParam(nm, instType inst ty, inFlag, fl2, fl3, attrs) diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index 2865ef27927..62c92e006be 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -8,7 +8,7 @@ open Internal.Utilities.Library open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.TcGlobals open FSharp.Compiler.TypedTreeOps -open FSharp.Compiler.TypedTree +open FSharp.Compiler.TypedTree /// Make a method that simply loads a field let mkLdfldMethodDef (ilMethName, iLAccess, isStatic, ilTy, ilFieldName, ilPropType, customAttrs) = @@ -243,7 +243,7 @@ let GetNullableAttribute (g: TcGlobals) (nullnessInfos: TypedTree.NullnessInfo l mkILCustomAttribute (tref, [ g.ilg.typ_ByteArray ], [ ILAttribElem.Array(g.ilg.typ_Byte, bytes) ], []) -let GenReadOnlyIfNecessary g ty = +let GenReadOnlyIfNecessary g ty = if isInByrefTy g ty then let attr = GetReadOnlyAttribute g Some attr @@ -263,63 +263,73 @@ Array: the nullability (0, 1, or 2), followed by the representation of the eleme Tuple: the representation of the underlying constructed type Type parameter reference: the nullability (0, 1, or 2, with 0 for unconstrained type parameter) *) -let rec GetNullnessFromTType (g: TcGlobals) ty = - match ty |> stripTyEqns g with - | TType_app (tcref, tinst, nullness) -> +let rec GetNullnessFromTType (g: TcGlobals) ty = + match ty |> stripTyEqns g with + | TType_app (tcref, tinst, nullness) -> let isValueType = tcref.IsStructOrEnumTycon let isNonGeneric = tinst.IsEmpty + if isNonGeneric && isValueType then - // Non-generic value type: skipped + // Non-generic value type: skipped [] else - [ if tyconRefEq g g.system_Nullable_tcref tcref then - // Nullable value type: the representation of the type argument only - () - else if isValueType then - // Generic value type: 0, followed by the representation of the type arguments in order including containing types - yield NullnessInfo.AmbivalentToNull - else - // Reference type: the nullability (0, 1, or 2), followed by the representation of the type arguments in order including containing types - yield nullness.Evaluate() - - for tt in tinst do - yield! GetNullnessFromTType g tt ] - - | TType_fun (domainTy, retTy, nullness) -> + [ + if tyconRefEq g g.system_Nullable_tcref tcref then + // Nullable value type: the representation of the type argument only + () + else if isValueType then + // Generic value type: 0, followed by the representation of the type arguments in order including containing types + yield NullnessInfo.AmbivalentToNull + else + // Reference type: the nullability (0, 1, or 2), followed by the representation of the type arguments in order including containing types + yield nullness.Evaluate() + + for tt in tinst do + yield! GetNullnessFromTType g tt + ] + + | TType_fun (domainTy, retTy, nullness) -> // FsharpFunc - [ yield nullness.Evaluate() - yield! GetNullnessFromTType g domainTy - yield! GetNullnessFromTType g retTy] - - | TType_tuple (tupInfo,elementTypes) -> - // Tuple: the representation of the underlying constructed type - [ if evalTupInfoIsStruct tupInfo then - yield NullnessInfo.AmbivalentToNull - else - yield NullnessInfo.WithoutNull - for t in elementTypes do - yield! GetNullnessFromTType g t] - - | TType_anon (anonInfo,tys) -> - [ if evalAnonInfoIsStruct anonInfo then - yield NullnessInfo.AmbivalentToNull - else - yield NullnessInfo.WithoutNull - for t in tys do - yield! GetNullnessFromTType g t] + [ + yield nullness.Evaluate() + yield! GetNullnessFromTType g domainTy + yield! GetNullnessFromTType g retTy + ] + + | TType_tuple (tupInfo, elementTypes) -> + // Tuple: the representation of the underlying constructed type + [ + if evalTupInfoIsStruct tupInfo then + yield NullnessInfo.AmbivalentToNull + else + yield NullnessInfo.WithoutNull + for t in elementTypes do + yield! GetNullnessFromTType g t + ] + + | TType_anon (anonInfo, tys) -> + [ + if evalAnonInfoIsStruct anonInfo then + yield NullnessInfo.AmbivalentToNull + else + yield NullnessInfo.WithoutNull + for t in tys do + yield! GetNullnessFromTType g t + ] | TType_forall _ | TType_ucase _ | TType_var _ | TType_measure _ -> [] -let GenNullnessIfNecessary (g: TcGlobals) ty = +let GenNullnessIfNecessary (g: TcGlobals) ty = if g.langFeatureNullness && g.checkNullness then let nullnessList = GetNullnessFromTType g ty + match nullnessList with // Optimizations as done in C# :: If the byte[] is empty, the NullableAttribute is omitted. - | [] -> None + | [] -> None // Optimizations as done in C# :: If all values in the byte[] are the same, the NullableAttribute is constructed with that single byte value. - | head :: tail when tail |> List.forall ((=) head) -> GetNullableAttribute g [head] |> Some + | head :: tail when tail |> List.forall ((=) head) -> GetNullableAttribute g [ head ] |> Some | nonUniformList -> GetNullableAttribute g nonUniformList |> Some else None From 9c8026925eaee3867ec9e8d7c797c14ac1c2137f Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 18 Sep 2023 12:36:37 +0200 Subject: [PATCH 09/33] mkLocalPrivateAttributeWithByteAndByteArrayConstructors --- src/Compiler/CodeGen/IlxGenSupport.fs | 43 +++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index 62c92e006be..7ebfe8f7556 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -123,6 +123,44 @@ let mkLocalPrivateAttributeWithPropertyConstructors (g: TcGlobals, name: string, ILTypeInit.BeforeField ) +let mkLocalPrivateAttributeWithByteAndByteArrayConstructors (g: TcGlobals, name: string, bytePropertyName: string) = + let ilTypeRef = mkILTyRef (ILScopeRef.Local, name) + let ilTy = mkILFormalNamedTy ILBoxity.AsObject ilTypeRef [] + + let fieldName = bytePropertyName + let fieldType = g.ilg.typ_ByteArray + let fieldDef = g.AddFieldGeneratedAttributes(mkILInstanceField (fieldName, fieldType, None, ILMemberAccess.Public)) + + + // Constructor taking an array + let ilArrayCtorDef = + g.AddMethodGeneratedAttributes( + mkILSimpleStorageCtorWithParamNames ( + Some g.ilg.typ_Attribute.TypeSpec, + ilTy, + [], + [(fieldName,fieldName,fieldType)], + ILMemberAccess.Public, + None, + None + ) + ) + + mkILGenericClass ( + name, + ILTypeDefAccess.Private, + ILGenericParameterDefs.Empty, + g.ilg.typ_Attribute, + ILTypes.Empty, + mkILMethods ([ilArrayCtorDef]), + mkILFields [fieldDef], + emptyILTypeDefs, + emptyILProperties, + emptyILEvents, + emptyILCustomAttrs, + ILTypeInit.BeforeField + ) + let mkLocalPrivateInt32Enum (g: TcGlobals, tref: ILTypeRef, values: (string * int32) array) = let ilType = ILType.Value(mkILNonGenericTySpec (tref)) @@ -228,9 +266,7 @@ let GetNullableAttribute (g: TcGlobals) (nullnessInfos: TypedTree.NullnessInfo l g.TryEmbedILType( tref, - (fun () -> - let properties = Some [ "NullableFlags", g.ilg.typ_ByteArray ] - mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, properties)) + (fun () ->mkLocalPrivateAttributeWithByteAndByteArrayConstructors (g, tref.Name, "NullableFlags")) ) let byteValue ni = @@ -308,6 +344,7 @@ let rec GetNullnessFromTType (g: TcGlobals) ty = ] | TType_anon (anonInfo, tys) -> + // It is unlikely for an anon type to be used from C# due to the mangled name, but can still carry the nullability info about it's generic type arguments == the types of the fields [ if evalAnonInfoIsStruct anonInfo then yield NullnessInfo.AmbivalentToNull From 4853886efa4fb9a6f9612dd1d7a96ea875d69c83 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 18 Sep 2023 13:21:52 +0200 Subject: [PATCH 10/33] Compacted metadata if byte[] has .Length of 1 --- src/Compiler/CodeGen/IlxGenSupport.fs | 42 ++++++++++++++----- .../EmittedIL/Nullness/NullnessMetadata.fs | 20 ++++----- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index 7ebfe8f7556..c9e490a3af4 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -129,8 +129,9 @@ let mkLocalPrivateAttributeWithByteAndByteArrayConstructors (g: TcGlobals, name: let fieldName = bytePropertyName let fieldType = g.ilg.typ_ByteArray - let fieldDef = g.AddFieldGeneratedAttributes(mkILInstanceField (fieldName, fieldType, None, ILMemberAccess.Public)) - + + let fieldDef = + g.AddFieldGeneratedAttributes(mkILInstanceField (fieldName, fieldType, None, ILMemberAccess.Public)) // Constructor taking an array let ilArrayCtorDef = @@ -139,21 +140,43 @@ let mkLocalPrivateAttributeWithByteAndByteArrayConstructors (g: TcGlobals, name: Some g.ilg.typ_Attribute.TypeSpec, ilTy, [], - [(fieldName,fieldName,fieldType)], + [ (fieldName, fieldName, fieldType) ], ILMemberAccess.Public, None, None ) ) + let ilScalarCtorDef = + let scalarValueIlType = g.ilg.typ_Byte + + g.AddMethodGeneratedAttributes( + let code = + [ + mkLdarg0 + mkNormalCall (mkILCtorMethSpecForTy (mkILBoxedType g.ilg.typ_Attribute.TypeSpec, [])) // Base class .ctor + + mkLdarg0 // Prepare 'this' to be on bottom of the stack + mkLdcInt32 1 + I_newarr(ILArrayShape.SingleDimensional, scalarValueIlType) // new byte[1] + mkLdcInt32 0 + mkLdarg 1us + I_stelem DT_I1 // array[0] = argument from .ctor + mkNormalStfld (mkILFieldSpecInTy (ilTy, fieldName, fieldType)) + ] + + let body = mkMethodBody (false, [], 8, nonBranchingInstrsToCode code, None, None) + mkILCtor (ILMemberAccess.Public, [ mkILParamNamed ("scalarByteValue", scalarValueIlType) ], body) + ) + mkILGenericClass ( name, ILTypeDefAccess.Private, ILGenericParameterDefs.Empty, g.ilg.typ_Attribute, ILTypes.Empty, - mkILMethods ([ilArrayCtorDef]), - mkILFields [fieldDef], + mkILMethods ([ ilArrayCtorDef; ilScalarCtorDef ]), + mkILFields [ fieldDef ], emptyILTypeDefs, emptyILProperties, emptyILEvents, @@ -264,10 +287,7 @@ let GetDynamicDependencyAttribute (g: TcGlobals) memberTypes (ilType: ILType) = let GetNullableAttribute (g: TcGlobals) (nullnessInfos: TypedTree.NullnessInfo list) = let tref = g.attrib_NullableAttribute.TypeRef - g.TryEmbedILType( - tref, - (fun () ->mkLocalPrivateAttributeWithByteAndByteArrayConstructors (g, tref.Name, "NullableFlags")) - ) + g.TryEmbedILType(tref, (fun () -> mkLocalPrivateAttributeWithByteAndByteArrayConstructors (g, tref.Name, "NullableFlags"))) let byteValue ni = match ni with @@ -277,7 +297,9 @@ let GetNullableAttribute (g: TcGlobals) (nullnessInfos: TypedTree.NullnessInfo l let bytes = nullnessInfos |> List.map (fun ni -> byteValue ni |> ILAttribElem.Byte) - mkILCustomAttribute (tref, [ g.ilg.typ_ByteArray ], [ ILAttribElem.Array(g.ilg.typ_Byte, bytes) ], []) + match bytes with + | [ singleByte ] -> mkILCustomAttribute (tref, [ g.ilg.typ_Byte ], [ singleByte ], []) + | listOfBytes -> mkILCustomAttribute (tref, [ g.ilg.typ_ByteArray ], [ ILAttribElem.Array(g.ilg.typ_Byte, listOfBytes) ], []) let GenReadOnlyIfNecessary g ty = if isInByrefTy g ty then diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index 6aeb84da226..10a2282cc8c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -29,9 +29,9 @@ let multiArgumentTest (x:string) (y:string | null) = 42 .method public static string nonNullableInputOutputFunc(string x) cil managed { .param [0] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 01 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 01 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -40,9 +40,9 @@ IL_0001: ret .method public static string nullableStringInputOutputFunc(string x) cil managed { .param [0] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -86,9 +86,9 @@ IL_0001: ret .param [0] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) .param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 01 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .param [2] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -109,9 +109,9 @@ IL_000d: ret nestedGenericsTest(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> x) cil managed { .param [0] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -122,9 +122,9 @@ IL_0001: ret { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 01 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .param [2] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 01 00 00 00 02 00 00 ) +.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldc.i4.s 42 From 490347e3a6423efa0621d5ae71dc37915ca26c94 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 19 Sep 2023 15:11:17 +0200 Subject: [PATCH 11/33] nullablecontext attribute generation --- src/Compiler/CodeGen/IlxGen.fs | 23 +++-- src/Compiler/CodeGen/IlxGenSupport.fs | 90 ++++++++++++++----- src/Compiler/CodeGen/IlxGenSupport.fsi | 1 + .../EmittedIL/Nullness/NullnessMetadata.fs | 18 +++- 4 files changed, 105 insertions(+), 27 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index a63a1523833..ec07e2d5bf8 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -1868,13 +1868,22 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) = let gevents = ResizeArray(tdef.Events.AsList()) let gnested = TypeDefsBuilder() - member _.Close() = + member _.Close(g: TcGlobals) = + let needsNullableContext = (gmethods.Count + gfields.Count + gproperties.Count) > 0 + + let attrs = + if needsNullableContext && g.checkNullness && g.langFeatureNullness then + mkILCustomAttrsFromArray (Array.append (tdef.CustomAttrs.AsArray()) [| GetNullableContextAttribute g |]) + else + tdef.CustomAttrs + tdef.With( methods = mkILMethods (ResizeArray.toList gmethods), fields = mkILFields (ResizeArray.toList gfields), properties = mkILProperties (tdef.Properties.AsList() @ HashRangeSorted gproperties), events = mkILEvents (ResizeArray.toList gevents), - nestedTypes = mkILTypeDefs (tdef.NestedTypes.AsList() @ gnested.Close()) + nestedTypes = mkILTypeDefs (tdef.NestedTypes.AsList() @ gnested.Close(g)), + customAttrs = attrs ) member _.AddEventDef edef = gevents.Add edef @@ -1922,14 +1931,14 @@ and TypeDefsBuilder() = let mutable countDown = System.Int32.MaxValue let mutable countUp = -1 - member b.Close() = + member b.Close(g: TcGlobals) = //The order we emit type definitions is not deterministic since it is using the reverse of a range from a hash table. We should use an approximation of source order. // Ideally it shouldn't matter which order we use. // However, for some tests FSI generated code appears sensitive to the order, especially for nested types. [ for _, (b, eliminateIfEmpty) in tdefs.Values |> Seq.collect id |> Seq.sortBy fst do - let tdef = b.Close() + let tdef = b.Close(g) // Skip the type if it is empty if not eliminateIfEmpty @@ -2359,7 +2368,7 @@ and AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbuf |> List.sortBy (fst >> (~-)) // invert the result to get 'order-by-descending' behavior (items in list are 0..* so we don't need to worry about int.MinValue) |> List.map snd - gtdefs.Close(), orderedReflectedDefinitions + gtdefs.Close(g), orderedReflectedDefinitions member _.cenv = cenv @@ -10330,6 +10339,8 @@ and GenWitnessParams cenv eenv m (witnessInfos: TraitWitnessInfos) = let nm = String.uncapitalize witnessInfo.MemberName let nm = if used.Contains nm then nm + string i else nm + let attribs = GenAdditionalAttributesForTy cenv.g ty + let ilParam: ILParameter = { Name = Some nm @@ -10339,7 +10350,7 @@ and GenWitnessParams cenv eenv m (witnessInfos: TraitWitnessInfos) = IsIn = false IsOut = false IsOptional = false - CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs []) + CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrs attribs) MetadataIndex = NoMetadataIdx } diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index c9e490a3af4..e7cfdc9190b 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -67,7 +67,22 @@ let mkILNonGenericInstanceProperty (name, ilType, propertyAttribute, customAttri customAttrs = customAttributes ) -let mkLocalPrivateAttributeWithPropertyConstructors (g: TcGlobals, name: string, attrProperties: (string * ILType) list option) = +type AttrDataGenerationStyle = + | PublicFields + | EncapsulatedProperties + +let getFieldMemberAccess = + function + | PublicFields -> ILMemberAccess.Private + | EncapsulatedProperties -> ILMemberAccess.Public + +let mkLocalPrivateAttributeWithPropertyConstructors + ( + g: TcGlobals, + name: string, + attrProperties: (string * ILType) list option, + codegenStyle: AttrDataGenerationStyle + ) = let ilTypeRef = mkILTyRef (ILScopeRef.Local, name) let ilTy = mkILFormalNamedTy ILBoxity.AsObject ilTypeRef [] @@ -75,21 +90,34 @@ let mkLocalPrivateAttributeWithPropertyConstructors (g: TcGlobals, name: string, attrProperties |> Option.defaultValue [] |> List.map (fun (name, ilType) -> - let fieldName = name + "@" - - (g.AddFieldGeneratedAttributes(mkILInstanceField (fieldName, ilType, None, ILMemberAccess.Private))), - (g.AddMethodGeneratedAttributes(mkLdfldMethodDef ($"get_{name}", ILMemberAccess.Public, false, ilTy, fieldName, ilType, []))), - (g.AddPropertyGeneratedAttributes( - mkILNonGenericInstanceProperty ( - name, - ilType, - PropertyAttributes.None, - emptyILCustomAttrs, - Some(mkILMethRef (ilTypeRef, ILCallingConv.Instance, "get_" + name, 0, [], ilType)), - None - ) - )), - (name, fieldName, ilType)) + match codegenStyle with + | PublicFields -> + (g.AddFieldGeneratedAttributes(mkILInstanceField (name, ilType, None, getFieldMemberAccess codegenStyle))), + [], + [], + (name, name, ilType) + | EncapsulatedProperties -> + let fieldName = name + "@" + + (g.AddFieldGeneratedAttributes(mkILInstanceField (fieldName, ilType, None, getFieldMemberAccess codegenStyle))), + [ + g.AddMethodGeneratedAttributes( + mkLdfldMethodDef ($"get_{name}", ILMemberAccess.Public, false, ilTy, fieldName, ilType, []) + ) + ], + [ + g.AddPropertyGeneratedAttributes( + mkILNonGenericInstanceProperty ( + name, + ilType, + PropertyAttributes.None, + emptyILCustomAttrs, + Some(mkILMethRef (ilTypeRef, ILCallingConv.Instance, "get_" + name, 0, [], ilType)), + None + ) + ) + ], + (name, fieldName, ilType)) // Generate constructor with required arguments let ilCtorDef = @@ -113,11 +141,11 @@ let mkLocalPrivateAttributeWithPropertyConstructors (g: TcGlobals, name: string, ILTypes.Empty, mkILMethods ( ilCtorDef - :: (ilElements |> List.fold (fun acc (_, getter, _, _) -> getter :: acc) []) + :: (ilElements |> List.fold (fun acc (_, getter, _, _) -> getter @ acc) []) ), mkILFields (ilElements |> List.map (fun (field, _, _, _) -> field)), emptyILTypeDefs, - mkILProperties (ilElements |> List.map (fun (_, _, property, _) -> property)), + mkILProperties (ilElements |> List.collect (fun (_, _, props, _) -> props)), emptyILEvents, emptyILCustomAttrs, ILTypeInit.BeforeField @@ -159,6 +187,7 @@ let mkLocalPrivateAttributeWithByteAndByteArrayConstructors (g: TcGlobals, name: mkLdarg0 // Prepare 'this' to be on bottom of the stack mkLdcInt32 1 I_newarr(ILArrayShape.SingleDimensional, scalarValueIlType) // new byte[1] + AI_dup // Duplicate the array pointer in stack, 1 for stelem and 1 for stfld mkLdcInt32 0 mkLdarg 1us I_stelem DT_I1 // array[0] = argument from .ctor @@ -271,7 +300,7 @@ let GetDynamicDependencyAttribute (g: TcGlobals) memberTypes (ilType: ILType) = let properties = Some [ "MemberType", GetDynamicallyAccessedMemberTypes g; "Type", g.ilg.typ_Type ] - mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, properties)) + mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, properties, EncapsulatedProperties)) ) let typIlMemberTypes = @@ -284,6 +313,22 @@ let GetDynamicDependencyAttribute (g: TcGlobals) memberTypes (ilType: ILType) = [] ) +/// Generates NullableContextAttribute[1], which has the meaning of: +/// Nested items not being annotated with Nullable attribute themselves are interpreted as being withoutnull +/// Doing it that way is a heuristical decision supporting limited usage of (| null) annotations and not allowing nulls in >50% of F# code +/// (if majority of fields/parameters/return values would be nullable, this heuristic would lead to bloat of generated metadata) +let GetNullableContextAttribute (g: TcGlobals) = + let tref = g.attrib_NullableContextAttribute.TypeRef + + g.TryEmbedILType( + tref, + (fun () -> + let properties = Some [ "Flag", g.ilg.typ_Byte ] + mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, properties, PublicFields)) + ) + + mkILCustomAttribute (tref, [ g.ilg.typ_Byte ], [ ILAttribElem.Byte 1uy ], []) + let GetNullableAttribute (g: TcGlobals) (nullnessInfos: TypedTree.NullnessInfo list) = let tref = g.attrib_NullableAttribute.TypeRef @@ -388,7 +433,12 @@ let GenNullnessIfNecessary (g: TcGlobals) ty = // Optimizations as done in C# :: If the byte[] is empty, the NullableAttribute is omitted. | [] -> None // Optimizations as done in C# :: If all values in the byte[] are the same, the NullableAttribute is constructed with that single byte value. - | head :: tail when tail |> List.forall ((=) head) -> GetNullableAttribute g [ head ] |> Some + | head :: tail when tail |> List.forall ((=) head) -> + match head with + // For F# code, each type has an automatically generated NullableContextAttribute(1) + // That means an implicit (hidden, not generated) Nullable(1) attribute + | NullnessInfo.WithoutNull -> None + | _ -> GetNullableAttribute g [ head ] |> Some | nonUniformList -> GetNullableAttribute g nonUniformList |> Some else None diff --git a/src/Compiler/CodeGen/IlxGenSupport.fsi b/src/Compiler/CodeGen/IlxGenSupport.fsi index 7310d245b25..36493718a91 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fsi +++ b/src/Compiler/CodeGen/IlxGenSupport.fsi @@ -23,3 +23,4 @@ val GenAdditionalAttributesForTy: g: TcGlobals -> ty: TypedTree.TType -> ILAttri val GetReadOnlyAttribute: g: TcGlobals -> ILAttribute val GetIsUnmanagedAttribute: g: TcGlobals -> ILAttribute val GetNullableAttribute: g: TcGlobals -> nullnessInfos: TypedTree.NullnessInfo list -> ILAttribute +val GetNullableContextAttribute: g: TcGlobals -> ILAttribute diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index 10a2282cc8c..e9b94b9d3ce 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -8,7 +8,23 @@ open FSharp.Test.Compiler module NullnessMetadata = [] - let ``Nullable attribute gets generated``() = + let ``Nullable attribute gets generated for module level values``() = + FSharp """ +module MyTestModule + +let notNullStringField : string = "" +let nullableStringField : string | null = null +let nullableNestedList : list | null> | null = null +let nullableInt : System.Nullable = System.Nullable() +let regularInt = 42""" + |> withLangVersionPreview + |> withOptions ["--checknulls"] + |> compile + |> shouldSucceed + |> verifyIL [""" abc """] + + [] + let ``Nullable attribute gets generated for function parameters and return types``() = FSharp """ module MyTestModule From b2ca9acd924dba2b9a02e00f100a15703c648954 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 19 Sep 2023 15:18:12 +0200 Subject: [PATCH 12/33] Updating tests to reflect space reduction heuristics --- src/Compiler/CodeGen/IlxGenSupport.fs | 8 ++++---- .../EmittedIL/Nullness/NullnessMetadata.fs | 8 -------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index e7cfdc9190b..63be4542828 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -73,8 +73,8 @@ type AttrDataGenerationStyle = let getFieldMemberAccess = function - | PublicFields -> ILMemberAccess.Private - | EncapsulatedProperties -> ILMemberAccess.Public + | PublicFields -> ILMemberAccess.Public + | EncapsulatedProperties -> ILMemberAccess.Private let mkLocalPrivateAttributeWithPropertyConstructors ( @@ -323,8 +323,8 @@ let GetNullableContextAttribute (g: TcGlobals) = g.TryEmbedILType( tref, (fun () -> - let properties = Some [ "Flag", g.ilg.typ_Byte ] - mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, properties, PublicFields)) + let fields = Some [ "Flag", g.ilg.typ_Byte ] + mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, fields, PublicFields)) ) mkILCustomAttribute (tref, [ g.ilg.typ_Byte ], [ ILAttribElem.Byte 1uy ], []) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index e9b94b9d3ce..4481a946a33 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -44,10 +44,6 @@ let multiArgumentTest (x:string) (y:string | null) = 42 |> verifyIL [""" .method public static string nonNullableInputOutputFunc(string x) cil managed { -.param [0] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) -.param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -101,8 +97,6 @@ IL_0001: ret { .param [0] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) -.param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .param [2] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) @@ -137,8 +131,6 @@ IL_0001: ret string y) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) -.param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .param [2] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) From a0a7d7386d491ec3b721c7be99b22b6f3d9bd111 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 19 Sep 2023 16:40:53 +0200 Subject: [PATCH 13/33] Emit field level nullable attributes --- src/Compiler/CodeGen/IlxGen.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index ec07e2d5bf8..6e04ccec121 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -10836,7 +10836,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = literalValue = None, offset = ilFieldOffset, marshal = None, - customAttrs = mkILCustomAttrs (GenAttrs cenv eenv fattribs @ extraAttribs) + customAttrs = mkILCustomAttrs (GenAttrs cenv eenv fattribs @ extraAttribs @ GenAdditionalAttributesForTy g fspec.FormalType ) ) .WithAccess(access) .WithStatic(isStatic) From 33ca5c0d46445f827303c75f071b955dc86058f4 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 20 Sep 2023 12:45:51 +0200 Subject: [PATCH 14/33] tests coverage it emitted IL --- .../EmittedIL/Nullness/AnonRecords.fs | 14 + .../EmittedIL/Nullness/AnonRecords.fs.il.bsl | 750 ++++++++++++++++++ .../EmittedIL/Nullness/CurriedFunctions.fs | 10 + .../Nullness/CurriedFunctions.fs.il.bsl | 203 +++++ .../EmittedIL/Nullness/CustomType.fs | 20 + .../EmittedIL/Nullness/CustomType.fs.il.bsl | 277 +++++++ .../EmittedIL/Nullness/ModuleLevelBindings.fs | 7 + .../Nullness/ModuleLevelBindings.fs.il.bsl | 168 ++++ .../Nullness/ModuleLevelFunctions.fs | 10 + .../Nullness/ModuleLevelFunctions.fs.il.bsl | 214 +++++ .../Nullness/ModuleLevelFunctionsOpt.fs | 10 + .../ModuleLevelFunctionsOpt.fs.il.bsl | 211 +++++ .../EmittedIL/Nullness/NullnessMetadata.fs | 196 ++--- .../EmittedIL/Nullness/Records.fs | 25 + .../EmittedIL/Nullness/Records.fs.il.bsl | 366 +++++++++ .../EmittedIL/Nullness/ReferenceDU.fs | 18 + .../EmittedIL/Nullness/ReferenceDU.fs.il.bsl | 670 ++++++++++++++++ .../EmittedIL/Nullness/StructDU.fs | 13 + .../EmittedIL/Nullness/StructDU.fs.il.bsl | 354 +++++++++ 19 files changed, 3402 insertions(+), 134 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs new file mode 100644 index 00000000000..1178f3e704e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs @@ -0,0 +1,14 @@ +module MyTestModule + +let justInt = 42 +let maybeString : string | null = null +let maybeListOfMaybeString : List<_> | null = [maybeString] + +let giveMeA () = + {| A = maybeString; B = maybeListOfMaybeString; C = justInt|} + +let giveMeB () = + {| A = justInt; B = justInt; C = justInt|} + +let giveMeC () = + {| A = maybeString; B = maybeString; C = maybeString|} \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.bsl new file mode 100644 index 00000000000..0e9cafe159f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.bsl @@ -0,0 +1,750 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .method public specialname static int32 + get_justInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.s 42 + IL_0002: ret + } + + .method public specialname static string + get_maybeString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + get_maybeListOfMaybeString() cil managed + { + + .maxstack 8 + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 ''.$MyTestModule::maybeListOfMaybeString@5 + IL_0005: ret + } + + .method public static class '<>f__AnonymousType2430756162`3',int32> + giveMeA() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) + + .maxstack 8 + IL_0000: call string MyTestModule::get_maybeString() + IL_0005: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 MyTestModule::get_maybeListOfMaybeString() + IL_000a: call int32 MyTestModule::get_justInt() + IL_000f: newobj instance void class '<>f__AnonymousType2430756162`3',int32>::.ctor(!0, + !1, + !2) + IL_0014: ret + } + + .method public static class '<>f__AnonymousType2430756162`3' + giveMeB() cil managed + { + + .maxstack 8 + IL_0000: call int32 MyTestModule::get_justInt() + IL_0005: call int32 MyTestModule::get_justInt() + IL_000a: call int32 MyTestModule::get_justInt() + IL_000f: newobj instance void class '<>f__AnonymousType2430756162`3'::.ctor(!0, + !1, + !2) + IL_0014: ret + } + + .method public static class '<>f__AnonymousType2430756162`3' + giveMeC() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) + + .maxstack 8 + IL_0000: call string MyTestModule::get_maybeString() + IL_0005: call string MyTestModule::get_maybeString() + IL_000a: call string MyTestModule::get_maybeString() + IL_000f: newobj instance void class '<>f__AnonymousType2430756162`3'::.ctor(!0, + !1, + !2) + IL_0014: ret + } + + .property int32 justInt() + { + .get int32 MyTestModule::get_justInt() + } + .property string maybeString() + { + .get string MyTestModule::get_maybeString() + } + .property class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + maybeListOfMaybeString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 09 00 00 00 00 00 ) + .get class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 MyTestModule::get_maybeListOfMaybeString() + } +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field static assembly initonly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 maybeListOfMaybeString@5 + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field static assembly int32 init@ + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 8 + IL_0000: call string MyTestModule::get_maybeString() + IL_0005: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_000a: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::Cons(!0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1) + IL_000f: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 ''.$MyTestModule::maybeListOfMaybeString@5 + IL_0014: ret + } + +} + +.class public auto ansi serializable sealed beforefieldinit '<>f__AnonymousType2430756162`3'<'j__TPar','j__TPar','j__TPar'> + extends [runtime]System.Object + implements [runtime]System.Collections.IStructuralComparable, + [runtime]System.IComparable, + class [runtime]System.IComparable`1f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>>, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IEquatable`1f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>> +{ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field private !'j__TPar' A@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private !'j__TPar' B@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private !'j__TPar' C@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(!'j__TPar' A, + !'j__TPar' B, + !'j__TPar' C) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 1E 3C 3E 66 5F 5F 41 6E 6F 6E + 79 6D 6F 75 73 54 79 70 65 32 34 33 30 37 35 36 + 31 36 32 60 33 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0014: ldarg.0 + IL_0015: ldarg.3 + IL_0016: stfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_001b: ret + } + + .method public hidebysig specialname instance !'j__TPar' + get_A() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0006: ret + } + + .method public hidebysig specialname instance !'j__TPar' + get_B() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0006: ret + } + + .method public hidebysig specialname instance !'j__TPar' + get_C() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0006: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToStringf__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>,string>::Invoke(!0) + IL_0015: ret + } + + .method public hidebysig virtual final + instance int32 CompareTo(class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (int32 V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0067 + + IL_0003: ldarg.1 + IL_0004: brfalse.s IL_0065 + + IL_0006: call class [runtime]System.Collections.IComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericComparer() + IL_000b: ldarg.0 + IL_000c: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0011: ldarg.1 + IL_0012: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0017: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: ldc.i4.0 + IL_001f: bge.s IL_0023 + + IL_0021: ldloc.0 + IL_0022: ret + + IL_0023: ldloc.0 + IL_0024: ldc.i4.0 + IL_0025: ble.s IL_0029 + + IL_0027: ldloc.0 + IL_0028: ret + + IL_0029: call class [runtime]System.Collections.IComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericComparer() + IL_002e: ldarg.0 + IL_002f: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0034: ldarg.1 + IL_0035: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_003a: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_003f: stloc.1 + IL_0040: ldloc.1 + IL_0041: ldc.i4.0 + IL_0042: bge.s IL_0046 + + IL_0044: ldloc.1 + IL_0045: ret + + IL_0046: ldloc.1 + IL_0047: ldc.i4.0 + IL_0048: ble.s IL_004c + + IL_004a: ldloc.1 + IL_004b: ret + + IL_004c: call class [runtime]System.Collections.IComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericComparer() + IL_0051: ldarg.0 + IL_0052: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0057: ldarg.1 + IL_0058: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_005d: tail. + IL_005f: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_0064: ret + + IL_0065: ldc.i4.1 + IL_0066: ret + + IL_0067: ldarg.1 + IL_0068: brfalse.s IL_006c + + IL_006a: ldc.i4.m1 + IL_006b: ret + + IL_006c: ldc.i4.0 + IL_006d: ret + } + + .method public hidebysig virtual final + instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: unbox.any class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0007: tail. + IL_0009: callvirt instance int32 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::CompareTo(class '<>f__AnonymousType2430756162`3') + IL_000e: ret + } + + .method public hidebysig virtual final + instance int32 CompareTo(object obj, + class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_0, + class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_1, + int32 V_2, + int32 V_3) + IL_0000: ldarg.1 + IL_0001: unbox.any class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldarg.0 + IL_000a: brfalse.s IL_0069 + + IL_000c: ldarg.1 + IL_000d: unbox.any class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0012: brfalse.s IL_0067 + + IL_0014: ldarg.2 + IL_0015: ldarg.0 + IL_0016: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_001b: ldloc.1 + IL_001c: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0021: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_0026: stloc.2 + IL_0027: ldloc.2 + IL_0028: ldc.i4.0 + IL_0029: bge.s IL_002d + + IL_002b: ldloc.2 + IL_002c: ret + + IL_002d: ldloc.2 + IL_002e: ldc.i4.0 + IL_002f: ble.s IL_0033 + + IL_0031: ldloc.2 + IL_0032: ret + + IL_0033: ldarg.2 + IL_0034: ldarg.0 + IL_0035: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_003a: ldloc.1 + IL_003b: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0040: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_0045: stloc.3 + IL_0046: ldloc.3 + IL_0047: ldc.i4.0 + IL_0048: bge.s IL_004c + + IL_004a: ldloc.3 + IL_004b: ret + + IL_004c: ldloc.3 + IL_004d: ldc.i4.0 + IL_004e: ble.s IL_0052 + + IL_0050: ldloc.3 + IL_0051: ret + + IL_0052: ldarg.2 + IL_0053: ldarg.0 + IL_0054: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0059: ldloc.1 + IL_005a: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_005f: tail. + IL_0061: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_0066: ret + + IL_0067: ldc.i4.1 + IL_0068: ret + + IL_0069: ldarg.1 + IL_006a: unbox.any class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_006f: brfalse.s IL_0073 + + IL_0071: ldc.i4.m1 + IL_0072: ret + + IL_0073: ldc.i4.0 + IL_0074: ret + } + + .method public hidebysig virtual final + instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 7 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0058 + + IL_0003: ldc.i4.0 + IL_0004: stloc.0 + IL_0005: ldc.i4 0x9e3779b9 + IL_000a: ldarg.1 + IL_000b: ldarg.0 + IL_000c: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0011: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericHashWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0) + IL_0016: ldloc.0 + IL_0017: ldc.i4.6 + IL_0018: shl + IL_0019: ldloc.0 + IL_001a: ldc.i4.2 + IL_001b: shr + IL_001c: add + IL_001d: add + IL_001e: add + IL_001f: stloc.0 + IL_0020: ldc.i4 0x9e3779b9 + IL_0025: ldarg.1 + IL_0026: ldarg.0 + IL_0027: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_002c: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericHashWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0) + IL_0031: ldloc.0 + IL_0032: ldc.i4.6 + IL_0033: shl + IL_0034: ldloc.0 + IL_0035: ldc.i4.2 + IL_0036: shr + IL_0037: add + IL_0038: add + IL_0039: add + IL_003a: stloc.0 + IL_003b: ldc.i4 0x9e3779b9 + IL_0040: ldarg.1 + IL_0041: ldarg.0 + IL_0042: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0047: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericHashWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0) + IL_004c: ldloc.0 + IL_004d: ldc.i4.6 + IL_004e: shl + IL_004f: ldloc.0 + IL_0050: ldc.i4.2 + IL_0051: shr + IL_0052: add + IL_0053: add + IL_0054: add + IL_0055: stloc.0 + IL_0056: ldloc.0 + IL_0057: ret + + IL_0058: ldc.i4.0 + IL_0059: ret + } + + .method public hidebysig virtual final + instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: tail. + IL_0008: callvirt instance int32 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000d: ret + } + + .method public hidebysig virtual final + instance bool Equals(object obj, + class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_0, + class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_1) + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0052 + + IL_0003: ldarg.1 + IL_0004: isinst class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0009: stloc.0 + IL_000a: ldloc.0 + IL_000b: brfalse.s IL_0050 + + IL_000d: ldloc.0 + IL_000e: stloc.1 + IL_000f: ldarg.2 + IL_0010: ldarg.0 + IL_0011: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0016: ldloc.1 + IL_0017: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_001c: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0, + !!0) + IL_0021: brfalse.s IL_004e + + IL_0023: ldarg.2 + IL_0024: ldarg.0 + IL_0025: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_002a: ldloc.1 + IL_002b: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0030: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0, + !!0) + IL_0035: brfalse.s IL_004c + + IL_0037: ldarg.2 + IL_0038: ldarg.0 + IL_0039: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_003e: ldloc.1 + IL_003f: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0044: tail. + IL_0046: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0, + !!0) + IL_004b: ret + + IL_004c: ldc.i4.0 + IL_004d: ret + + IL_004e: ldc.i4.0 + IL_004f: ret + + IL_0050: ldc.i4.0 + IL_0051: ret + + IL_0052: ldarg.1 + IL_0053: ldnull + IL_0054: cgt.un + IL_0056: ldc.i4.0 + IL_0057: ceq + IL_0059: ret + } + + .method public hidebysig virtual final + instance bool Equals(class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 4 + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0046 + + IL_0003: ldarg.1 + IL_0004: brfalse.s IL_0044 + + IL_0006: ldarg.0 + IL_0007: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_000c: ldarg.1 + IL_000d: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0012: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityERj__TPar'>(!!0, + !!0) + IL_0017: brfalse.s IL_0042 + + IL_0019: ldarg.0 + IL_001a: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_001f: ldarg.1 + IL_0020: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0025: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityERj__TPar'>(!!0, + !!0) + IL_002a: brfalse.s IL_0040 + + IL_002c: ldarg.0 + IL_002d: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0032: ldarg.1 + IL_0033: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0038: tail. + IL_003a: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityERj__TPar'>(!!0, + !!0) + IL_003f: ret + + IL_0040: ldc.i4.0 + IL_0041: ret + + IL_0042: ldc.i4.0 + IL_0043: ret + + IL_0044: ldc.i4.0 + IL_0045: ret + + IL_0046: ldarg.1 + IL_0047: ldnull + IL_0048: cgt.un + IL_004a: ldc.i4.0 + IL_004b: ceq + IL_004d: ret + } + + .method public hidebysig virtual final + instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 4 + .locals init (class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_0) + IL_0000: ldarg.1 + IL_0001: isinst class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_0014 + + IL_000a: ldarg.0 + IL_000b: ldloc.0 + IL_000c: tail. + IL_000e: callvirt instance bool class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::Equals(class '<>f__AnonymousType2430756162`3') + IL_0013: ret + + IL_0014: ldc.i4.0 + IL_0015: ret + } + + .property instance !'j__TPar' A() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 ) + .get instance !'j__TPar' '<>f__AnonymousType2430756162`3'::get_A() + } + .property instance !'j__TPar' B() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 ) + .get instance !'j__TPar' '<>f__AnonymousType2430756162`3'::get_B() + } + .property instance !'j__TPar' C() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 ) + .get instance !'j__TPar' '<>f__AnonymousType2430756162`3'::get_C() + } +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs new file mode 100644 index 00000000000..7245cd2cd8e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs @@ -0,0 +1,10 @@ +module MyTestModule + +type Maybe<'T> = 'T | null +type MaybeString = string | null + +let curried3Func (a:MaybeString) (b:string) (c:int) = (a,b,c) + +let partiallyAplied (propperString:string) = curried3Func propperString + +let secondOutOfTriple (a,b,c) d e : Maybe<_> = b \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl new file mode 100644 index 00000000000..8eb27f1765d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl @@ -0,0 +1,203 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit partiallyAplied@8 + extends class [FSharp.Core]Microsoft.FSharp.Core.OptimizedClosures/FSharpFunc`3> + { + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field public string propperString + .method assembly specialname rtspecialname + instance void .ctor(string propperString) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.OptimizedClosures/FSharpFunc`3>::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld string MyTestModule/partiallyAplied@8::propperString + IL_000d: ret + } + + .method public strict virtual instance class [runtime]System.Tuple`3 + Invoke(string b, + int32 c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string MyTestModule/partiallyAplied@8::propperString + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: newobj instance void class [runtime]System.Tuple`3::.ctor(!0, + !1, + !2) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Tuple`3 + curried3Func(string a, + string b, + int32 c) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 02 01 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: newobj instance void class [runtime]System.Tuple`3::.ctor(!0, + !1, + !2) + IL_0008: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>> + partiallyAplied(string propperString) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 06 00 00 00 01 01 01 01 02 01 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void MyTestModule/partiallyAplied@8::.ctor(string) + IL_0006: ret + } + + .method public static !!b secondOutOfTriple(!!a a, + !!b b, + !!c c, + !!d d, + !!e e) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 03 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + .param type a + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type b + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type c + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type d + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type e + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs new file mode 100644 index 00000000000..d6892936aac --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs @@ -0,0 +1,20 @@ +module rec MyTestModule + +type MaybeString = string | null +type MaybeMyCustomType = (MyCustomType | null) + +type MyCustomType (x: MaybeString, y: string) = + + static let mutable uglyGlobalMutableString : string = "" + static let mutable uglyGlobalMutableNullableString : MaybeString = null + + member val Nullable = x + member val NonNullable = y + member val JustSomeInt = 42 + + static member GiveMeNull() : MaybeString = null + static member GiveMeString() : string = "" + + member this.UnitFunc() = () + member this.GetThis() = this + member this.GetThisOrNull() : MaybeMyCustomType = null \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl new file mode 100644 index 00000000000..90efd10b6d0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl @@ -0,0 +1,277 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public Myassembly + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field static assembly string uglyGlobalMutableString + .field static assembly string uglyGlobalMutableNullableString + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .field assembly string Nullable@ + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .field assembly string NonNullable@ + .field assembly int32 JustSomeInt@ + .field static assembly int32 init@6 + .method public specialname rtspecialname + instance void .ctor(string x, + string y) cil managed + { + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld string MyTestModule/Myassembly::Nullable@ + IL_000f: ldarg.0 + IL_0010: ldarg.2 + IL_0011: stfld string MyTestModule/Myassembly::NonNullable@ + IL_0016: ldarg.0 + IL_0017: ldc.i4.s 42 + IL_0019: stfld int32 MyTestModule/Myassembly::JustSomeInt@ + IL_001e: ret + } + + .method public hidebysig specialname + instance string get_Nullable() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string MyTestModule/Myassembly::Nullable@ + IL_0006: ret + } + + .method public hidebysig specialname + instance string get_NonNullable() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string MyTestModule/Myassembly::NonNullable@ + IL_0006: ret + } + + .method public hidebysig specialname + instance int32 get_JustSomeInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 MyTestModule/Myassembly::JustSomeInt@ + IL_0006: ret + } + + .method public static string GiveMeNull() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public static string GiveMeString() cil managed + { + + .maxstack 8 + IL_0000: ldstr "" + IL_0005: ret + } + + .method public hidebysig instance void + UnitFunc() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance class MyTestModule/Myassembly + GetThis() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public hidebysig instance class MyTestModule/Myassembly + GetThisOrNull() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$MyTestModule::init@ + IL_0006: ldsfld int32 ''.$MyTestModule::init@ + IL_000b: pop + IL_000c: ret + } + + .property instance string Nullable() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .get instance string MyTestModule/Myassembly::get_Nullable() + } + .property instance string NonNullable() + { + .get instance string MyTestModule/Myassembly::get_NonNullable() + } + .property instance int32 JustSomeInt() + { + .get instance int32 MyTestModule/Myassembly::get_JustSomeInt() + } + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field static assembly int32 init@ + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldstr "" + IL_0005: stsfld string MyTestModule/Myassembly::uglyGlobalMutableString + IL_000a: ldc.i4.2 + IL_000b: volatile. + IL_000d: stsfld int32 MyTestModule/Myassembly::init@6 + IL_0012: ldnull + IL_0013: stsfld string MyTestModule/Myassembly::uglyGlobalMutableNullableString + IL_0018: ldc.i4.3 + IL_0019: volatile. + IL_001b: stsfld int32 MyTestModule/Myassembly::init@6 + IL_0020: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs new file mode 100644 index 00000000000..296f0e92baa --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs @@ -0,0 +1,7 @@ +module MyTestModule + +let notNullStringField : string = "" +let nullableStringField : string | null = null +let mutable nullableMutableStringField : string | null = null +let nullableInt : System.Nullable = System.Nullable() +let regularInt = 42 \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl new file mode 100644 index 00000000000..6233a25a762 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl @@ -0,0 +1,168 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .method public specialname static string + get_notNullStringField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "" + IL_0005: ret + } + + .method public specialname static string + get_nullableStringField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public specialname static string + get_nullableMutableStringField() cil managed + { + + .maxstack 8 + IL_0000: ldsfld string ''.$MyTestModule::nullableMutableStringField@5 + IL_0005: ret + } + + .method public specialname static void + set_nullableMutableStringField(string 'value') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: stsfld string ''.$MyTestModule::nullableMutableStringField@5 + IL_0006: ret + } + + .method public specialname static valuetype [runtime]System.Nullable`1 + get_nullableInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype [runtime]System.Nullable`1 V_0) + IL_0000: ldloc.0 + IL_0001: ret + } + + .method public specialname static int32 + get_regularInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.s 42 + IL_0002: ret + } + + .property string notNullStringField() + { + .get string MyTestModule::get_notNullStringField() + } + .property string nullableStringField() + { + .get string MyTestModule::get_nullableStringField() + } + .property string nullableMutableStringField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 09 00 00 00 00 00 ) + .set void MyTestModule::set_nullableMutableStringField(string) + .get string MyTestModule::get_nullableMutableStringField() + } + .property valuetype [runtime]System.Nullable`1 + nullableInt() + { + .get valuetype [runtime]System.Nullable`1 MyTestModule::get_nullableInt() + } + .property int32 regularInt() + { + .get int32 MyTestModule::get_regularInt() + } +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field static assembly string nullableMutableStringField@5 + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field static assembly int32 init@ + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: stsfld string ''.$MyTestModule::nullableMutableStringField@5 + IL_0006: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs new file mode 100644 index 00000000000..5b7efae9b87 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs @@ -0,0 +1,10 @@ +module MyTestModule + +let nonNullableInputOutputFunc (x:string) = x +let nullableStringInputOutputFunc (x: string | null) = x +let nonNullableIntFunc (x:int) = x +let nullableIntFunc (x:System.Nullable) = x +let genericValueTypeTest (x: struct(string * (string|null) * int * int * int * int)) = x +let genericRefTypeTest (x: string * (string|null) * int * int * int * int) = x +let nestedGenericsTest (x: list | null> | null) = x +let multiArgumentTest (x:string) (y:string | null) = 42 \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs.il.bsl new file mode 100644 index 00000000000..ad450d7738c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs.il.bsl @@ -0,0 +1,214 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .method public static string nonNullableInputOutputFunc(string x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static string nullableStringInputOutputFunc(string x) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static int32 nonNullableIntFunc(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static valuetype [runtime]System.Nullable`1 + nullableIntFunc(valuetype [runtime]System.Nullable`1 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static valuetype [runtime]System.ValueTuple`6 + genericValueTypeTest(valuetype [runtime]System.ValueTuple`6 x) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class [runtime]System.Tuple`6 + genericRefTypeTest(string x_0, + string x_1, + int32 x_2, + int32 x_3, + int32 x_4, + int32 x_5) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) + .param [2] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + .locals init (class [runtime]System.Tuple`6 V_0) + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: ldarg.3 + IL_0004: ldarg.s x_4 + IL_0006: ldarg.s x_5 + IL_0008: newobj instance void class [runtime]System.Tuple`6::.ctor(!0, + !1, + !2, + !3, + !4, + !5) + IL_000d: stloc.0 + IL_000e: ldloc.0 + IL_000f: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + nestedGenericsTest(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> x) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static int32 multiArgumentTest(string x, + string y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .param [2] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.s 42 + IL_0002: ret + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs new file mode 100644 index 00000000000..5b7efae9b87 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs @@ -0,0 +1,10 @@ +module MyTestModule + +let nonNullableInputOutputFunc (x:string) = x +let nullableStringInputOutputFunc (x: string | null) = x +let nonNullableIntFunc (x:int) = x +let nullableIntFunc (x:System.Nullable) = x +let genericValueTypeTest (x: struct(string * (string|null) * int * int * int * int)) = x +let genericRefTypeTest (x: string * (string|null) * int * int * int * int) = x +let nestedGenericsTest (x: list | null> | null) = x +let multiArgumentTest (x:string) (y:string | null) = 42 \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs.il.bsl new file mode 100644 index 00000000000..083abbb1f07 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs.il.bsl @@ -0,0 +1,211 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .method public static string nonNullableInputOutputFunc(string x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static string nullableStringInputOutputFunc(string x) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static int32 nonNullableIntFunc(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static valuetype [runtime]System.Nullable`1 + nullableIntFunc(valuetype [runtime]System.Nullable`1 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static valuetype [runtime]System.ValueTuple`6 + genericValueTypeTest(valuetype [runtime]System.ValueTuple`6 x) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class [runtime]System.Tuple`6 + genericRefTypeTest(string x_0, + string x_1, + int32 x_2, + int32 x_3, + int32 x_4, + int32 x_5) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) + .param [2] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: ldarg.2 + IL_0003: ldarg.3 + IL_0004: ldarg.s x_4 + IL_0006: ldarg.s x_5 + IL_0008: newobj instance void class [runtime]System.Tuple`6::.ctor(!0, + !1, + !2, + !3, + !4, + !5) + IL_000d: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + nestedGenericsTest(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> x) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static int32 multiArgumentTest(string x, + string y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .param [2] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.s 42 + IL_0002: ret + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index 4481a946a33..65a0aea4583 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -1,142 +1,70 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace EmittedIL +module EmittedIL.NullnessMetadata open Xunit +open FSharp.Test open FSharp.Test.Compiler -module NullnessMetadata = - - [] - let ``Nullable attribute gets generated for module level values``() = - FSharp """ -module MyTestModule - -let notNullStringField : string = "" -let nullableStringField : string | null = null -let nullableNestedList : list | null> | null = null -let nullableInt : System.Nullable = System.Nullable() -let regularInt = 42""" - |> withLangVersionPreview - |> withOptions ["--checknulls"] - |> compile - |> shouldSucceed - |> verifyIL [""" abc """] - - [] - let ``Nullable attribute gets generated for function parameters and return types``() = - FSharp """ -module MyTestModule - -let nonNullableInputOutputFunc (x:string) = x -let nullableStringInputOutputFunc (x: string | null) = x -let nonNullableIntFunc (x:int) = x -let nullableIntFunc (x:System.Nullable) = x -let genericValueTypeTest (x: struct(string * (string|null) * int * int * int * int)) = x -let genericRefTypeTest (x: string * (string|null) * int * int * int * int) = x -let nestedGenericsTest (x: list | null> | null) = x -let multiArgumentTest (x:string) (y:string | null) = 42 - """ - |> withLangVersionPreview - |> withOptions ["--checknulls"] - |> compile - |> shouldSucceed - |> verifyIL [""" -.method public static string nonNullableInputOutputFunc(string x) cil managed -{ - -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: ret -} """;""" -.method public static string nullableStringInputOutputFunc(string x) cil managed -{ -.param [0] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) -.param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: ret -} """;""" -.method public static int32 nonNullableIntFunc(int32 x) cil managed -{ - -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: ret -} """;""" -.method public static valuetype [runtime]System.Nullable`1 - nullableIntFunc(valuetype [runtime]System.Nullable`1 x) cil managed -{ - -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: ret -} """;""" -.method public static valuetype [runtime]System.ValueTuple`6 - genericValueTypeTest(valuetype [runtime]System.ValueTuple`6 x) cil managed -{ -.param [0] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) -.param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) - -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: ret -} """;""" -.method public static class [runtime]System.Tuple`6 - genericRefTypeTest(string x_0, - string x_1, - int32 x_2, - int32 x_3, - int32 x_4, - int32 x_5) cil managed -{ -.param [0] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) -.param [2] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: ldarg.1 -IL_0002: ldarg.2 -IL_0003: ldarg.3 -IL_0004: ldarg.s x_4 -IL_0006: ldarg.s x_5 -IL_0008: newobj instance void class [runtime]System.Tuple`6::.ctor(!0, - !1, - !2, - !3, - !4, - !5) -IL_000d: ret -} """;""" -.method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> - nestedGenericsTest(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> x) cil managed -{ -.param [0] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) -.param [1] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: ret -} """;""" -.method public static int32 multiArgumentTest(string x, - string y) cil managed -{ -.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) -.param [2] -.custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - -.maxstack 8 -IL_0000: ldc.i4.s 42 -IL_0002: ret -} """;] +type Optimize = Optimize | DoNotOptimize + +let verifyCompilation (o:Optimize) compilation = + compilation + |> withLangVersionPreview + |> withOptions ["--checknulls"] + |> (match o with | Optimize -> withOptimize | DoNotOptimize -> withNoOptimize) + |> withNoDebug + |> withNoInterfaceData + |> withNoOptimizationData + |> asLibrary + |> verifyILBaseline + +[] +let ``Nullable attr for module bindings`` compilation = + compilation + |> verifyCompilation DoNotOptimize + +[] +let ``Nullable attr for module functions`` compilation = + compilation + |> verifyCompilation DoNotOptimize + +[] +let ``Nullable attr for module functions optimize`` compilation = + compilation + |> verifyCompilation Optimize + +[] +let ``Nullable attr for curriedFunc optimize`` compilation = + compilation + |> verifyCompilation Optimize + +[] +let ``Nullable attr for anon records`` compilation = + compilation + |> verifyCompilation DoNotOptimize + +[] +let ``Nullable attr for records`` compilation = + compilation + |> verifyCompilation DoNotOptimize + +[] +let ``Nullable attr for ref DUs`` compilation = + compilation + |> verifyCompilation DoNotOptimize + +[] +let ``Nullable attr for struct DUs`` compilation = + compilation + |> verifyCompilation DoNotOptimize + +[] +let ``Nullable attr for custom type`` compilation = + compilation + |> verifyCompilation DoNotOptimize + + + \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs new file mode 100644 index 00000000000..2a2c7a09b7e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs @@ -0,0 +1,25 @@ +module MyTestModule + +let maybeString : string | null = null + +[] +type MyRecord<'X,'Y,'Z when 'Y:null and 'Z:not null> = + { + JustInt : int + NullInt : System.Nullable + JustString : string + NullableString : string | null + GenericNormalField : 'X + GenericNullableField : 'Y + GenericNotNullField : 'Z } + +let createAnInstance () = + { + JustInt = 42 + NullInt = System.Nullable.op_Implicit(42) + JustString = "" + NullableString = null + GenericNormalField = 42 + GenericNullableField = maybeString + GenericNotNullField = ""} + \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.bsl new file mode 100644 index 00000000000..81a742d6ad4 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.bsl @@ -0,0 +1,366 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class auto ansi serializable sealed nested public beforefieldinit MyRecord`3 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type X + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type Y + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type Z + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field assembly int32 JustInt@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly valuetype [runtime]System.Nullable`1 NullInt@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly string JustString@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly string NullableString@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .field assembly !X GenericNormalField@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly !Y GenericNullableField@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly !Z GenericNotNullField@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .method public hidebysig specialname + instance int32 get_JustInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 class MyTestModule/MyRecord`3::JustInt@ + IL_0006: ret + } + + .method public hidebysig specialname + instance valuetype [runtime]System.Nullable`1 + get_NullInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype [runtime]System.Nullable`1 class MyTestModule/MyRecord`3::NullInt@ + IL_0006: ret + } + + .method public hidebysig specialname + instance string get_JustString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string class MyTestModule/MyRecord`3::JustString@ + IL_0006: ret + } + + .method public hidebysig specialname + instance string get_NullableString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string class MyTestModule/MyRecord`3::NullableString@ + IL_0006: ret + } + + .method public hidebysig specialname + instance !X get_GenericNormalField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 class MyTestModule/MyRecord`3::GenericNormalField@ + IL_0006: ret + } + + .method public hidebysig specialname + instance !Y get_GenericNullableField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !1 class MyTestModule/MyRecord`3::GenericNullableField@ + IL_0006: ret + } + + .method public hidebysig specialname + instance !Z get_GenericNotNullField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !2 class MyTestModule/MyRecord`3::GenericNotNullField@ + IL_0006: ret + } + + .method public specialname rtspecialname + instance void .ctor(int32 justInt, + valuetype [runtime]System.Nullable`1 nullInt, + string justString, + string nullableString, + !X genericNormalField, + !Y genericNullableField, + !Z genericNotNullField) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 17 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 52 65 63 6F 72 64 60 33 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 class MyTestModule/MyRecord`3::JustInt@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld valuetype [runtime]System.Nullable`1 class MyTestModule/MyRecord`3::NullInt@ + IL_0014: ldarg.0 + IL_0015: ldarg.3 + IL_0016: stfld string class MyTestModule/MyRecord`3::JustString@ + IL_001b: ldarg.0 + IL_001c: ldarg.s nullableString + IL_001e: stfld string class MyTestModule/MyRecord`3::NullableString@ + IL_0023: ldarg.0 + IL_0024: ldarg.s genericNormalField + IL_0026: stfld !0 class MyTestModule/MyRecord`3::GenericNormalField@ + IL_002b: ldarg.0 + IL_002c: ldarg.s genericNullableField + IL_002e: stfld !1 class MyTestModule/MyRecord`3::GenericNullableField@ + IL_0033: ldarg.0 + IL_0034: ldarg.s genericNotNullField + IL_0036: stfld !2 class MyTestModule/MyRecord`3::GenericNotNullField@ + IL_003b: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class MyTestModule/MyRecord`3>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .property instance int32 JustInt() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 ) + .get instance int32 MyTestModule/MyRecord`3::get_JustInt() + } + .property instance valuetype [runtime]System.Nullable`1 + NullInt() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 ) + .get instance valuetype [runtime]System.Nullable`1 MyTestModule/MyRecord`3::get_NullInt() + } + .property instance string JustString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 ) + .get instance string MyTestModule/MyRecord`3::get_JustString() + } + .property instance string NullableString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 03 00 00 00 00 00 ) + .get instance string MyTestModule/MyRecord`3::get_NullableString() + } + .property instance !X GenericNormalField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 04 00 00 00 00 00 ) + .get instance !X MyTestModule/MyRecord`3::get_GenericNormalField() + } + .property instance !Y GenericNullableField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 05 00 00 00 00 00 ) + .get instance !Y MyTestModule/MyRecord`3::get_GenericNullableField() + } + .property instance !Z GenericNotNullField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 06 00 00 00 00 00 ) + .get instance !Z MyTestModule/MyRecord`3::get_GenericNotNullField() + } + } + + .method public specialname static string + get_maybeString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public static class MyTestModule/MyRecord`3 + createAnInstance() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 02 01 00 00 ) + + .maxstack 9 + IL_0000: ldc.i4.s 42 + IL_0002: ldc.i4.s 42 + IL_0004: call valuetype [runtime]System.Nullable`1 valuetype [runtime]System.Nullable`1::op_Implicit(!0) + IL_0009: ldstr "" + IL_000e: ldnull + IL_000f: ldc.i4.s 42 + IL_0011: call string MyTestModule::get_maybeString() + IL_0016: ldstr "" + IL_001b: newobj instance void class MyTestModule/MyRecord`3::.ctor(int32, + valuetype [runtime]System.Nullable`1, + string, + string, + !0, + !1, + !2) + IL_0020: ret + } + + .property string maybeString() + { + .get string MyTestModule::get_maybeString() + } +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs new file mode 100644 index 00000000000..b4d87d8293d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs @@ -0,0 +1,18 @@ +module MyTestModule + +[] +type MyDu = + | JustLabel + | JustInt of int + | MaybeString of (string | null) + +let giveMeLabel () = JustLabel + +let createMaybeString (innerValue) = MaybeString innerValue + +let processNullableDu (x : (MyDu | null)) : string | null = + match x with + | null -> null + | JustLabel -> null + | JustInt x -> string x + | MaybeString x -> x \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.bsl new file mode 100644 index 00000000000..a0f5d34249c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.bsl @@ -0,0 +1,670 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly extern netstandard +{ + .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) + .ver 2:1:0:0 +} +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto autochar serializable nested public beforefieldinit MyDu + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .field public static literal int32 JustLabel = int32(0x00000000) + .field public static literal int32 JustInt = int32(0x00000001) + .field public static literal int32 MaybeString = int32(0x00000002) + } + + .class auto ansi serializable nested assembly beforefieldinit specialname _JustLabel + extends MyTestModule/MyDu + { + .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 2B 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B + 4D 79 44 75 2B 5F 4A 75 73 74 4C 61 62 65 6C 40 + 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void MyTestModule/MyDu::.ctor() + IL_0006: ret + } + + } + + .class auto ansi serializable nested public beforefieldinit specialname JustInt + extends MyTestModule/MyDu + { + .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 28 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B + 4D 79 44 75 2B 4A 75 73 74 49 6E 74 40 44 65 62 + 75 67 54 79 70 65 50 72 6F 78 79 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .field assembly initonly int32 item + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int32 item) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void MyTestModule/MyDu::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 MyTestModule/MyDu/JustInt::item + IL_000d: ret + } + + .method public hidebysig instance int32 + get_Item() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 MyTestModule/MyDu/JustInt::item + IL_0006: ret + } + + .property instance int32 Item() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance int32 MyTestModule/MyDu/JustInt::get_Item() + } + } + + .class auto ansi serializable nested public beforefieldinit specialname MaybeString + extends MyTestModule/MyDu + { + .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 2C 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B + 4D 79 44 75 2B 4D 61 79 62 65 53 74 72 69 6E 67 + 40 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 + 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .field assembly initonly string item + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(string item) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void MyTestModule/MyDu::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld string MyTestModule/MyDu/MaybeString::item + IL_000d: ret + } + + .method public hidebysig instance string + get_Item() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string MyTestModule/MyDu/MaybeString::item + IL_0006: ret + } + + .property instance string Item() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string MyTestModule/MyDu/MaybeString::get_Item() + } + } + + .class auto ansi nested assembly beforefieldinit specialname _JustLabel@DebugTypeProxy + extends [runtime]System.Object + { + .field assembly class MyTestModule/MyDu/_JustLabel _obj + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class MyTestModule/MyDu/_JustLabel obj) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class MyTestModule/MyDu/_JustLabel MyTestModule/MyDu/_JustLabel@DebugTypeProxy::_obj + IL_000d: ret + } + + } + + .class auto ansi nested assembly beforefieldinit specialname JustInt@DebugTypeProxy + extends [runtime]System.Object + { + .field assembly class MyTestModule/MyDu/JustInt _obj + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class MyTestModule/MyDu/JustInt obj) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class MyTestModule/MyDu/JustInt MyTestModule/MyDu/JustInt@DebugTypeProxy::_obj + IL_000d: ret + } + + .method public hidebysig instance int32 + get_Item() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class MyTestModule/MyDu/JustInt MyTestModule/MyDu/JustInt@DebugTypeProxy::_obj + IL_0006: ldfld int32 MyTestModule/MyDu/JustInt::item + IL_000b: ret + } + + .property instance int32 Item() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance int32 MyTestModule/MyDu/JustInt@DebugTypeProxy::get_Item() + } + } + + .class auto ansi nested assembly beforefieldinit specialname MaybeString@DebugTypeProxy + extends [runtime]System.Object + { + .field assembly class MyTestModule/MyDu/MaybeString _obj + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class MyTestModule/MyDu/MaybeString obj) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class MyTestModule/MyDu/MaybeString MyTestModule/MyDu/MaybeString@DebugTypeProxy::_obj + IL_000d: ret + } + + .method public hidebysig instance string + get_Item() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class MyTestModule/MyDu/MaybeString MyTestModule/MyDu/MaybeString@DebugTypeProxy::_obj + IL_0006: ldfld string MyTestModule/MyDu/MaybeString::item + IL_000b: ret + } + + .property instance string Item() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string MyTestModule/MyDu/MaybeString@DebugTypeProxy::get_Item() + } + } + + .field static assembly initonly class MyTestModule/MyDu _unique_JustLabel + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 8 + IL_0000: newobj instance void MyTestModule/MyDu/_JustLabel::.ctor() + IL_0005: stsfld class MyTestModule/MyDu MyTestModule/MyDu::_unique_JustLabel + IL_000a: ret + } + + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 E0 07 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ret + } + + .method public static class MyTestModule/MyDu + get_JustLabel() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldsfld class MyTestModule/MyDu MyTestModule/MyDu::_unique_JustLabel + IL_0005: ret + } + + .method public hidebysig instance bool + get_IsJustLabel() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst MyTestModule/MyDu/_JustLabel + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } + + .method public static class MyTestModule/MyDu + NewJustInt(int32 item) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void MyTestModule/MyDu/JustInt::.ctor(int32) + IL_0006: ret + } + + .method public hidebysig instance bool + get_IsJustInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst MyTestModule/MyDu/JustInt + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } + + .method public static class MyTestModule/MyDu + NewMaybeString(string item) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void MyTestModule/MyDu/MaybeString::.ctor(string) + IL_0006: ret + } + + .method public hidebysig instance bool + get_IsMaybeString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst MyTestModule/MyDu/MaybeString + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } + + .method public hidebysig instance int32 + get_Tag() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst MyTestModule/MyDu/MaybeString + IL_0006: brfalse.s IL_000b + + IL_0008: ldc.i4.2 + IL_0009: br.s IL_0017 + + IL_000b: ldarg.0 + IL_000c: isinst MyTestModule/MyDu/JustInt + IL_0011: brfalse.s IL_0016 + + IL_0013: ldc.i4.1 + IL_0014: br.s IL_0017 + + IL_0016: ldc.i4.0 + IL_0017: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0015: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class MyTestModule/MyDu>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0015: ret + } + + .property instance int32 Tag() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance int32 MyTestModule/MyDu::get_Tag() + } + .property class MyTestModule/MyDu JustLabel() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get class MyTestModule/MyDu MyTestModule/MyDu::get_JustLabel() + } + .property instance bool IsJustLabel() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/MyDu::get_IsJustLabel() + } + .property instance bool IsJustInt() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/MyDu::get_IsJustInt() + } + .property instance bool IsMaybeString() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/MyDu::get_IsMaybeString() + } + } + + .method public static class MyTestModule/MyDu + giveMeLabel() cil managed + { + + .maxstack 8 + IL_0000: call class MyTestModule/MyDu MyTestModule/MyDu::get_JustLabel() + IL_0005: ret + } + + .method public static class MyTestModule/MyDu + createMaybeString(string innerValue) cil managed + { + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class MyTestModule/MyDu MyTestModule/MyDu::NewMaybeString(string) + IL_0006: ret + } + + .method public static string processNullableDu(class MyTestModule/MyDu x) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 5 + .locals init (class MyTestModule/MyDu V_0, + class MyTestModule/MyDu V_1, + class MyTestModule/MyDu/JustInt V_2, + int32 V_3, + int32 V_4, + class MyTestModule/MyDu/MaybeString V_5, + string V_6) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: brfalse.s IL_0019 + + IL_0005: ldloc.0 + IL_0006: stloc.1 + IL_0007: ldloc.1 + IL_0008: isinst MyTestModule/MyDu/JustInt + IL_000d: brtrue.s IL_001d + + IL_000f: ldloc.1 + IL_0010: isinst MyTestModule/MyDu/MaybeString + IL_0015: brtrue.s IL_0048 + + IL_0017: br.s IL_001b + + IL_0019: ldnull + IL_001a: ret + + IL_001b: ldnull + IL_001c: ret + + IL_001d: ldloc.0 + IL_001e: castclass MyTestModule/MyDu/JustInt + IL_0023: stloc.2 + IL_0024: ldloc.2 + IL_0025: ldfld int32 MyTestModule/MyDu/JustInt::item + IL_002a: stloc.3 + IL_002b: ldloc.3 + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: box [runtime]System.Int32 + IL_0035: unbox.any [runtime]System.IFormattable + IL_003a: ldnull + IL_003b: call class [netstandard]System.Globalization.CultureInfo [netstandard]System.Globalization.CultureInfo::get_InvariantCulture() + IL_0040: tail. + IL_0042: callvirt instance string [netstandard]System.IFormattable::ToString(string, + class [netstandard]System.IFormatProvider) + IL_0047: ret + + IL_0048: ldloc.0 + IL_0049: castclass MyTestModule/MyDu/MaybeString + IL_004e: stloc.s V_5 + IL_0050: ldloc.s V_5 + IL_0052: ldfld string MyTestModule/MyDu/MaybeString::item + IL_0057: stloc.s V_6 + IL_0059: ldloc.s V_6 + IL_005b: ret + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs new file mode 100644 index 00000000000..4062320867d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs @@ -0,0 +1,13 @@ +module MyTestModule + +[] +[] +type MyStructDU = + | A + | B of nonNullableString:string // Tricky as the field WILL be null for tags other than B + | C of nullableString:(string | null) // The field behind this is always nullable + +let getVal x = + match x with + | B text -> text + | _ -> failwith "fail" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.bsl new file mode 100644 index 00000000000..f08847a4c03 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.bsl @@ -0,0 +1,354 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class sequential autochar serializable sealed nested public beforefieldinit Myassembly + extends [runtime]System.ValueType + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .field public static literal int32 A = int32(0x00000000) + .field public static literal int32 B = int32(0x00000001) + .field public static literal int32 C = int32(0x00000002) + } + + .field assembly string _nonNullableString + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly string _nullableString + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly int32 _tag + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public static valuetype MyTestModule/Myassembly + get_A() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: newobj instance void MyTestModule/Myassembly::.ctor(int32) + IL_0006: ret + } + + .method public hidebysig instance bool + get_IsA() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 MyTestModule/Myassembly::get_Tag() + IL_0006: ldc.i4.0 + IL_0007: ceq + IL_0009: ret + } + + .method public static valuetype MyTestModule/Myassembly + NewB(string _nonNullableString) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 2 + .locals init (valuetype MyTestModule/Myassembly V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj MyTestModule/Myassembly + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.1 + IL_000b: stfld int32 MyTestModule/Myassembly::_tag + IL_0010: ldloca.s V_0 + IL_0012: ldarg.0 + IL_0013: stfld string MyTestModule/Myassembly::_nonNullableString + IL_0018: ldloc.0 + IL_0019: ret + } + + .method public hidebysig instance bool + get_IsB() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 MyTestModule/Myassembly::get_Tag() + IL_0006: ldc.i4.1 + IL_0007: ceq + IL_0009: ret + } + + .method public static valuetype MyTestModule/Myassembly + NewC(string _nullableString) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) + + .maxstack 2 + .locals init (valuetype MyTestModule/Myassembly V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj MyTestModule/Myassembly + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.2 + IL_000b: stfld int32 MyTestModule/Myassembly::_tag + IL_0010: ldloca.s V_0 + IL_0012: ldarg.0 + IL_0013: stfld string MyTestModule/Myassembly::_nullableString + IL_0018: ldloc.0 + IL_0019: ret + } + + .method public hidebysig instance bool + get_IsC() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 MyTestModule/Myassembly::get_Tag() + IL_0006: ldc.i4.2 + IL_0007: ceq + IL_0009: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(int32 _tag) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 17 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 53 74 72 75 63 74 44 55 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 MyTestModule/Myassembly::_tag + IL_0007: ret + } + + .method public hidebysig instance string + get_nonNullableString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string MyTestModule/Myassembly::_nonNullableString + IL_0006: ret + } + + .method public hidebysig instance string + get_nullableString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string MyTestModule/Myassembly::_nullableString + IL_0006: ret + } + + .method public hidebysig instance int32 + get_Tag() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 MyTestModule/Myassembly::_tag + IL_0006: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: ldobj MyTestModule/Myassembly + IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001a: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,valuetype MyTestModule/Myassembly>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: ldobj MyTestModule/Myassembly + IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001a: ret + } + + .property instance int32 Tag() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance int32 MyTestModule/Myassembly::get_Tag() + } + .property valuetype MyTestModule/Myassembly + A() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get valuetype MyTestModule/Myassembly MyTestModule/Myassembly::get_A() + } + .property instance bool IsA() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/Myassembly::get_IsA() + } + .property instance bool IsB() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/Myassembly::get_IsB() + } + .property instance bool IsC() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/Myassembly::get_IsC() + } + .property instance string nonNullableString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string MyTestModule/Myassembly::get_nonNullableString() + } + .property instance string nullableString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string MyTestModule/Myassembly::get_nullableString() + } + } + + .method public static string getVal(valuetype MyTestModule/Myassembly x) cil managed + { + + .maxstack 3 + .locals init (valuetype MyTestModule/Myassembly V_0, + string V_1, + string V_2) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance int32 MyTestModule/Myassembly::get_Tag() + IL_0009: ldc.i4.1 + IL_000a: bne.un.s IL_0016 + + IL_000c: ldloca.s V_0 + IL_000e: ldfld string MyTestModule/Myassembly::_nonNullableString + IL_0013: stloc.1 + IL_0014: ldloc.1 + IL_0015: ret + + IL_0016: ldstr "fail" + IL_001b: stloc.2 + IL_001c: ldloc.2 + IL_001d: call class [runtime]System.Exception [FSharp.Core]Microsoft.FSharp.Core.Operators::Failure(string) + IL_0022: throw + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + From df1e7e8eddc50bde7f4df527417cb31ac0e879ed Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 20 Sep 2023 14:34:07 +0200 Subject: [PATCH 15/33] Separate baselines into net472/netcore in case it needed DynamicAccessedMembers --- .../Nullness/AnonRecords.fs.il.net472.bsl | 843 ++++++++++++++++++ ...s.il.bsl => AnonRecords.fs.il.netcore.bsl} | 0 .../EmittedIL/Nullness/NullnessMetadata.fs | 4 - .../Nullness/Records.fs.il.net472.bsl | 459 ++++++++++ ...ds.fs.il.bsl => Records.fs.il.netcore.bsl} | 0 .../Nullness/ReferenceDU.fs.il.net472.bsl | 763 ++++++++++++++++ ...s.il.bsl => ReferenceDU.fs.il.netcore.bsl} | 0 .../Nullness/StructDU.fs.il.net472.bsl | 447 ++++++++++ ...U.fs.il.bsl => StructDU.fs.il.netcore.bsl} | 0 9 files changed, 2512 insertions(+), 4 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl rename tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/{AnonRecords.fs.il.bsl => AnonRecords.fs.il.netcore.bsl} (100%) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl rename tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/{Records.fs.il.bsl => Records.fs.il.netcore.bsl} (100%) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl rename tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/{ReferenceDU.fs.il.bsl => ReferenceDU.fs.il.netcore.bsl} (100%) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl rename tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/{StructDU.fs.il.bsl => StructDU.fs.il.netcore.bsl} (100%) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl new file mode 100644 index 00000000000..cce90cb41b7 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl @@ -0,0 +1,843 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .method public specialname static int32 + get_justInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.s 42 + IL_0002: ret + } + + .method public specialname static string + get_maybeString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + get_maybeListOfMaybeString() cil managed + { + + .maxstack 8 + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 ''.$MyTestModule::maybeListOfMaybeString@5 + IL_0005: ret + } + + .method public static class '<>f__AnonymousType2430756162`3',int32> + giveMeA() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) + + .maxstack 8 + IL_0000: call string MyTestModule::get_maybeString() + IL_0005: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 MyTestModule::get_maybeListOfMaybeString() + IL_000a: call int32 MyTestModule::get_justInt() + IL_000f: newobj instance void class '<>f__AnonymousType2430756162`3',int32>::.ctor(!0, + !1, + !2) + IL_0014: ret + } + + .method public static class '<>f__AnonymousType2430756162`3' + giveMeB() cil managed + { + + .maxstack 8 + IL_0000: call int32 MyTestModule::get_justInt() + IL_0005: call int32 MyTestModule::get_justInt() + IL_000a: call int32 MyTestModule::get_justInt() + IL_000f: newobj instance void class '<>f__AnonymousType2430756162`3'::.ctor(!0, + !1, + !2) + IL_0014: ret + } + + .method public static class '<>f__AnonymousType2430756162`3' + giveMeC() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) + + .maxstack 8 + IL_0000: call string MyTestModule::get_maybeString() + IL_0005: call string MyTestModule::get_maybeString() + IL_000a: call string MyTestModule::get_maybeString() + IL_000f: newobj instance void class '<>f__AnonymousType2430756162`3'::.ctor(!0, + !1, + !2) + IL_0014: ret + } + + .property int32 justInt() + { + .get int32 MyTestModule::get_justInt() + } + .property string maybeString() + { + .get string MyTestModule::get_maybeString() + } + .property class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + maybeListOfMaybeString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 09 00 00 00 00 00 ) + .get class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 MyTestModule::get_maybeListOfMaybeString() + } +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field static assembly initonly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 maybeListOfMaybeString@5 + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field static assembly int32 init@ + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 8 + IL_0000: call string MyTestModule::get_maybeString() + IL_0005: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_000a: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::Cons(!0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1) + IL_000f: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 ''.$MyTestModule::maybeListOfMaybeString@5 + IL_0014: ret + } + +} + +.class public auto ansi serializable sealed beforefieldinit '<>f__AnonymousType2430756162`3'<'j__TPar','j__TPar','j__TPar'> + extends [runtime]System.Object + implements [runtime]System.Collections.IStructuralComparable, + [runtime]System.IComparable, + class [runtime]System.IComparable`1f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>>, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IEquatable`1f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>> +{ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field private !'j__TPar' A@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private !'j__TPar' B@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field private !'j__TPar' C@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(!'j__TPar' A, + !'j__TPar' B, + !'j__TPar' C) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 1E 3C 3E 66 5F 5F 41 6E 6F 6E + 79 6D 6F 75 73 54 79 70 65 32 34 33 30 37 35 36 + 31 36 32 60 33 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0014: ldarg.0 + IL_0015: ldarg.3 + IL_0016: stfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_001b: ret + } + + .method public hidebysig specialname instance !'j__TPar' + get_A() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0006: ret + } + + .method public hidebysig specialname instance !'j__TPar' + get_B() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0006: ret + } + + .method public hidebysig specialname instance !'j__TPar' + get_C() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0006: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToStringf__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>,string>::Invoke(!0) + IL_0015: ret + } + + .method public hidebysig virtual final + instance int32 CompareTo(class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (int32 V_0, + int32 V_1) + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0067 + + IL_0003: ldarg.1 + IL_0004: brfalse.s IL_0065 + + IL_0006: call class [runtime]System.Collections.IComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericComparer() + IL_000b: ldarg.0 + IL_000c: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0011: ldarg.1 + IL_0012: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0017: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: ldc.i4.0 + IL_001f: bge.s IL_0023 + + IL_0021: ldloc.0 + IL_0022: ret + + IL_0023: ldloc.0 + IL_0024: ldc.i4.0 + IL_0025: ble.s IL_0029 + + IL_0027: ldloc.0 + IL_0028: ret + + IL_0029: call class [runtime]System.Collections.IComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericComparer() + IL_002e: ldarg.0 + IL_002f: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0034: ldarg.1 + IL_0035: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_003a: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_003f: stloc.1 + IL_0040: ldloc.1 + IL_0041: ldc.i4.0 + IL_0042: bge.s IL_0046 + + IL_0044: ldloc.1 + IL_0045: ret + + IL_0046: ldloc.1 + IL_0047: ldc.i4.0 + IL_0048: ble.s IL_004c + + IL_004a: ldloc.1 + IL_004b: ret + + IL_004c: call class [runtime]System.Collections.IComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericComparer() + IL_0051: ldarg.0 + IL_0052: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0057: ldarg.1 + IL_0058: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_005d: tail. + IL_005f: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_0064: ret + + IL_0065: ldc.i4.1 + IL_0066: ret + + IL_0067: ldarg.1 + IL_0068: brfalse.s IL_006c + + IL_006a: ldc.i4.m1 + IL_006b: ret + + IL_006c: ldc.i4.0 + IL_006d: ret + } + + .method public hidebysig virtual final + instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: unbox.any class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0007: tail. + IL_0009: callvirt instance int32 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::CompareTo(class '<>f__AnonymousType2430756162`3') + IL_000e: ret + } + + .method public hidebysig virtual final + instance int32 CompareTo(object obj, + class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_0, + class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_1, + int32 V_2, + int32 V_3) + IL_0000: ldarg.1 + IL_0001: unbox.any class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: stloc.1 + IL_0009: ldarg.0 + IL_000a: brfalse.s IL_0069 + + IL_000c: ldarg.1 + IL_000d: unbox.any class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0012: brfalse.s IL_0067 + + IL_0014: ldarg.2 + IL_0015: ldarg.0 + IL_0016: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_001b: ldloc.1 + IL_001c: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0021: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_0026: stloc.2 + IL_0027: ldloc.2 + IL_0028: ldc.i4.0 + IL_0029: bge.s IL_002d + + IL_002b: ldloc.2 + IL_002c: ret + + IL_002d: ldloc.2 + IL_002e: ldc.i4.0 + IL_002f: ble.s IL_0033 + + IL_0031: ldloc.2 + IL_0032: ret + + IL_0033: ldarg.2 + IL_0034: ldarg.0 + IL_0035: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_003a: ldloc.1 + IL_003b: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0040: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_0045: stloc.3 + IL_0046: ldloc.3 + IL_0047: ldc.i4.0 + IL_0048: bge.s IL_004c + + IL_004a: ldloc.3 + IL_004b: ret + + IL_004c: ldloc.3 + IL_004d: ldc.i4.0 + IL_004e: ble.s IL_0052 + + IL_0050: ldloc.3 + IL_0051: ret + + IL_0052: ldarg.2 + IL_0053: ldarg.0 + IL_0054: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0059: ldloc.1 + IL_005a: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_005f: tail. + IL_0061: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericComparisonWithComparerj__TPar'>(class [runtime]System.Collections.IComparer, + !!0, + !!0) + IL_0066: ret + + IL_0067: ldc.i4.1 + IL_0068: ret + + IL_0069: ldarg.1 + IL_006a: unbox.any class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_006f: brfalse.s IL_0073 + + IL_0071: ldc.i4.m1 + IL_0072: ret + + IL_0073: ldc.i4.0 + IL_0074: ret + } + + .method public hidebysig virtual final + instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 7 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0058 + + IL_0003: ldc.i4.0 + IL_0004: stloc.0 + IL_0005: ldc.i4 0x9e3779b9 + IL_000a: ldarg.1 + IL_000b: ldarg.0 + IL_000c: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0011: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericHashWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0) + IL_0016: ldloc.0 + IL_0017: ldc.i4.6 + IL_0018: shl + IL_0019: ldloc.0 + IL_001a: ldc.i4.2 + IL_001b: shr + IL_001c: add + IL_001d: add + IL_001e: add + IL_001f: stloc.0 + IL_0020: ldc.i4 0x9e3779b9 + IL_0025: ldarg.1 + IL_0026: ldarg.0 + IL_0027: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_002c: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericHashWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0) + IL_0031: ldloc.0 + IL_0032: ldc.i4.6 + IL_0033: shl + IL_0034: ldloc.0 + IL_0035: ldc.i4.2 + IL_0036: shr + IL_0037: add + IL_0038: add + IL_0039: add + IL_003a: stloc.0 + IL_003b: ldc.i4 0x9e3779b9 + IL_0040: ldarg.1 + IL_0041: ldarg.0 + IL_0042: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0047: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericHashWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0) + IL_004c: ldloc.0 + IL_004d: ldc.i4.6 + IL_004e: shl + IL_004f: ldloc.0 + IL_0050: ldc.i4.2 + IL_0051: shr + IL_0052: add + IL_0053: add + IL_0054: add + IL_0055: stloc.0 + IL_0056: ldloc.0 + IL_0057: ret + + IL_0058: ldc.i4.0 + IL_0059: ret + } + + .method public hidebysig virtual final + instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: tail. + IL_0008: callvirt instance int32 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000d: ret + } + + .method public hidebysig virtual final + instance bool Equals(object obj, + class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_0, + class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_1) + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0052 + + IL_0003: ldarg.1 + IL_0004: isinst class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0009: stloc.0 + IL_000a: ldloc.0 + IL_000b: brfalse.s IL_0050 + + IL_000d: ldloc.0 + IL_000e: stloc.1 + IL_000f: ldarg.2 + IL_0010: ldarg.0 + IL_0011: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0016: ldloc.1 + IL_0017: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_001c: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0, + !!0) + IL_0021: brfalse.s IL_004e + + IL_0023: ldarg.2 + IL_0024: ldarg.0 + IL_0025: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_002a: ldloc.1 + IL_002b: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0030: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0, + !!0) + IL_0035: brfalse.s IL_004c + + IL_0037: ldarg.2 + IL_0038: ldarg.0 + IL_0039: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_003e: ldloc.1 + IL_003f: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0044: tail. + IL_0046: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityWithComparerj__TPar'>(class [runtime]System.Collections.IEqualityComparer, + !!0, + !!0) + IL_004b: ret + + IL_004c: ldc.i4.0 + IL_004d: ret + + IL_004e: ldc.i4.0 + IL_004f: ret + + IL_0050: ldc.i4.0 + IL_0051: ret + + IL_0052: ldarg.1 + IL_0053: ldnull + IL_0054: cgt.un + IL_0056: ldc.i4.0 + IL_0057: ceq + IL_0059: ret + } + + .method public hidebysig virtual final + instance bool Equals(class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 4 + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0046 + + IL_0003: ldarg.1 + IL_0004: brfalse.s IL_0044 + + IL_0006: ldarg.0 + IL_0007: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_000c: ldarg.1 + IL_000d: ldfld !0 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::A@ + IL_0012: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityERj__TPar'>(!!0, + !!0) + IL_0017: brfalse.s IL_0042 + + IL_0019: ldarg.0 + IL_001a: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_001f: ldarg.1 + IL_0020: ldfld !1 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::B@ + IL_0025: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityERj__TPar'>(!!0, + !!0) + IL_002a: brfalse.s IL_0040 + + IL_002c: ldarg.0 + IL_002d: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0032: ldarg.1 + IL_0033: ldfld !2 class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::C@ + IL_0038: tail. + IL_003a: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::GenericEqualityERj__TPar'>(!!0, + !!0) + IL_003f: ret + + IL_0040: ldc.i4.0 + IL_0041: ret + + IL_0042: ldc.i4.0 + IL_0043: ret + + IL_0044: ldc.i4.0 + IL_0045: ret + + IL_0046: ldarg.1 + IL_0047: ldnull + IL_0048: cgt.un + IL_004a: ldc.i4.0 + IL_004b: ceq + IL_004d: ret + } + + .method public hidebysig virtual final + instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 4 + .locals init (class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> V_0) + IL_0000: ldarg.1 + IL_0001: isinst class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: brfalse.s IL_0014 + + IL_000a: ldarg.0 + IL_000b: ldloc.0 + IL_000c: tail. + IL_000e: callvirt instance bool class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'>::Equals(class '<>f__AnonymousType2430756162`3') + IL_0013: ret + + IL_0014: ldc.i4.0 + IL_0015: ret + } + + .property instance !'j__TPar' A() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 ) + .get instance !'j__TPar' '<>f__AnonymousType2430756162`3'::get_A() + } + .property instance !'j__TPar' B() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 ) + .get instance !'j__TPar' '<>f__AnonymousType2430756162`3'::get_B() + } + .property instance !'j__TPar' C() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 ) + .get instance !'j__TPar' '<>f__AnonymousType2430756162`3'::get_C() + } +} + +.class private auto ansi serializable sealed System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + extends [runtime]System.Enum +{ + .custom instance void [runtime]System.FlagsAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes All = int32(0xFFFFFFFF) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes None = int32(0x00000000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicParameterlessConstructor = int32(0x00000001) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicConstructors = int32(0x00000003) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicConstructors = int32(0x00000004) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicMethods = int32(0x00000008) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicMethods = int32(0x00000010) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicFields = int32(0x00000020) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicFields = int32(0x00000040) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicNestedTypes = int32(0x00000080) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicNestedTypes = int32(0x00000100) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicProperties = int32(0x00000200) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicProperties = int32(0x00000400) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicEvents = int32(0x00000800) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicEvents = int32(0x00001000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes Interfaces = int32(0x00002000) +} + +.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute + extends [runtime]System.Attribute +{ + .field private valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [runtime]System.Type Type@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, + class [runtime]System.Type Type) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0014: ret + } + + .method public hidebysig specialname instance class [runtime]System.Type + get_Type() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0006: ret + } + + .method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + get_MemberType() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_0006: ret + } + + .property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + MemberType() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType() + } + .property instance class [runtime]System.Type + Type() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type() + } +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index 65a0aea4583..728a0dac598 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -64,7 +64,3 @@ let ``Nullable attr for custom type`` compilation = compilation |> verifyCompilation DoNotOptimize - - - - \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl new file mode 100644 index 00000000000..a8f28534b92 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl @@ -0,0 +1,459 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class auto ansi serializable sealed nested public beforefieldinit MyRecord`3 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type X + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type Y + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type Z + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field assembly int32 JustInt@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly valuetype [runtime]System.Nullable`1 NullInt@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly string JustString@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly string NullableString@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .field assembly !X GenericNormalField@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly !Y GenericNullableField@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .field assembly !Z GenericNotNullField@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .method public hidebysig specialname + instance int32 get_JustInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 class MyTestModule/MyRecord`3::JustInt@ + IL_0006: ret + } + + .method public hidebysig specialname + instance valuetype [runtime]System.Nullable`1 + get_NullInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype [runtime]System.Nullable`1 class MyTestModule/MyRecord`3::NullInt@ + IL_0006: ret + } + + .method public hidebysig specialname + instance string get_JustString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string class MyTestModule/MyRecord`3::JustString@ + IL_0006: ret + } + + .method public hidebysig specialname + instance string get_NullableString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string class MyTestModule/MyRecord`3::NullableString@ + IL_0006: ret + } + + .method public hidebysig specialname + instance !X get_GenericNormalField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 class MyTestModule/MyRecord`3::GenericNormalField@ + IL_0006: ret + } + + .method public hidebysig specialname + instance !Y get_GenericNullableField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !1 class MyTestModule/MyRecord`3::GenericNullableField@ + IL_0006: ret + } + + .method public hidebysig specialname + instance !Z get_GenericNotNullField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !2 class MyTestModule/MyRecord`3::GenericNotNullField@ + IL_0006: ret + } + + .method public specialname rtspecialname + instance void .ctor(int32 justInt, + valuetype [runtime]System.Nullable`1 nullInt, + string justString, + string nullableString, + !X genericNormalField, + !Y genericNullableField, + !Z genericNotNullField) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 17 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 52 65 63 6F 72 64 60 33 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 class MyTestModule/MyRecord`3::JustInt@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld valuetype [runtime]System.Nullable`1 class MyTestModule/MyRecord`3::NullInt@ + IL_0014: ldarg.0 + IL_0015: ldarg.3 + IL_0016: stfld string class MyTestModule/MyRecord`3::JustString@ + IL_001b: ldarg.0 + IL_001c: ldarg.s nullableString + IL_001e: stfld string class MyTestModule/MyRecord`3::NullableString@ + IL_0023: ldarg.0 + IL_0024: ldarg.s genericNormalField + IL_0026: stfld !0 class MyTestModule/MyRecord`3::GenericNormalField@ + IL_002b: ldarg.0 + IL_002c: ldarg.s genericNullableField + IL_002e: stfld !1 class MyTestModule/MyRecord`3::GenericNullableField@ + IL_0033: ldarg.0 + IL_0034: ldarg.s genericNotNullField + IL_0036: stfld !2 class MyTestModule/MyRecord`3::GenericNotNullField@ + IL_003b: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class MyTestModule/MyRecord`3>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .property instance int32 JustInt() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 00 00 00 00 00 00 ) + .get instance int32 MyTestModule/MyRecord`3::get_JustInt() + } + .property instance valuetype [runtime]System.Nullable`1 + NullInt() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 ) + .get instance valuetype [runtime]System.Nullable`1 MyTestModule/MyRecord`3::get_NullInt() + } + .property instance string JustString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 ) + .get instance string MyTestModule/MyRecord`3::get_JustString() + } + .property instance string NullableString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 03 00 00 00 00 00 ) + .get instance string MyTestModule/MyRecord`3::get_NullableString() + } + .property instance !X GenericNormalField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 04 00 00 00 00 00 ) + .get instance !X MyTestModule/MyRecord`3::get_GenericNormalField() + } + .property instance !Y GenericNullableField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 05 00 00 00 00 00 ) + .get instance !Y MyTestModule/MyRecord`3::get_GenericNullableField() + } + .property instance !Z GenericNotNullField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 04 00 00 00 06 00 00 00 00 00 ) + .get instance !Z MyTestModule/MyRecord`3::get_GenericNotNullField() + } + } + + .method public specialname static string + get_maybeString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public static class MyTestModule/MyRecord`3 + createAnInstance() cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 02 01 00 00 ) + + .maxstack 9 + IL_0000: ldc.i4.s 42 + IL_0002: ldc.i4.s 42 + IL_0004: call valuetype [runtime]System.Nullable`1 valuetype [runtime]System.Nullable`1::op_Implicit(!0) + IL_0009: ldstr "" + IL_000e: ldnull + IL_000f: ldc.i4.s 42 + IL_0011: call string MyTestModule::get_maybeString() + IL_0016: ldstr "" + IL_001b: newobj instance void class MyTestModule/MyRecord`3::.ctor(int32, + valuetype [runtime]System.Nullable`1, + string, + string, + !0, + !1, + !2) + IL_0020: ret + } + + .property string maybeString() + { + .get string MyTestModule::get_maybeString() + } +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi serializable sealed System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + extends [runtime]System.Enum +{ + .custom instance void [runtime]System.FlagsAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes All = int32(0xFFFFFFFF) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes None = int32(0x00000000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicParameterlessConstructor = int32(0x00000001) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicConstructors = int32(0x00000003) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicConstructors = int32(0x00000004) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicMethods = int32(0x00000008) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicMethods = int32(0x00000010) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicFields = int32(0x00000020) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicFields = int32(0x00000040) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicNestedTypes = int32(0x00000080) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicNestedTypes = int32(0x00000100) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicProperties = int32(0x00000200) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicProperties = int32(0x00000400) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicEvents = int32(0x00000800) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicEvents = int32(0x00001000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes Interfaces = int32(0x00002000) +} + +.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute + extends [runtime]System.Attribute +{ + .field private valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [runtime]System.Type Type@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, + class [runtime]System.Type Type) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0014: ret + } + + .method public hidebysig specialname instance class [runtime]System.Type + get_Type() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0006: ret + } + + .method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + get_MemberType() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_0006: ret + } + + .property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + MemberType() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType() + } + .property instance class [runtime]System.Type + Type() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type() + } +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl new file mode 100644 index 00000000000..9961a90d43f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl @@ -0,0 +1,763 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly extern netstandard +{ + .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) + .ver 2:0:0:0 +} +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto autochar serializable nested public beforefieldinit MyDu + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .field public static literal int32 JustLabel = int32(0x00000000) + .field public static literal int32 JustInt = int32(0x00000001) + .field public static literal int32 MaybeString = int32(0x00000002) + } + + .class auto ansi serializable nested assembly beforefieldinit specialname _JustLabel + extends MyTestModule/MyDu + { + .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 2B 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B + 4D 79 44 75 2B 5F 4A 75 73 74 4C 61 62 65 6C 40 + 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void MyTestModule/MyDu::.ctor() + IL_0006: ret + } + + } + + .class auto ansi serializable nested public beforefieldinit specialname JustInt + extends MyTestModule/MyDu + { + .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 28 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B + 4D 79 44 75 2B 4A 75 73 74 49 6E 74 40 44 65 62 + 75 67 54 79 70 65 50 72 6F 78 79 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .field assembly initonly int32 item + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int32 item) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void MyTestModule/MyDu::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 MyTestModule/MyDu/JustInt::item + IL_000d: ret + } + + .method public hidebysig instance int32 + get_Item() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 MyTestModule/MyDu/JustInt::item + IL_0006: ret + } + + .property instance int32 Item() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance int32 MyTestModule/MyDu/JustInt::get_Item() + } + } + + .class auto ansi serializable nested public beforefieldinit specialname MaybeString + extends MyTestModule/MyDu + { + .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 2C 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B + 4D 79 44 75 2B 4D 61 79 62 65 53 74 72 69 6E 67 + 40 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 + 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .field assembly initonly string item + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(string item) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void MyTestModule/MyDu::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld string MyTestModule/MyDu/MaybeString::item + IL_000d: ret + } + + .method public hidebysig instance string + get_Item() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string MyTestModule/MyDu/MaybeString::item + IL_0006: ret + } + + .property instance string Item() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string MyTestModule/MyDu/MaybeString::get_Item() + } + } + + .class auto ansi nested assembly beforefieldinit specialname _JustLabel@DebugTypeProxy + extends [runtime]System.Object + { + .field assembly class MyTestModule/MyDu/_JustLabel _obj + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class MyTestModule/MyDu/_JustLabel obj) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class MyTestModule/MyDu/_JustLabel MyTestModule/MyDu/_JustLabel@DebugTypeProxy::_obj + IL_000d: ret + } + + } + + .class auto ansi nested assembly beforefieldinit specialname JustInt@DebugTypeProxy + extends [runtime]System.Object + { + .field assembly class MyTestModule/MyDu/JustInt _obj + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class MyTestModule/MyDu/JustInt obj) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class MyTestModule/MyDu/JustInt MyTestModule/MyDu/JustInt@DebugTypeProxy::_obj + IL_000d: ret + } + + .method public hidebysig instance int32 + get_Item() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class MyTestModule/MyDu/JustInt MyTestModule/MyDu/JustInt@DebugTypeProxy::_obj + IL_0006: ldfld int32 MyTestModule/MyDu/JustInt::item + IL_000b: ret + } + + .property instance int32 Item() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance int32 MyTestModule/MyDu/JustInt@DebugTypeProxy::get_Item() + } + } + + .class auto ansi nested assembly beforefieldinit specialname MaybeString@DebugTypeProxy + extends [runtime]System.Object + { + .field assembly class MyTestModule/MyDu/MaybeString _obj + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class MyTestModule/MyDu/MaybeString obj) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class MyTestModule/MyDu/MaybeString MyTestModule/MyDu/MaybeString@DebugTypeProxy::_obj + IL_000d: ret + } + + .method public hidebysig instance string + get_Item() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class MyTestModule/MyDu/MaybeString MyTestModule/MyDu/MaybeString@DebugTypeProxy::_obj + IL_0006: ldfld string MyTestModule/MyDu/MaybeString::item + IL_000b: ret + } + + .property instance string Item() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string MyTestModule/MyDu/MaybeString@DebugTypeProxy::get_Item() + } + } + + .field static assembly initonly class MyTestModule/MyDu _unique_JustLabel + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 8 + IL_0000: newobj instance void MyTestModule/MyDu/_JustLabel::.ctor() + IL_0005: stsfld class MyTestModule/MyDu MyTestModule/MyDu::_unique_JustLabel + IL_000a: ret + } + + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 E0 07 00 00 11 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 44 75 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ret + } + + .method public static class MyTestModule/MyDu + get_JustLabel() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldsfld class MyTestModule/MyDu MyTestModule/MyDu::_unique_JustLabel + IL_0005: ret + } + + .method public hidebysig instance bool + get_IsJustLabel() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst MyTestModule/MyDu/_JustLabel + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } + + .method public static class MyTestModule/MyDu + NewJustInt(int32 item) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void MyTestModule/MyDu/JustInt::.ctor(int32) + IL_0006: ret + } + + .method public hidebysig instance bool + get_IsJustInt() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst MyTestModule/MyDu/JustInt + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } + + .method public static class MyTestModule/MyDu + NewMaybeString(string item) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void MyTestModule/MyDu/MaybeString::.ctor(string) + IL_0006: ret + } + + .method public hidebysig instance bool + get_IsMaybeString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst MyTestModule/MyDu/MaybeString + IL_0006: ldnull + IL_0007: cgt.un + IL_0009: ret + } + + .method public hidebysig instance int32 + get_Tag() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: isinst MyTestModule/MyDu/MaybeString + IL_0006: brfalse.s IL_000b + + IL_0008: ldc.i4.2 + IL_0009: br.s IL_0017 + + IL_000b: ldarg.0 + IL_000c: isinst MyTestModule/MyDu/JustInt + IL_0011: brfalse.s IL_0016 + + IL_0013: ldc.i4.1 + IL_0014: br.s IL_0017 + + IL_0016: ldc.i4.0 + IL_0017: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0015: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class MyTestModule/MyDu>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0015: ret + } + + .property instance int32 Tag() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance int32 MyTestModule/MyDu::get_Tag() + } + .property class MyTestModule/MyDu JustLabel() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get class MyTestModule/MyDu MyTestModule/MyDu::get_JustLabel() + } + .property instance bool IsJustLabel() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/MyDu::get_IsJustLabel() + } + .property instance bool IsJustInt() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/MyDu::get_IsJustInt() + } + .property instance bool IsMaybeString() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/MyDu::get_IsMaybeString() + } + } + + .method public static class MyTestModule/MyDu + giveMeLabel() cil managed + { + + .maxstack 8 + IL_0000: call class MyTestModule/MyDu MyTestModule/MyDu::get_JustLabel() + IL_0005: ret + } + + .method public static class MyTestModule/MyDu + createMaybeString(string innerValue) cil managed + { + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class MyTestModule/MyDu MyTestModule/MyDu::NewMaybeString(string) + IL_0006: ret + } + + .method public static string processNullableDu(class MyTestModule/MyDu x) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 5 + .locals init (class MyTestModule/MyDu V_0, + class MyTestModule/MyDu V_1, + class MyTestModule/MyDu/JustInt V_2, + int32 V_3, + int32 V_4, + class MyTestModule/MyDu/MaybeString V_5, + string V_6) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: brfalse.s IL_0019 + + IL_0005: ldloc.0 + IL_0006: stloc.1 + IL_0007: ldloc.1 + IL_0008: isinst MyTestModule/MyDu/JustInt + IL_000d: brtrue.s IL_001d + + IL_000f: ldloc.1 + IL_0010: isinst MyTestModule/MyDu/MaybeString + IL_0015: brtrue.s IL_0048 + + IL_0017: br.s IL_001b + + IL_0019: ldnull + IL_001a: ret + + IL_001b: ldnull + IL_001c: ret + + IL_001d: ldloc.0 + IL_001e: castclass MyTestModule/MyDu/JustInt + IL_0023: stloc.2 + IL_0024: ldloc.2 + IL_0025: ldfld int32 MyTestModule/MyDu/JustInt::item + IL_002a: stloc.3 + IL_002b: ldloc.3 + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: box [runtime]System.Int32 + IL_0035: unbox.any [runtime]System.IFormattable + IL_003a: ldnull + IL_003b: call class [netstandard]System.Globalization.CultureInfo [netstandard]System.Globalization.CultureInfo::get_InvariantCulture() + IL_0040: tail. + IL_0042: callvirt instance string [netstandard]System.IFormattable::ToString(string, + class [netstandard]System.IFormatProvider) + IL_0047: ret + + IL_0048: ldloc.0 + IL_0049: castclass MyTestModule/MyDu/MaybeString + IL_004e: stloc.s V_5 + IL_0050: ldloc.s V_5 + IL_0052: ldfld string MyTestModule/MyDu/MaybeString::item + IL_0057: stloc.s V_6 + IL_0059: ldloc.s V_6 + IL_005b: ret + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi serializable sealed System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + extends [runtime]System.Enum +{ + .custom instance void [runtime]System.FlagsAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes All = int32(0xFFFFFFFF) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes None = int32(0x00000000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicParameterlessConstructor = int32(0x00000001) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicConstructors = int32(0x00000003) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicConstructors = int32(0x00000004) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicMethods = int32(0x00000008) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicMethods = int32(0x00000010) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicFields = int32(0x00000020) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicFields = int32(0x00000040) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicNestedTypes = int32(0x00000080) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicNestedTypes = int32(0x00000100) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicProperties = int32(0x00000200) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicProperties = int32(0x00000400) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicEvents = int32(0x00000800) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicEvents = int32(0x00001000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes Interfaces = int32(0x00002000) +} + +.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute + extends [runtime]System.Attribute +{ + .field private valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [runtime]System.Type Type@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, + class [runtime]System.Type Type) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0014: ret + } + + .method public hidebysig specialname instance class [runtime]System.Type + get_Type() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0006: ret + } + + .method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + get_MemberType() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_0006: ret + } + + .property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + MemberType() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType() + } + .property instance class [runtime]System.Type + Type() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type() + } +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl new file mode 100644 index 00000000000..284d2459335 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl @@ -0,0 +1,447 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed MyTestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class sequential autochar serializable sealed nested public beforefieldinit Myassembly + extends [runtime]System.ValueType + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .field public static literal int32 A = int32(0x00000000) + .field public static literal int32 B = int32(0x00000001) + .field public static literal int32 C = int32(0x00000002) + } + + .field assembly string _nonNullableString + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly string _nullableString + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly int32 _tag + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public static valuetype MyTestModule/Myassembly + get_A() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: newobj instance void MyTestModule/Myassembly::.ctor(int32) + IL_0006: ret + } + + .method public hidebysig instance bool + get_IsA() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 MyTestModule/Myassembly::get_Tag() + IL_0006: ldc.i4.0 + IL_0007: ceq + IL_0009: ret + } + + .method public static valuetype MyTestModule/Myassembly + NewB(string _nonNullableString) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 2 + .locals init (valuetype MyTestModule/Myassembly V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj MyTestModule/Myassembly + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.1 + IL_000b: stfld int32 MyTestModule/Myassembly::_tag + IL_0010: ldloca.s V_0 + IL_0012: ldarg.0 + IL_0013: stfld string MyTestModule/Myassembly::_nonNullableString + IL_0018: ldloc.0 + IL_0019: ret + } + + .method public hidebysig instance bool + get_IsB() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 MyTestModule/Myassembly::get_Tag() + IL_0006: ldc.i4.1 + IL_0007: ceq + IL_0009: ret + } + + .method public static valuetype MyTestModule/Myassembly + NewC(string _nullableString) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) + + .maxstack 2 + .locals init (valuetype MyTestModule/Myassembly V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj MyTestModule/Myassembly + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.2 + IL_000b: stfld int32 MyTestModule/Myassembly::_tag + IL_0010: ldloca.s V_0 + IL_0012: ldarg.0 + IL_0013: stfld string MyTestModule/Myassembly::_nullableString + IL_0018: ldloc.0 + IL_0019: ret + } + + .method public hidebysig instance bool + get_IsC() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 MyTestModule/Myassembly::get_Tag() + IL_0006: ldc.i4.2 + IL_0007: ceq + IL_0009: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(int32 _tag) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 17 4D 79 54 65 73 74 4D 6F 64 + 75 6C 65 2B 4D 79 53 74 72 75 63 74 44 55 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 MyTestModule/Myassembly::_tag + IL_0007: ret + } + + .method public hidebysig instance string + get_nonNullableString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string MyTestModule/Myassembly::_nonNullableString + IL_0006: ret + } + + .method public hidebysig instance string + get_nullableString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string MyTestModule/Myassembly::_nullableString + IL_0006: ret + } + + .method public hidebysig instance int32 + get_Tag() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 MyTestModule/Myassembly::_tag + IL_0006: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: ldobj MyTestModule/Myassembly + IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001a: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,valuetype MyTestModule/Myassembly>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: ldobj MyTestModule/Myassembly + IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001a: ret + } + + .property instance int32 Tag() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance int32 MyTestModule/Myassembly::get_Tag() + } + .property valuetype MyTestModule/Myassembly + A() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get valuetype MyTestModule/Myassembly MyTestModule/Myassembly::get_A() + } + .property instance bool IsA() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/Myassembly::get_IsA() + } + .property instance bool IsB() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/Myassembly::get_IsB() + } + .property instance bool IsC() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool MyTestModule/Myassembly::get_IsC() + } + .property instance string nonNullableString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string MyTestModule/Myassembly::get_nonNullableString() + } + .property instance string nullableString() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string MyTestModule/Myassembly::get_nullableString() + } + } + + .method public static string getVal(valuetype MyTestModule/Myassembly x) cil managed + { + + .maxstack 3 + .locals init (valuetype MyTestModule/Myassembly V_0, + string V_1, + string V_2) + IL_0000: ldarg.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance int32 MyTestModule/Myassembly::get_Tag() + IL_0009: ldc.i4.1 + IL_000a: bne.un.s IL_0016 + + IL_000c: ldloca.s V_0 + IL_000e: ldfld string MyTestModule/Myassembly::_nonNullableString + IL_0013: stloc.1 + IL_0014: ldloc.1 + IL_0015: ret + + IL_0016: ldstr "fail" + IL_001b: stloc.2 + IL_001c: ldloc.2 + IL_001d: call class [runtime]System.Exception [FSharp.Core]Microsoft.FSharp.Core.Operators::Failure(string) + IL_0022: throw + } + +} + +.class private abstract auto ansi sealed ''.$MyTestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi serializable sealed System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + extends [runtime]System.Enum +{ + .custom instance void [runtime]System.FlagsAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes All = int32(0xFFFFFFFF) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes None = int32(0x00000000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicParameterlessConstructor = int32(0x00000001) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicConstructors = int32(0x00000003) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicConstructors = int32(0x00000004) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicMethods = int32(0x00000008) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicMethods = int32(0x00000010) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicFields = int32(0x00000020) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicFields = int32(0x00000040) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicNestedTypes = int32(0x00000080) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicNestedTypes = int32(0x00000100) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicProperties = int32(0x00000200) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicProperties = int32(0x00000400) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicEvents = int32(0x00000800) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicEvents = int32(0x00001000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes Interfaces = int32(0x00002000) +} + +.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute + extends [runtime]System.Attribute +{ + .field private valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [runtime]System.Type Type@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, + class [runtime]System.Type Type) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0014: ret + } + + .method public hidebysig specialname instance class [runtime]System.Type + get_Type() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0006: ret + } + + .method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + get_MemberType() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_0006: ret + } + + .property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + MemberType() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType() + } + .property instance class [runtime]System.Type + Type() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type() + } +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl From a1e08f92a30900d8a058b111ebd343d904cf5e20 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 20 Sep 2023 14:50:08 +0200 Subject: [PATCH 16/33] tyarg can be omitted when it is `not null` --- src/Compiler/CodeGen/IlxGen.fs | 6 ++++-- .../EmittedIL/Nullness/CurriedFunctions.fs.il.bsl | 2 -- .../EmittedIL/Nullness/Records.fs.il.net472.bsl | 2 -- .../EmittedIL/Nullness/Records.fs.il.netcore.bsl | 2 -- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 6e04ccec121..566699d3dd4 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -5633,8 +5633,10 @@ and GenGenericParam cenv eenv (tp: Typar) = if emitUnmanagedInIlOutput then yield (GetIsUnmanagedAttribute g) match notNullReferenceTypeConstraint with - | Some nullness -> yield GetNullableAttribute g [ nullness ] - | None -> () + // If using the `checknulls` flag, F# generated class has [] + // This means that everything inside is considered to be NOT-nullable by default + | Some NullnessInfo.WithNull -> yield GetNullableAttribute g [ NullnessInfo.WithNull ] + | _ -> () ] let tpAttrs = mkILCustomAttrs (attributeList) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl index 8eb27f1765d..f7b3bc189b3 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl @@ -109,8 +109,6 @@ 00 00 00 00 ) .param type a .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - .param type b - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .param type c .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .param type d diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl index a8f28534b92..d51492e1051 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl @@ -38,8 +38,6 @@ .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .param type Y .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - .param type Z - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .field assembly int32 JustInt@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl index 81a742d6ad4..183af908e59 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl @@ -38,8 +38,6 @@ .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .param type Y .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - .param type Z - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .field assembly int32 JustInt@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) From 82d0dcc5ca1608157114a5a9b7d86522b2555761 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 20 Sep 2023 15:32:05 +0200 Subject: [PATCH 17/33] properties annotated on IL level --- src/Compiler/CodeGen/IlxGen.fs | 3 +- .../Nullness/AnonRecords.fs.il.net472.bsl | 2 + .../Nullness/AnonRecords.fs.il.netcore.bsl | 2 + .../EmittedIL/Nullness/CustomType.fs | 7 +- .../EmittedIL/Nullness/CustomType.fs.il.bsl | 73 ++++++++++++++++++- .../Nullness/ModuleLevelBindings.fs.il.bsl | 45 ++++++++++++ .../Nullness/Records.fs.il.net472.bsl | 1 + .../Nullness/Records.fs.il.netcore.bsl | 1 + 8 files changed, 131 insertions(+), 3 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 566699d3dd4..38780b89e14 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -8356,7 +8356,7 @@ and GenBindingAfterDebugPoint cenv cgbuf eenv bind isStateVar startMarkOpt = propertyType = ilTy, init = None, args = [], - customAttrs = mkILCustomAttrs ilAttribs + customAttrs = mkILCustomAttrs (GenAdditionalAttributesForTy g vspec.Type @ ilAttribs) ) cgbuf.mgbuf.AddOrMergePropertyDef(ilGetterMethSpec.MethodRef.DeclaringTypeRef, ilPropDef, m) @@ -8453,6 +8453,7 @@ and GenBindingAfterDebugPoint cenv cgbuf eenv bind isStateVar startMarkOpt = vspec.Attribs |> List.filter (fun (Attrib (_, _, _, _, _, targets, _)) -> canTarget (targets, System.AttributeTargets.Property)) |> GenAttrs cenv eenv // property only gets attributes that target properties + |> List.append (GenAdditionalAttributesForTy g vspec.Type) let ilPropDef = ILPropertyDef( diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl index cce90cb41b7..ebdc70f6bb9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl @@ -110,11 +110,13 @@ } .property string maybeString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .get string MyTestModule::get_maybeString() } .property class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 maybeListOfMaybeString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 09 00 00 00 00 00 ) .get class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 MyTestModule::get_maybeListOfMaybeString() } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl index 0e9cafe159f..5482f74b477 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl @@ -110,11 +110,13 @@ } .property string maybeString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .get string MyTestModule::get_maybeString() } .property class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 maybeListOfMaybeString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 09 00 00 00 00 00 ) .get class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 MyTestModule::get_maybeListOfMaybeString() } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs index d6892936aac..f4aac11e1c5 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs @@ -7,6 +7,7 @@ type MyCustomType (x: MaybeString, y: string) = static let mutable uglyGlobalMutableString : string = "" static let mutable uglyGlobalMutableNullableString : MaybeString = null + static let dict = System.Collections.Generic.Dictionary() member val Nullable = x member val NonNullable = y @@ -17,4 +18,8 @@ type MyCustomType (x: MaybeString, y: string) = member this.UnitFunc() = () member this.GetThis() = this - member this.GetThisOrNull() : MaybeMyCustomType = null \ No newline at end of file + member this.GetThisOrNull() : MaybeMyCustomType = null + + member this.Item + with get (index) = dict.[index] + and set index value = dict.[index] <- value \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl index 90efd10b6d0..dce23e42161 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl @@ -5,6 +5,11 @@ .assembly extern runtime { } .assembly extern FSharp.Core { } +.assembly extern System.Collections +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 7:0:0:0 +} .assembly assembly { .hash algorithm 0x00008004 @@ -29,11 +34,14 @@ .class auto ansi serializable nested public Myassembly extends [runtime]System.Object { + .custom instance void [runtime]System.Reflection.DefaultMemberAttribute::.ctor(string) = ( 01 00 04 49 74 65 6D 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .field static assembly string uglyGlobalMutableString .field static assembly string uglyGlobalMutableNullableString .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .field static assembly class [System.Collections]System.Collections.Generic.Dictionary`2 dict + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 02 02 00 00 ) .field assembly string Nullable@ .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .field assembly string NonNullable@ @@ -147,6 +155,57 @@ IL_0001: ret } + .method public hidebysig specialname + instance string get_Item(string index) cil managed + { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: volatile. + IL_0002: ldsfld int32 MyTestModule/Myassembly::init@6 + IL_0007: ldc.i4.4 + IL_0008: bge.s IL_0011 + + IL_000a: call void [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/IntrinsicFunctions::FailStaticInit() + IL_000f: br.s IL_0011 + + IL_0011: ldsfld class [System.Collections]System.Collections.Generic.Dictionary`2 MyTestModule/Myassembly::dict + IL_0016: ldarg.1 + IL_0017: tail. + IL_0019: callvirt instance !1 class [System.Collections]System.Collections.Generic.Dictionary`2::get_Item(!0) + IL_001e: ret + } + + .method public hidebysig specialname + instance void set_Item(string index, + string 'value') cil managed + { + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [2] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: volatile. + IL_0002: ldsfld int32 MyTestModule/Myassembly::init@6 + IL_0007: ldc.i4.4 + IL_0008: bge.s IL_0011 + + IL_000a: call void [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/IntrinsicFunctions::FailStaticInit() + IL_000f: br.s IL_0011 + + IL_0011: ldsfld class [System.Collections]System.Collections.Generic.Dictionary`2 MyTestModule/Myassembly::dict + IL_0016: ldarg.1 + IL_0017: ldarg.2 + IL_0018: tail. + IL_001a: callvirt instance void class [System.Collections]System.Collections.Generic.Dictionary`2::set_Item(!0, + !1) + IL_001f: ret + } + .method private specialname rtspecialname static void .cctor() cil managed { @@ -172,6 +231,13 @@ { .get instance int32 MyTestModule/Myassembly::get_JustSomeInt() } + .property instance string Item(string) + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .set instance void MyTestModule/Myassembly::set_Item(string, + string) + .get instance string MyTestModule/Myassembly::get_Item(string) + } } } @@ -199,7 +265,12 @@ IL_0018: ldc.i4.3 IL_0019: volatile. IL_001b: stsfld int32 MyTestModule/Myassembly::init@6 - IL_0020: ret + IL_0020: newobj instance void class [System.Collections]System.Collections.Generic.Dictionary`2::.ctor() + IL_0025: stsfld class [System.Collections]System.Collections.Generic.Dictionary`2 MyTestModule/Myassembly::dict + IL_002a: ldc.i4.4 + IL_002b: volatile. + IL_002d: stsfld int32 MyTestModule/Myassembly::init@6 + IL_0032: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl index 6233a25a762..031a5d09cfc 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl @@ -97,10 +97,12 @@ } .property string nullableStringField() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .get string MyTestModule::get_nullableStringField() } .property string nullableMutableStringField() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 09 00 00 00 00 00 ) .set void MyTestModule::set_nullableMutableStringField(string) .get string MyTestModule::get_nullableMutableStringField() @@ -138,6 +140,49 @@ } +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute extends [runtime]System.Attribute { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl index d51492e1051..5411a5f901f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl @@ -282,6 +282,7 @@ .property string maybeString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .get string MyTestModule::get_maybeString() } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl index 183af908e59..2b21b830b63 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl @@ -282,6 +282,7 @@ .property string maybeString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .get string MyTestModule::get_maybeString() } } From 9cb137cd1ccaec762726b5a1781cfde8036c4690 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 20 Sep 2023 15:45:40 +0200 Subject: [PATCH 18/33] let bindings which created fields annotated --- src/Compiler/CodeGen/IlxGen.fs | 2 ++ .../Nullness/AnonRecords.fs.il.net472.bsl | 1 + .../Nullness/AnonRecords.fs.il.netcore.bsl | 1 + .../EmittedIL/Nullness/ModuleLevelBindings.fs | 3 ++- .../Nullness/ModuleLevelBindings.fs.il.bsl | 25 ++++++++++++++++--- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 38780b89e14..ebce3a3df47 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -8432,6 +8432,8 @@ and GenBindingAfterDebugPoint cenv cgbuf eenv bind isStateVar startMarkOpt = else GenAttrs cenv eenv vspec.Attribs // literals have no property, so preserve all the attributes on the field itself + let ilAttribs = GenAdditionalAttributesForTy g vspec.Type @ ilAttribs + let ilFieldDef = ilFieldDef.With(customAttrs = mkILCustomAttrs (ilAttribs @ [ g.DebuggerBrowsableNeverAttribute ])) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl index ebdc70f6bb9..aec9e4e9869 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl @@ -127,6 +127,7 @@ { .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .field static assembly initonly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 maybeListOfMaybeString@5 + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly int32 init@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl index 5482f74b477..7ae9d6301fc 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl @@ -127,6 +127,7 @@ { .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .field static assembly initonly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 maybeListOfMaybeString@5 + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly int32 init@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs index 296f0e92baa..f3cb30cd05d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs @@ -1,5 +1,6 @@ module MyTestModule - +[] +let nullableLiteral : string | null = "" let notNullStringField : string = "" let nullableStringField : string | null = null let mutable nullableMutableStringField : string | null = null diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl index 031a5d09cfc..9bba1aebc80 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl @@ -27,6 +27,10 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field public static literal string nullableLiteral = "" + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.LiteralAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public specialname static string get_notNullStringField() cil managed { @@ -54,7 +58,7 @@ { .maxstack 8 - IL_0000: ldsfld string ''.$MyTestModule::nullableMutableStringField@5 + IL_0000: ldsfld string ''.$MyTestModule::nullableMutableStringField@6 IL_0005: ret } @@ -64,7 +68,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: stsfld string ''.$MyTestModule::nullableMutableStringField@5 + IL_0001: stsfld string ''.$MyTestModule::nullableMutableStringField@6 IL_0006: ret } @@ -91,6 +95,18 @@ IL_0002: ret } + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$MyTestModule::init@ + IL_0006: ldsfld int32 ''.$MyTestModule::init@ + IL_000b: pop + IL_000c: ret + } + .property string notNullStringField() { .get string MyTestModule::get_notNullStringField() @@ -122,7 +138,8 @@ extends [runtime]System.Object { .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) - .field static assembly string nullableMutableStringField@5 + .field static assembly string nullableMutableStringField@6 + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly int32 init@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) @@ -134,7 +151,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: stsfld string ''.$MyTestModule::nullableMutableStringField@5 + IL_0001: stsfld string ''.$MyTestModule::nullableMutableStringField@6 IL_0006: ret } From 7cbff2c8b1e19db846f4407cf21428ea350c8d9a Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 20 Sep 2023 17:44:52 +0200 Subject: [PATCH 19/33] Ref unions nullness --- src/Compiler/CodeGen/EraseUnions.fs | 8 ++- src/Compiler/CodeGen/IlxGen.fs | 60 +++++++++++-------- .../Nullness/CurriedFunctions.fs.il.bsl | 10 ++-- .../Nullness/Records.fs.il.net472.bsl | 4 +- .../Nullness/Records.fs.il.netcore.bsl | 4 +- .../Nullness/ReferenceDU.fs.il.net472.bsl | 2 + .../Nullness/ReferenceDU.fs.il.netcore.bsl | 2 + .../EmittedIL/Nullness/StructDU.fs | 2 +- .../Nullness/StructDU.fs.il.net472.bsl | 44 ++++++++++++++ .../Nullness/StructDU.fs.il.netcore.bsl | 44 ++++++++++++++ 10 files changed, 147 insertions(+), 33 deletions(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index d00c45f2df7..61a91d7f5c2 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -1467,7 +1467,13 @@ let mkClassUnionDef @ List.map (fun (_, _, _, _, fdef, _) -> fdef) altNullaryFields @ td.Fields.AsList() ), - properties = mkILProperties (tagProps @ basePropsFromAlt @ selfProps @ existingProps) + properties = mkILProperties (tagProps @ basePropsFromAlt @ selfProps @ existingProps), + customAttrs = + if cud.IsNullPermitted && g.checkNullness && g.langFeatureNullness then + td.CustomAttrs.AsArray() + |> Array.append [|GetNullableAttribute g [FSharp.Compiler.TypedTree.NullnessInfo.WithNull]|] + |> mkILCustomAttrsFromArray + else td.CustomAttrs ) // The .cctor goes on the Cases type since that's where the constant fields for nullary constructors live |> addConstFieldInit diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index ebce3a3df47..15d590a30bf 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -693,15 +693,11 @@ and GenUnionCaseRef (cenv: cenv) m tyenv i (fspecs: RecdField[]) = let ilFieldDef = mkILInstanceField (fspec.LogicalName, GenType cenv m tyenv fspec.FormalType, None, ILMemberAccess.Public) // These properties on the "field" of an alternative end up going on a property generated by cu_erase.fs - IlxUnionCaseField( - ilFieldDef.With( - customAttrs = - mkILCustomAttrs - [ - (mkCompilationMappingAttrWithVariantNumAndSeqNum g (int SourceConstructFlags.Field) i j) - ] - ) - )) + let attrs = + (mkCompilationMappingAttrWithVariantNumAndSeqNum g (int SourceConstructFlags.Field) i j) + :: GenAdditionalAttributesForTy g fspec.FormalType + + IlxUnionCaseField(ilFieldDef.With(customAttrs = mkILCustomAttrs attrs))) and GenUnionRef (cenv: cenv) m (tcref: TyconRef) = let g = cenv.g @@ -722,7 +718,7 @@ and GenUnionRef (cenv: cenv) m (tcref: TyconRef) = |> Array.mapi (fun i cspec -> { altName = cspec.CompiledName - altCustomAttrs = emptyILCustomAttrs + altCustomAttrs = mkILCustomAttrs [ GetNullableContextAttribute g ] altFields = GenUnionCaseRef cenv m tyenvinner i cspec.RecdFieldsArray }) @@ -1868,12 +1864,19 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) = let gevents = ResizeArray(tdef.Events.AsList()) let gnested = TypeDefsBuilder() - member _.Close(g: TcGlobals) = - let needsNullableContext = (gmethods.Count + gfields.Count + gproperties.Count) > 0 + member _.Close(g: TcGlobals) = let attrs = - if needsNullableContext && g.checkNullness && g.langFeatureNullness then - mkILCustomAttrsFromArray (Array.append (tdef.CustomAttrs.AsArray()) [| GetNullableContextAttribute g |]) + if g.checkNullness && g.langFeatureNullness then + let attrsBefore = tdef.CustomAttrs + [| + yield! attrsBefore.AsArray() + if attrsBefore |> TryFindILAttribute g.attrib_AllowNullLiteralAttribute then + yield GetNullableAttribute g [NullnessInfo.WithNull] + if (gmethods.Count + gfields.Count + gproperties.Count) > 0 then + yield GetNullableContextAttribute g + |] + |> mkILCustomAttrsFromArray else tdef.CustomAttrs @@ -5576,13 +5579,18 @@ and GenGenericParam cenv eenv (tp: Typar) = let notNullReferenceTypeConstraint = if g.langFeatureNullness && g.checkNullness then - tp.Constraints - |> List.exists (function - | TyparConstraint.NotSupportsNull _ -> true - | _ -> false) - |> (function - | true -> NullnessInfo.WithoutNull - | false -> NullnessInfo.WithNull) + let hasNotSupportsNull = + tp.Constraints + |> List.exists (function + | TyparConstraint.NotSupportsNull _ -> true + | _ -> false) + + if hasNotSupportsNull || notNullableValueTypeConstraint then + NullnessInfo.WithoutNull + elif hasNotSupportsNull || refTypeConstraint then + NullnessInfo.WithNull + else + NullnessInfo.AmbivalentToNull |> Some else None @@ -5633,9 +5641,7 @@ and GenGenericParam cenv eenv (tp: Typar) = if emitUnmanagedInIlOutput then yield (GetIsUnmanagedAttribute g) match notNullReferenceTypeConstraint with - // If using the `checknulls` flag, F# generated class has [] - // This means that everything inside is considered to be NOT-nullable by default - | Some NullnessInfo.WithNull -> yield GetNullableAttribute g [ NullnessInfo.WithNull ] + | Some nullInfo -> yield GetNullableAttribute g [ nullInfo ] | _ -> () ] @@ -10841,7 +10847,11 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = literalValue = None, offset = ilFieldOffset, marshal = None, - customAttrs = mkILCustomAttrs (GenAttrs cenv eenv fattribs @ extraAttribs @ GenAdditionalAttributesForTy g fspec.FormalType ) + customAttrs = + mkILCustomAttrs ( + GenAttrs cenv eenv fattribs + @ extraAttribs @ GenAdditionalAttributesForTy g fspec.FormalType + ) ) .WithAccess(access) .WithStatic(isStatic) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl index f7b3bc189b3..4153e65f617 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl @@ -108,13 +108,15 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 03 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .param type a - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .param type b + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .param type c - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .param type d - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .param type e - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .maxstack 8 IL_0000: ldarg.1 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl index 5411a5f901f..feada7bde4e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl @@ -35,9 +35,11 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .param type X - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .param type Y .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type Z + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .field assembly int32 JustInt@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl index 2b21b830b63..66faee727eb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl @@ -35,9 +35,11 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 02 00 00 00 00 00 ) .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .param type X - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .param type Y .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type Z + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .field assembly int32 JustInt@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl index 9961a90d43f..6e7be29b3a1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl @@ -175,6 +175,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/MyDu/MaybeString::get_Item() @@ -300,6 +301,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/MyDu/MaybeString@DebugTypeProxy::get_Item() diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl index a0f5d34249c..47b2d95422a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl @@ -175,6 +175,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/MyDu/MaybeString::get_Item() @@ -300,6 +301,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/MyDu/MaybeString@DebugTypeProxy::get_Item() diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs index 4062320867d..2571094f73f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs @@ -9,5 +9,5 @@ type MyStructDU = let getVal x = match x with - | B text -> text + | C text -> text | _ -> failwith "fail" \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl index 284d2459335..1a07e212ffa 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl @@ -284,6 +284,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/Myassembly::get_nullableString() @@ -417,6 +418,49 @@ } } +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute extends [runtime]System.Attribute { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl index f08847a4c03..5e3813688f2 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl @@ -284,6 +284,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/Myassembly::get_nullableString() @@ -324,6 +325,49 @@ { } +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute extends [runtime]System.Attribute { From c6352345ec27779ac7be19982071d574377ace51 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 20 Sep 2023 18:05:37 +0200 Subject: [PATCH 20/33] propagate DU nullness into functions working with it --- .../EmittedIL/Nullness/StructDU.fs.il.net472.bsl | 6 ++++-- .../EmittedIL/Nullness/StructDU.fs.il.netcore.bsl | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl index 1a07e212ffa..2e4856cd462 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl @@ -293,6 +293,8 @@ .method public static string getVal(valuetype MyTestModule/Myassembly x) cil managed { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 3 .locals init (valuetype MyTestModule/Myassembly V_0, @@ -302,11 +304,11 @@ IL_0001: stloc.0 IL_0002: ldloca.s V_0 IL_0004: call instance int32 MyTestModule/Myassembly::get_Tag() - IL_0009: ldc.i4.1 + IL_0009: ldc.i4.2 IL_000a: bne.un.s IL_0016 IL_000c: ldloca.s V_0 - IL_000e: ldfld string MyTestModule/Myassembly::_nonNullableString + IL_000e: ldfld string MyTestModule/Myassembly::_nullableString IL_0013: stloc.1 IL_0014: ldloc.1 IL_0015: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl index 5e3813688f2..974470d65ea 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl @@ -293,6 +293,8 @@ .method public static string getVal(valuetype MyTestModule/Myassembly x) cil managed { + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 3 .locals init (valuetype MyTestModule/Myassembly V_0, @@ -302,11 +304,11 @@ IL_0001: stloc.0 IL_0002: ldloca.s V_0 IL_0004: call instance int32 MyTestModule/Myassembly::get_Tag() - IL_0009: ldc.i4.1 + IL_0009: ldc.i4.2 IL_000a: bne.un.s IL_0016 IL_000c: ldloca.s V_0 - IL_000e: ldfld string MyTestModule/Myassembly::_nonNullableString + IL_000e: ldfld string MyTestModule/Myassembly::_nullableString IL_0013: stloc.1 IL_0014: ldloc.1 IL_0015: ret From ed573425f7bdedf92a0dccfed4d489440186a1c0 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 20 Sep 2023 19:51:45 +0200 Subject: [PATCH 21/33] nullable context for inner classes of DUs, ambivalent nullness for fields of struct DUs --- src/Compiler/CodeGen/EraseUnions.fs | 78 ++++++++++++++++--- src/Compiler/CodeGen/IlxGen.fs | 15 ++-- src/Compiler/TypedTree/TypedTreeOps.fs | 3 + src/Compiler/TypedTree/TypedTreeOps.fsi | 2 + .../Nullness/ReferenceDU.fs.il.net472.bsl | 7 ++ .../Nullness/ReferenceDU.fs.il.netcore.bsl | 7 ++ .../Nullness/StructDU.fs.il.net472.bsl | 9 ++- .../Nullness/StructDU.fs.il.netcore.bsl | 9 ++- 8 files changed, 112 insertions(+), 18 deletions(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 61a91d7f5c2..23c83d2d7e8 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -8,6 +8,7 @@ open FSharp.Compiler.IlxGenSupport open System.Collections.Generic open System.Reflection open Internal.Utilities.Library +open FSharp.Compiler.TypedTreeOps open FSharp.Compiler.TcGlobals open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.ILX.Types @@ -665,6 +666,7 @@ let emitDataSwitch ilg (cg: ICodeGen<'Mark>) (avoidHelpers, cuspec, cases) = let mkMethodsAndPropertiesForFields (addMethodGeneratedAttrs, addPropertyGeneratedAttrs) + (g: TcGlobals) access attr imports @@ -704,15 +706,28 @@ let mkMethodsAndPropertiesForFields for field in fields do let fspec = mkILFieldSpecInTy (ilTy, field.LowerName, field.Type) + let ilReturn = mkILReturn field.Type + + let ilReturn = + if TryFindILAttribute g.attrib_NullableAttribute field.ILField.CustomAttrs then + let attrs = + field.ILField.CustomAttrs.AsArray() + |> Array.filter (IsILAttrib g.attrib_NullableAttribute) + + ilReturn.WithCustomAttrs(mkILCustomAttrsFromArray attrs) + else + ilReturn + yield mkILNonGenericInstanceMethod ( "get_" + adjustFieldName hasHelpers field.Name, access, [], - mkILReturn field.Type, + ilReturn, mkMethodBody (true, [], 2, nonBranchingInstrsToCode [ mkLdarg 0us; mkNormalLdfld fspec ], attr, imports) ) |> addMethodGeneratedAttrs + ] basicProps, basicMethods @@ -921,7 +936,19 @@ let convAlternativeDef mkMakerName cuspec altName, cud.HelpersAccessibility, fields - |> Array.map (fun fd -> mkILParamNamed (fd.LowerName, fd.Type)) + |> Array.map (fun fd -> + let plainParam = mkILParamNamed (fd.LowerName, fd.Type) + + if TryFindILAttribute g.attrib_NullableAttribute fd.ILField.CustomAttrs then + let attrs = + fd.ILField.CustomAttrs.AsArray() + |> Array.filter (IsILAttrib g.attrib_NullableAttribute) + + { plainParam with + CustomAttrsStored = storeILCustomAttrs (mkILCustomAttrsFromArray attrs) + } + else + plainParam) |> Array.toList, mkILReturn baseTy, mkMethodBody (true, locals, fields.Length + locals.Length, nonBranchingInstrsToCode ilInstrs, attr, imports) @@ -1090,6 +1117,7 @@ let convAlternativeDef let basicProps, basicMethods = mkMethodsAndPropertiesForFields (addMethodGeneratedAttrs, addPropertyGeneratedAttrs) + g cud.UnionCasesAccessibility attr imports @@ -1141,7 +1169,7 @@ let convAlternativeDef emptyILTypeDefs, mkILProperties basicProps, emptyILEvents, - mkILCustomAttrs debugAttrs, + mkILCustomAttrs (GetNullableContextAttribute g :: debugAttrs), ILTypeInit.BeforeField ) @@ -1261,15 +1289,46 @@ let mkClassUnionDef |> addMethodGeneratedAttrs ] + let fieldDefs = + // Since structs are flattened out for all cases together, all non-struct field are potentially nullable + // TODO nullness + // Invent C#-friendly access pattern that will work with nullability + // TODO nullness + // In case of type being a generic instantiation (e.g. | A of (list)), we can at least mark the generic arguments as being not null + if + isStruct + && cud.UnionCases.Length > 1 + && g.checkNullness + && g.langFeatureNullness + then + alt.FieldDefs + |> Array.map (fun field -> + if field.Type.Boxity = AsValue then + field + else + let attrs = + field.ILField.CustomAttrs.AsArray() + |> Array.filter (IsILAttrib g.attrib_NullableAttribute >> not) + |> Array.append + [| + GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.AmbivalentToNull ] + |] + + field.ILField.With(customAttrs = mkILCustomAttrsFromArray attrs) + |> IlxUnionCaseField) + else + alt.FieldDefs + let props, meths = mkMethodsAndPropertiesForFields (addMethodGeneratedAttrs, addPropertyGeneratedAttrs) + g cud.UnionCasesAccessibility cud.DebugPoint cud.DebugImports cud.HasHelpers baseTy - alt.FieldDefs + fieldDefs yield (fields, (ctor @ meths), props) ] @@ -1468,12 +1527,13 @@ let mkClassUnionDef @ td.Fields.AsList() ), properties = mkILProperties (tagProps @ basePropsFromAlt @ selfProps @ existingProps), - customAttrs = - if cud.IsNullPermitted && g.checkNullness && g.langFeatureNullness then - td.CustomAttrs.AsArray() - |> Array.append [|GetNullableAttribute g [FSharp.Compiler.TypedTree.NullnessInfo.WithNull]|] + customAttrs = + if cud.IsNullPermitted && g.checkNullness && g.langFeatureNullness then + td.CustomAttrs.AsArray() + |> Array.append [| GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.WithNull ] |] |> mkILCustomAttrsFromArray - else td.CustomAttrs + else + td.CustomAttrs ) // The .cctor goes on the Cases type since that's where the constant fields for nullary constructors live |> addConstFieldInit diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 15d590a30bf..cbf129b653c 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -718,7 +718,7 @@ and GenUnionRef (cenv: cenv) m (tcref: TyconRef) = |> Array.mapi (fun i cspec -> { altName = cspec.CompiledName - altCustomAttrs = mkILCustomAttrs [ GetNullableContextAttribute g ] + altCustomAttrs = emptyILCustomAttrs altFields = GenUnionCaseRef cenv m tyenvinner i cspec.RecdFieldsArray }) @@ -1864,19 +1864,20 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) = let gevents = ResizeArray(tdef.Events.AsList()) let gnested = TypeDefsBuilder() - member _.Close(g: TcGlobals) = + member _.Close(g: TcGlobals) = let attrs = if g.checkNullness && g.langFeatureNullness then - let attrsBefore = tdef.CustomAttrs + let attrsBefore = tdef.CustomAttrs + [| yield! attrsBefore.AsArray() if attrsBefore |> TryFindILAttribute g.attrib_AllowNullLiteralAttribute then - yield GetNullableAttribute g [NullnessInfo.WithNull] + yield GetNullableAttribute g [ NullnessInfo.WithNull ] if (gmethods.Count + gfields.Count + gproperties.Count) > 0 then yield GetNullableContextAttribute g |] - |> mkILCustomAttrsFromArray + |> mkILCustomAttrsFromArray else tdef.CustomAttrs @@ -5579,7 +5580,7 @@ and GenGenericParam cenv eenv (tp: Typar) = let notNullReferenceTypeConstraint = if g.langFeatureNullness && g.checkNullness then - let hasNotSupportsNull = + let hasNotSupportsNull = tp.Constraints |> List.exists (function | TyparConstraint.NotSupportsNull _ -> true @@ -5641,7 +5642,7 @@ and GenGenericParam cenv eenv (tp: Typar) = if emitUnmanagedInIlOutput then yield (GetIsUnmanagedAttribute g) match notNullReferenceTypeConstraint with - | Some nullInfo -> yield GetNullableAttribute g [ nullInfo ] + | Some nullInfo -> yield GetNullableAttribute g [ nullInfo ] | _ -> () ] diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index 73632fbd66c..a2d82383aa9 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -3487,6 +3487,9 @@ let TryFindILAttributeOpt attr attrs = | Some (AttribInfo (atref, _)) -> HasILAttribute atref attrs | _ -> false +let IsILAttrib (AttribInfo (builtInAttrRef, _)) attr = isILAttrib builtInAttrRef attr + + /// Analyze three cases for attributes declared on type definitions: IL-declared attributes, F#-declared attributes and /// provided attributes. // diff --git a/src/Compiler/TypedTree/TypedTreeOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.fsi index 608c242e942..2403a8ad4ef 100755 --- a/src/Compiler/TypedTree/TypedTreeOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.fsi @@ -2238,6 +2238,8 @@ val mkLdelem: TcGlobals -> range -> TType -> Expr -> Expr -> Expr val TryDecodeILAttribute: ILTypeRef -> ILAttributes -> (ILAttribElem list * ILAttributeNamedArg list) option +val IsILAttrib: BuiltinAttribInfo -> ILAttribute -> bool + val TryFindILAttribute: BuiltinAttribInfo -> ILAttributes -> bool val TryFindILAttributeOpt: BuiltinAttribInfo option -> ILAttributes -> bool diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl index 6e7be29b3a1..eb38e7bad87 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl @@ -52,6 +52,7 @@ .class auto ansi serializable nested assembly beforefieldinit specialname _JustLabel extends MyTestModule/MyDu { + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 2B 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B 4D 79 44 75 2B 5F 4A 75 73 74 4C 61 62 65 6C 40 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 00 ) @@ -77,6 +78,7 @@ .class auto ansi serializable nested public beforefieldinit specialname JustInt extends MyTestModule/MyDu { + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 28 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B 4D 79 44 75 2B 4A 75 73 74 49 6E 74 40 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 00 ) @@ -130,6 +132,7 @@ .class auto ansi serializable nested public beforefieldinit specialname MaybeString extends MyTestModule/MyDu { + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 2C 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B 4D 79 44 75 2B 4D 61 79 62 65 53 74 72 69 6E 67 40 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 @@ -163,6 +166,8 @@ { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -393,6 +398,8 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl index 47b2d95422a..1815f073173 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl @@ -52,6 +52,7 @@ .class auto ansi serializable nested assembly beforefieldinit specialname _JustLabel extends MyTestModule/MyDu { + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 2B 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B 4D 79 44 75 2B 5F 4A 75 73 74 4C 61 62 65 6C 40 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 00 ) @@ -77,6 +78,7 @@ .class auto ansi serializable nested public beforefieldinit specialname JustInt extends MyTestModule/MyDu { + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 28 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B 4D 79 44 75 2B 4A 75 73 74 49 6E 74 40 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 00 ) @@ -130,6 +132,7 @@ .class auto ansi serializable nested public beforefieldinit specialname MaybeString extends MyTestModule/MyDu { + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerTypeProxyAttribute::.ctor(class [runtime]System.Type) = ( 01 00 2C 4D 79 54 65 73 74 4D 6F 64 75 6C 65 2B 4D 79 44 75 2B 4D 61 79 62 65 53 74 72 69 6E 67 40 44 65 62 75 67 54 79 70 65 50 72 6F 78 79 00 @@ -163,6 +166,8 @@ { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -393,6 +398,8 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl index 2e4856cd462..3fc8df226c7 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl @@ -122,6 +122,8 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 2 .locals init (valuetype MyTestModule/Myassembly V_0) @@ -172,6 +174,8 @@ { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -184,6 +188,8 @@ { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -272,6 +278,7 @@ } .property instance string nonNullableString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) @@ -281,10 +288,10 @@ } .property instance string nullableString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/Myassembly::get_nullableString() diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl index 974470d65ea..8c26a601665 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl @@ -122,6 +122,8 @@ { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 02 00 00 00 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 2 .locals init (valuetype MyTestModule/Myassembly V_0) @@ -172,6 +174,8 @@ { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -184,6 +188,8 @@ { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -272,6 +278,7 @@ } .property instance string nonNullableString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) @@ -281,10 +288,10 @@ } .property instance string nullableString() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/Myassembly::get_nullableString() From 77948c14e2983a087068fdbc39ebe9af043ffef5 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 20 Sep 2023 19:59:54 +0200 Subject: [PATCH 22/33] use Map instead of dict so that .bsl can be the same across net472/netcore --- .../EmittedIL/Nullness/CustomType.fs | 4 +- .../EmittedIL/Nullness/CustomType.fs.il.bsl | 37 ++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs index f4aac11e1c5..2e52933d1fe 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs @@ -7,7 +7,7 @@ type MyCustomType (x: MaybeString, y: string) = static let mutable uglyGlobalMutableString : string = "" static let mutable uglyGlobalMutableNullableString : MaybeString = null - static let dict = System.Collections.Generic.Dictionary() + static let mutable dict : Map = Map.empty member val Nullable = x member val NonNullable = y @@ -22,4 +22,4 @@ type MyCustomType (x: MaybeString, y: string) = member this.Item with get (index) = dict.[index] - and set index value = dict.[index] <- value \ No newline at end of file + and set index value = dict <- dict.Add(index,value) \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl index dce23e42161..8c7e3af2bcd 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl @@ -5,11 +5,6 @@ .assembly extern runtime { } .assembly extern FSharp.Core { } -.assembly extern System.Collections -{ - .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) - .ver 7:0:0:0 -} .assembly assembly { .hash algorithm 0x00008004 @@ -40,7 +35,7 @@ .field static assembly string uglyGlobalMutableString .field static assembly string uglyGlobalMutableNullableString .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - .field static assembly class [System.Collections]System.Collections.Generic.Dictionary`2 dict + .field static assembly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2 dict .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 02 02 00 00 ) .field assembly string Nullable@ .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) @@ -172,10 +167,10 @@ IL_000a: call void [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/IntrinsicFunctions::FailStaticInit() IL_000f: br.s IL_0011 - IL_0011: ldsfld class [System.Collections]System.Collections.Generic.Dictionary`2 MyTestModule/Myassembly::dict + IL_0011: ldsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2 MyTestModule/Myassembly::dict IL_0016: ldarg.1 IL_0017: tail. - IL_0019: callvirt instance !1 class [System.Collections]System.Collections.Generic.Dictionary`2::get_Item(!0) + IL_0019: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2::get_Item(!0) IL_001e: ret } @@ -197,13 +192,21 @@ IL_000a: call void [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/IntrinsicFunctions::FailStaticInit() IL_000f: br.s IL_0011 - IL_0011: ldsfld class [System.Collections]System.Collections.Generic.Dictionary`2 MyTestModule/Myassembly::dict - IL_0016: ldarg.1 - IL_0017: ldarg.2 - IL_0018: tail. - IL_001a: callvirt instance void class [System.Collections]System.Collections.Generic.Dictionary`2::set_Item(!0, - !1) - IL_001f: ret + IL_0011: volatile. + IL_0013: ldsfld int32 MyTestModule/Myassembly::init@6 + IL_0018: ldc.i4.4 + IL_0019: bge.s IL_0022 + + IL_001b: call void [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/IntrinsicFunctions::FailStaticInit() + IL_0020: br.s IL_0022 + + IL_0022: ldsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2 MyTestModule/Myassembly::dict + IL_0027: ldarg.1 + IL_0028: ldarg.2 + IL_0029: callvirt instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2::Add(!0, + !1) + IL_002e: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2 MyTestModule/Myassembly::dict + IL_0033: ret } .method private specialname rtspecialname static @@ -265,8 +268,8 @@ IL_0018: ldc.i4.3 IL_0019: volatile. IL_001b: stsfld int32 MyTestModule/Myassembly::init@6 - IL_0020: newobj instance void class [System.Collections]System.Collections.Generic.Dictionary`2::.ctor() - IL_0025: stsfld class [System.Collections]System.Collections.Generic.Dictionary`2 MyTestModule/Myassembly::dict + IL_0020: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2 [FSharp.Core]Microsoft.FSharp.Collections.MapModule::Empty() + IL_0025: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2 MyTestModule/Myassembly::dict IL_002a: ldc.i4.4 IL_002b: volatile. IL_002d: stsfld int32 MyTestModule/Myassembly::init@6 From bec7b874626386c735bb9debd646c778dcc2b0c7 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 21 Sep 2023 12:10:11 +0200 Subject: [PATCH 23/33] various Option<> representations --- src/Compiler/CodeGen/EraseUnions.fs | 15 ++++++--- .../EmittedIL/Nullness/NullAsTrueValue.fs | 33 +++++++++++++++++++ .../Nullness/NullAsTrueValue.fs.il.net472.bsl | 0 .../NullAsTrueValue.fs.il.netcore.bsl | 0 .../EmittedIL/Nullness/NullnessMetadata.fs | 5 +++ 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 23c83d2d7e8..7146bb9bb71 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -862,13 +862,20 @@ let convAlternativeDef let baseMakerMeths, baseMakerProps = if alt.IsNullary then + let attributes = + if g.checkNullness && g.langFeatureNullness && repr.RepresentAlternativeAsNull(info,alt) then + GetNullableAttribute g [FSharp.Compiler.TypedTree.NullnessInfo.WithNull] + |> Array.singleton + |> mkILCustomAttrsFromArray + else + emptyILCustomAttrs let nullaryMeth = mkILNonGenericStaticMethod ( "get_" + altName, cud.HelpersAccessibility, [], - mkILReturn baseTy, + (mkILReturn baseTy).WithCustomAttrs attributes, mkMethodBody ( true, [], @@ -892,7 +899,7 @@ let convAlternativeDef propertyType = baseTy, init = None, args = [], - customAttrs = emptyILCustomAttrs + customAttrs = attributes ) |> addPropertyGeneratedAttrs |> addPropertyNeverAttrs @@ -1292,7 +1299,7 @@ let mkClassUnionDef let fieldDefs = // Since structs are flattened out for all cases together, all non-struct field are potentially nullable // TODO nullness - // Invent C#-friendly access pattern that will work with nullability + // Invent C#-friendly access pattern that will work with nullability, e.g. bool this.TryGetCaseXXXData([NotNullWhen(true)]out field1,[NotNullWhen(true)]out field2) // TODO nullness // In case of type being a generic instantiation (e.g. | A of (list)), we can at least mark the generic arguments as being not null if @@ -1303,7 +1310,7 @@ let mkClassUnionDef then alt.FieldDefs |> Array.map (fun field -> - if field.Type.Boxity = AsValue then + if field.Type.IsNominal && field.Type.Boxity = AsValue then field else let attrs = diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs new file mode 100644 index 00000000000..d8d90423ccf --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs @@ -0,0 +1,33 @@ +module TestModule + +[] +[] +type MyNullableOption<'T when 'T:null> = + | MyNone + | MySome of value:'T + +let mapPossiblyNullable f myOpt = + match myOpt with + | MyNone -> MyNone + | MySome x -> MySome (f x) + +[] +[] +type MyOptionWhichCannotHaveNullInTheInside<'T when 'T:not null> = + | MyNotNullNone + | MyNotNullSome of value:'T + +let mapNotNullableContents f myOpt = + match myOpt with + | MyNotNullNone -> MyNotNullNone + | MyNotNullSome x -> MyNotNullSome (f x) + +[] +type MyStructOption<'T when 'T: not null> = + | MyStructNone + | MyStructSome of notNullField1 : 'T * notNullField2 : string + +let mapStructContents f myOpt = + match myOpt with + | MyStructNone -> MyStructNone + | MyStructSome(x,s) -> MyStructSome (f x,s) \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index 728a0dac598..4f0fad2f3a9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -64,3 +64,8 @@ let ``Nullable attr for custom type`` compilation = compilation |> verifyCompilation DoNotOptimize +[] +let ``Nullable attr for Option clones`` compilation = + compilation + |> verifyCompilation DoNotOptimize + From 83989ec9ea0b3d3e882a62854251d280c15c590a Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 21 Sep 2023 12:40:25 +0200 Subject: [PATCH 24/33] Defensive field access to unions --- .../Nullness/NullAsTrueValue.fs.il.net472.bsl | 881 ++++++++++++++++++ .../NullAsTrueValue.fs.il.netcore.bsl | 788 ++++++++++++++++ 2 files changed, 1669 insertions(+) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl index e69de29bb2d..9614f241201 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl @@ -0,0 +1,881 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed TestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class auto autochar serializable sealed nested public beforefieldinit MyNullableOption`1 + extends [runtime]System.Object + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationRepresentationAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilationRepresentationFlags) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .field public static literal int32 MyNone = int32(0x00000000) + .field public static literal int32 MySome = int32(0x00000001) + } + + .field assembly initonly !T _value + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 E0 07 00 00 1D 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 4E 75 6C 6C 61 62 6C 65 4F 70 74 69 + 6F 6E 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ret + } + + .method public static class TestModule/MyNullableOption`1 + get_MyNone() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public static class TestModule/MyNullableOption`1 + NewMySome(!T _value) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void class TestModule/MyNullableOption`1::.ctor(!0) + IL_0006: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(!T _value) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 1D 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 4E 75 6C 6C 61 62 6C 65 4F 70 74 69 + 6F 6E 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld !0 class TestModule/MyNullableOption`1::_value + IL_000d: ret + } + + .method public hidebysig instance !T + get_value() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 class TestModule/MyNullableOption`1::_value + IL_0006: ret + } + + .method public static int32 GetTag(class TestModule/MyNullableOption`1 A_0) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0006 + + IL_0003: ldc.i4.1 + IL_0004: br.s IL_0007 + + IL_0006: ldc.i4.0 + IL_0007: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class TestModule/MyNullableOption`1>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .property class TestModule/MyNullableOption`1 + MyNone() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get class TestModule/MyNullableOption`1 TestModule/MyNullableOption`1::get_MyNone() + } + .property instance !T 'value'() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance !T TestModule/MyNullableOption`1::get_value() + } + } + + .class auto autochar serializable sealed nested public beforefieldinit MyOptionWhichCannotHaveNullInTheInside`1 + extends [runtime]System.Object + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationRepresentationAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilationRepresentationFlags) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field public static literal int32 MyNotNullNone = int32(0x00000000) + .field public static literal int32 MyNotNullSome = int32(0x00000001) + } + + .field assembly initonly !T _value + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 E0 07 00 00 33 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 4F 70 74 69 6F 6E 57 68 69 63 68 43 + 61 6E 6E 6F 74 48 61 76 65 4E 75 6C 6C 49 6E 54 + 68 65 49 6E 73 69 64 65 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ret + } + + .method public static class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 + get_MyNotNullNone() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public static class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 + NewMyNotNullSome(!T _value) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::.ctor(!0) + IL_0006: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(!T _value) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 33 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 4F 70 74 69 6F 6E 57 68 69 63 68 43 + 61 6E 6E 6F 74 48 61 76 65 4E 75 6C 6C 49 6E 54 + 68 65 49 6E 73 69 64 65 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld !0 class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::_value + IL_000d: ret + } + + .method public hidebysig instance !T + get_value() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::_value + IL_0006: ret + } + + .method public static int32 GetTag(class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 A_0) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0006 + + IL_0003: ldc.i4.1 + IL_0004: br.s IL_0007 + + IL_0006: ldc.i4.0 + IL_0007: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class TestModule/MyOptionWhichCannotHaveNullInTheInside`1>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .property class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 + MyNotNullNone() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 TestModule/MyOptionWhichCannotHaveNullInTheInside`1::get_MyNotNullNone() + } + .property instance !T 'value'() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance !T TestModule/MyOptionWhichCannotHaveNullInTheInside`1::get_value() + } + } + + .class sequential autochar serializable sealed nested public beforefieldinit MyStructOption`1 + extends [runtime]System.ValueType + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field public static literal int32 MyStructNone = int32(0x00000000) + .field public static literal int32 MyStructSome = int32(0x00000001) + } + + .field assembly !T _notNullField1 + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly string _notNullField2 + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly int32 _tag + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public static valuetype TestModule/MyStructOption`1 + get_MyStructNone() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: newobj instance void valuetype TestModule/MyStructOption`1::.ctor(int32) + IL_0006: ret + } + + .method public hidebysig instance bool + get_IsMyStructNone() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 valuetype TestModule/MyStructOption`1::get_Tag() + IL_0006: ldc.i4.0 + IL_0007: ceq + IL_0009: ret + } + + .method public static valuetype TestModule/MyStructOption`1 + NewMyStructSome(!T _notNullField1, + string _notNullField2) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (valuetype TestModule/MyStructOption`1 V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj valuetype TestModule/MyStructOption`1 + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.1 + IL_000b: stfld int32 valuetype TestModule/MyStructOption`1::_tag + IL_0010: ldloca.s V_0 + IL_0012: ldarg.0 + IL_0013: stfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_0018: ldloca.s V_0 + IL_001a: ldarg.1 + IL_001b: stfld string valuetype TestModule/MyStructOption`1::_notNullField2 + IL_0020: ldloc.0 + IL_0021: ret + } + + .method public hidebysig instance bool + get_IsMyStructSome() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 valuetype TestModule/MyStructOption`1::get_Tag() + IL_0006: ldc.i4.1 + IL_0007: ceq + IL_0009: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(int32 _tag) cil managed + { + .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 1B 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 53 74 72 75 63 74 4F 70 74 69 6F 6E + 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 valuetype TestModule/MyStructOption`1::_tag + IL_0007: ret + } + + .method public hidebysig instance !T + get_notNullField1() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_0006: ret + } + + .method public hidebysig instance string + get_notNullField2() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string valuetype TestModule/MyStructOption`1::_notNullField2 + IL_0006: ret + } + + .method public hidebysig instance int32 + get_Tag() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 valuetype TestModule/MyStructOption`1::_tag + IL_0006: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: ldobj valuetype TestModule/MyStructOption`1 + IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_001a: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,valuetype TestModule/MyStructOption`1>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: ldobj valuetype TestModule/MyStructOption`1 + IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_001a: ret + } + + .property instance int32 Tag() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance int32 TestModule/MyStructOption`1::get_Tag() + } + .property valuetype TestModule/MyStructOption`1 + MyStructNone() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get valuetype TestModule/MyStructOption`1 TestModule/MyStructOption`1::get_MyStructNone() + } + .property instance bool IsMyStructNone() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool TestModule/MyStructOption`1::get_IsMyStructNone() + } + .property instance bool IsMyStructSome() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool TestModule/MyStructOption`1::get_IsMyStructSome() + } + .property instance !T notNullField1() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance !T TestModule/MyStructOption`1::get_notNullField1() + } + .property instance string notNullField2() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string TestModule/MyStructOption`1::get_notNullField2() + } + } + + .method public static class TestModule/MyNullableOption`1 + mapPossiblyNullable(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + class TestModule/MyNullableOption`1 myOpt) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .param type a + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type b + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 4 + .locals init (class TestModule/MyNullableOption`1 V_0, + class TestModule/MyNullableOption`1 V_1, + !!a V_2) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: brfalse.s IL_0007 + + IL_0005: br.s IL_0009 + + IL_0007: ldnull + IL_0008: ret + + IL_0009: ldloc.0 + IL_000a: stloc.1 + IL_000b: ldloc.1 + IL_000c: ldfld !0 class TestModule/MyNullableOption`1::_value + IL_0011: stloc.2 + IL_0012: ldarg.0 + IL_0013: ldloc.2 + IL_0014: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0019: call class TestModule/MyNullableOption`1 class TestModule/MyNullableOption`1::NewMySome(!0) + IL_001e: ret + } + + .method public static class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 + mapNotNullableContents(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 myOpt) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .param type a + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type b + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + + .maxstack 4 + .locals init (class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 V_0, + class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 V_1, + !!a V_2) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: brfalse.s IL_0007 + + IL_0005: br.s IL_0009 + + IL_0007: ldnull + IL_0008: ret + + IL_0009: ldloc.0 + IL_000a: stloc.1 + IL_000b: ldloc.1 + IL_000c: ldfld !0 class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::_value + IL_0011: stloc.2 + IL_0012: ldarg.0 + IL_0013: ldloc.2 + IL_0014: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0019: call class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::NewMyNotNullSome(!0) + IL_001e: ret + } + + .method public static valuetype TestModule/MyStructOption`1 + mapStructContents(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + valuetype TestModule/MyStructOption`1 myOpt) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .param type a + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type b + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .param [2] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 4 + .locals init (valuetype TestModule/MyStructOption`1 V_0, + !!a V_1, + string V_2) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance int32 valuetype TestModule/MyStructOption`1::get_Tag() + IL_0009: ldc.i4.1 + IL_000a: bne.un.s IL_000e + + IL_000c: br.s IL_0014 + + IL_000e: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::get_MyStructNone() + IL_0013: ret + + IL_0014: ldloca.s V_0 + IL_0016: ldfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_001b: stloc.1 + IL_001c: ldloca.s V_0 + IL_001e: ldfld string valuetype TestModule/MyStructOption`1::_notNullField2 + IL_0023: stloc.2 + IL_0024: ldarg.0 + IL_0025: ldloc.1 + IL_0026: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_002b: ldloc.2 + IL_002c: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(!0, + string) + IL_0031: ret + } + +} + +.class private abstract auto ansi sealed ''.$TestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi serializable sealed System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + extends [runtime]System.Enum +{ + .custom instance void [runtime]System.FlagsAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public specialname rtspecialname int32 value__ + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes All = int32(0xFFFFFFFF) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes None = int32(0x00000000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicParameterlessConstructor = int32(0x00000001) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicConstructors = int32(0x00000003) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicConstructors = int32(0x00000004) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicMethods = int32(0x00000008) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicMethods = int32(0x00000010) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicFields = int32(0x00000020) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicFields = int32(0x00000040) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicNestedTypes = int32(0x00000080) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicNestedTypes = int32(0x00000100) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicProperties = int32(0x00000200) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicProperties = int32(0x00000400) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes PublicEvents = int32(0x00000800) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes NonPublicEvents = int32(0x00001000) + .field public static literal valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes Interfaces = int32(0x00002000) +} + +.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute + extends [runtime]System.Attribute +{ + .field private valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [runtime]System.Type Type@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, + class [runtime]System.Type Type) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0014: ret + } + + .method public hidebysig specialname instance class [runtime]System.Type + get_Type() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::Type@ + IL_0006: ret + } + + .method public hidebysig specialname instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + get_MemberType() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::MemberType@ + IL_0006: ret + } + + .property instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes + MemberType() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_MemberType() + } + .property instance class [runtime]System.Type + Type() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [runtime]System.Type System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::get_Type() + } +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl index e69de29bb2d..a6adfcf985f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl @@ -0,0 +1,788 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.dll + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed TestModule + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class auto autochar serializable sealed nested public beforefieldinit MyNullableOption`1 + extends [runtime]System.Object + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationRepresentationAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilationRepresentationFlags) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .field public static literal int32 MyNone = int32(0x00000000) + .field public static literal int32 MySome = int32(0x00000001) + } + + .field assembly initonly !T _value + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 E0 07 00 00 1D 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 4E 75 6C 6C 61 62 6C 65 4F 70 74 69 + 6F 6E 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ret + } + + .method public static class TestModule/MyNullableOption`1 + get_MyNone() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public static class TestModule/MyNullableOption`1 + NewMySome(!T _value) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void class TestModule/MyNullableOption`1::.ctor(!0) + IL_0006: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(!T _value) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 1D 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 4E 75 6C 6C 61 62 6C 65 4F 70 74 69 + 6F 6E 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld !0 class TestModule/MyNullableOption`1::_value + IL_000d: ret + } + + .method public hidebysig instance !T + get_value() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 class TestModule/MyNullableOption`1::_value + IL_0006: ret + } + + .method public static int32 GetTag(class TestModule/MyNullableOption`1 A_0) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0006 + + IL_0003: ldc.i4.1 + IL_0004: br.s IL_0007 + + IL_0006: ldc.i4.0 + IL_0007: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class TestModule/MyNullableOption`1>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .property class TestModule/MyNullableOption`1 + MyNone() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get class TestModule/MyNullableOption`1 TestModule/MyNullableOption`1::get_MyNone() + } + .property instance !T 'value'() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance !T TestModule/MyNullableOption`1::get_value() + } + } + + .class auto autochar serializable sealed nested public beforefieldinit MyOptionWhichCannotHaveNullInTheInside`1 + extends [runtime]System.Object + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationRepresentationAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilationRepresentationFlags) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field public static literal int32 MyNotNullNone = int32(0x00000000) + .field public static literal int32 MyNotNullSome = int32(0x00000001) + } + + .field assembly initonly !T _value + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 E0 07 00 00 33 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 4F 70 74 69 6F 6E 57 68 69 63 68 43 + 61 6E 6E 6F 74 48 61 76 65 4E 75 6C 6C 49 6E 54 + 68 65 49 6E 73 69 64 65 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ret + } + + .method public static class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 + get_MyNotNullNone() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ret + } + + .method public static class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 + NewMyNotNullSome(!T _value) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::.ctor(!0) + IL_0006: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(!T _value) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 33 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 4F 70 74 69 6F 6E 57 68 69 63 68 43 + 61 6E 6E 6F 74 48 61 76 65 4E 75 6C 6C 49 6E 54 + 68 65 49 6E 73 69 64 65 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld !0 class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::_value + IL_000d: ret + } + + .method public hidebysig instance !T + get_value() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::_value + IL_0006: ret + } + + .method public static int32 GetTag(class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 A_0) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: brfalse.s IL_0006 + + IL_0003: ldc.i4.1 + IL_0004: br.s IL_0007 + + IL_0006: ldc.i4.0 + IL_0007: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,class TestModule/MyOptionWhichCannotHaveNullInTheInside`1>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_0015: ret + } + + .property class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 + MyNotNullNone() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 TestModule/MyOptionWhichCannotHaveNullInTheInside`1::get_MyNotNullNone() + } + .property instance !T 'value'() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance !T TestModule/MyOptionWhichCannotHaveNullInTheInside`1::get_value() + } + } + + .class sequential autochar serializable sealed nested public beforefieldinit MyStructOption`1 + extends [runtime]System.ValueType + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoEqualityAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoComparisonAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerDisplayAttribute::.ctor(string) = ( 01 00 15 7B 5F 5F 44 65 62 75 67 44 69 73 70 6C + 61 79 28 29 2C 6E 71 7D 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 01 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableContextAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .class abstract auto ansi sealed nested public Tags + extends [runtime]System.Object + { + .param type T + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .field public static literal int32 MyStructNone = int32(0x00000000) + .field public static literal int32 MyStructSome = int32(0x00000001) + } + + .field assembly !T _notNullField1 + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly string _notNullField2 + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly int32 _tag + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public static valuetype TestModule/MyStructOption`1 + get_MyStructNone() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 00 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: newobj instance void valuetype TestModule/MyStructOption`1::.ctor(int32) + IL_0006: ret + } + + .method public hidebysig instance bool + get_IsMyStructNone() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 valuetype TestModule/MyStructOption`1::get_Tag() + IL_0006: ldc.i4.0 + IL_0007: ceq + IL_0009: ret + } + + .method public static valuetype TestModule/MyStructOption`1 + NewMyStructSome(!T _notNullField1, + string _notNullField2) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (valuetype TestModule/MyStructOption`1 V_0) + IL_0000: ldloca.s V_0 + IL_0002: initobj valuetype TestModule/MyStructOption`1 + IL_0008: ldloca.s V_0 + IL_000a: ldc.i4.1 + IL_000b: stfld int32 valuetype TestModule/MyStructOption`1::_tag + IL_0010: ldloca.s V_0 + IL_0012: ldarg.0 + IL_0013: stfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_0018: ldloca.s V_0 + IL_001a: ldarg.1 + IL_001b: stfld string valuetype TestModule/MyStructOption`1::_notNullField2 + IL_0020: ldloc.0 + IL_0021: ret + } + + .method public hidebysig instance bool + get_IsMyStructSome() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance int32 valuetype TestModule/MyStructOption`1::get_Tag() + IL_0006: ldc.i4.1 + IL_0007: ceq + IL_0009: ret + } + + .method assembly specialname rtspecialname + instance void .ctor(int32 _tag) cil managed + { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, + class [runtime]System.Type) = ( 01 00 60 06 00 00 1B 54 65 73 74 4D 6F 64 75 6C + 65 2B 4D 79 53 74 72 75 63 74 4F 70 74 69 6F 6E + 60 31 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 valuetype TestModule/MyStructOption`1::_tag + IL_0007: ret + } + + .method public hidebysig instance !T + get_notNullField1() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_0006: ret + } + + .method public hidebysig instance string + get_notNullField2() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string valuetype TestModule/MyStructOption`1::_notNullField2 + IL_0006: ret + } + + .method public hidebysig instance int32 + get_Tag() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 valuetype TestModule/MyStructOption`1::_tag + IL_0006: ret + } + + .method assembly hidebysig specialname + instance object __DebugDisplay() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+0.8A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,string>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: ldobj valuetype TestModule/MyStructOption`1 + IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_001a: ret + } + + .method public strict virtual instance string + ToString() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldstr "%+A" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,string>,class [FSharp.Core]Microsoft.FSharp.Core.Unit,string,string,valuetype TestModule/MyStructOption`1>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatToString,string>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: ldarg.0 + IL_0010: ldobj valuetype TestModule/MyStructOption`1 + IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,string>::Invoke(!0) + IL_001a: ret + } + + .property instance int32 Tag() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance int32 TestModule/MyStructOption`1::get_Tag() + } + .property valuetype TestModule/MyStructOption`1 + MyStructNone() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get valuetype TestModule/MyStructOption`1 TestModule/MyStructOption`1::get_MyStructNone() + } + .property instance bool IsMyStructNone() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool TestModule/MyStructOption`1::get_IsMyStructNone() + } + .property instance bool IsMyStructSome() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .get instance bool TestModule/MyStructOption`1::get_IsMyStructSome() + } + .property instance !T notNullField1() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance !T TestModule/MyStructOption`1::get_notNullField1() + } + .property instance string notNullField2() + { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string TestModule/MyStructOption`1::get_notNullField2() + } + } + + .method public static class TestModule/MyNullableOption`1 + mapPossiblyNullable(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + class TestModule/MyNullableOption`1 myOpt) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .param type a + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param type b + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 4 + .locals init (class TestModule/MyNullableOption`1 V_0, + class TestModule/MyNullableOption`1 V_1, + !!a V_2) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: brfalse.s IL_0007 + + IL_0005: br.s IL_0009 + + IL_0007: ldnull + IL_0008: ret + + IL_0009: ldloc.0 + IL_000a: stloc.1 + IL_000b: ldloc.1 + IL_000c: ldfld !0 class TestModule/MyNullableOption`1::_value + IL_0011: stloc.2 + IL_0012: ldarg.0 + IL_0013: ldloc.2 + IL_0014: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0019: call class TestModule/MyNullableOption`1 class TestModule/MyNullableOption`1::NewMySome(!0) + IL_001e: ret + } + + .method public static class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 + mapNotNullableContents(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 myOpt) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .param type a + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type b + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + + .maxstack 4 + .locals init (class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 V_0, + class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 V_1, + !!a V_2) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: brfalse.s IL_0007 + + IL_0005: br.s IL_0009 + + IL_0007: ldnull + IL_0008: ret + + IL_0009: ldloc.0 + IL_000a: stloc.1 + IL_000b: ldloc.1 + IL_000c: ldfld !0 class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::_value + IL_0011: stloc.2 + IL_0012: ldarg.0 + IL_0013: ldloc.2 + IL_0014: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0019: call class TestModule/MyOptionWhichCannotHaveNullInTheInside`1 class TestModule/MyOptionWhichCannotHaveNullInTheInside`1::NewMyNotNullSome(!0) + IL_001e: ret + } + + .method public static valuetype TestModule/MyStructOption`1 + mapStructContents(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + valuetype TestModule/MyStructOption`1 myOpt) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + .param type a + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param type b + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 01 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .param [2] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + + .maxstack 4 + .locals init (valuetype TestModule/MyStructOption`1 V_0, + !!a V_1, + string V_2) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call instance int32 valuetype TestModule/MyStructOption`1::get_Tag() + IL_0009: ldc.i4.1 + IL_000a: bne.un.s IL_000e + + IL_000c: br.s IL_0014 + + IL_000e: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::get_MyStructNone() + IL_0013: ret + + IL_0014: ldloca.s V_0 + IL_0016: ldfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_001b: stloc.1 + IL_001c: ldloca.s V_0 + IL_001e: ldfld string valuetype TestModule/MyStructOption`1::_notNullField2 + IL_0023: stloc.2 + IL_0024: ldarg.0 + IL_0025: ldloc.1 + IL_0026: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_002b: ldloc.2 + IL_002c: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(!0, + string) + IL_0031: ret + } + +} + +.class private abstract auto ansi sealed ''.$TestModule + extends [runtime]System.Object +{ +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute + extends [runtime]System.Attribute +{ + .field public class [runtime]System.Array NullableFlags + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret + } + + .method public specialname rtspecialname + instance void .ctor(uint8 scalarByteValue) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret + } + +} + +.class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableContextAttribute + extends [runtime]System.Attribute +{ + .field public uint8 Flag + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(uint8 Flag) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint8 System.Runtime.CompilerServices.NullableContextAttribute::Flag + IL_000d: ret + } + +} + + + + + + From 93f0f2ab97827c9cff83beac4d206d1cb671434f Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 21 Sep 2023 16:38:41 +0200 Subject: [PATCH 25/33] MemberNotNullWhenAttribute applied when codegening struct DUs with fields --- src/Compiler/AbstractIL/il.fs | 5 +- src/Compiler/AbstractIL/il.fsi | 1 + src/Compiler/CodeGen/EraseUnions.fs | 74 +++++-- src/Compiler/CodeGen/IlxGenSupport.fs | 15 ++ src/Compiler/CodeGen/IlxGenSupport.fsi | 1 + src/Compiler/TypedTree/TcGlobals.fs | 4 +- .../EmittedIL/Nullness/NullAsTrueValue.fs | 4 +- .../Nullness/NullAsTrueValue.fs.il.net472.bsl | 186 ++++++++++++++++-- .../NullAsTrueValue.fs.il.netcore.bsl | 119 +++++++++-- .../Nullness/StructDU.fs.il.net472.bsl | 79 +++++++- .../Nullness/StructDU.fs.il.netcore.bsl | 12 +- 11 files changed, 449 insertions(+), 51 deletions(-) diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 409a6f5a057..18178d4ae54 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -3413,6 +3413,7 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly let mkSysILTypeRef nm = mkILTyRef (primaryScopeRef, nm) let byteIlType = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_Byte)) + let stringIlType = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_String)) member _.primaryAssemblyScopeRef = primaryScopeRef @@ -3431,7 +3432,7 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly member val typ_Object = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_Object)) - member val typ_String = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_String)) + member val typ_String = stringIlType member val typ_Array = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_Array)) @@ -3449,6 +3450,8 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly member val typ_ByteArray = mkILBoxedType (mkILTySpec (mkSysILTypeRef tname_Array, [ byteIlType ])) + member val typ_StringArray = mkILBoxedType (mkILTySpec (mkSysILTypeRef tname_Array, [ stringIlType ])) + member val typ_UInt16 = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_UInt16)) member val typ_UInt32 = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_UInt32)) diff --git a/src/Compiler/AbstractIL/il.fsi b/src/Compiler/AbstractIL/il.fsi index 1861e9e2d57..8ae8704265c 100644 --- a/src/Compiler/AbstractIL/il.fsi +++ b/src/Compiler/AbstractIL/il.fsi @@ -1876,6 +1876,7 @@ type internal ILGlobals = member typ_Enum: ILType member typ_Object: ILType member typ_String: ILType + member typ_StringArray : ILType member typ_Type: ILType member typ_Array: ILType member typ_IntPtr: ILType diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 7146bb9bb71..db110e82a45 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -816,8 +816,34 @@ let convAlternativeDef elif repr.RepresentOneAlternativeAsNull info then [], [] else + let additionalAttributes = + if + g.checkNullness + && g.langFeatureNullness + && repr.RepresentAlternativeAsStructValue info + && not alt.IsNullary + then + let notnullfields = + alt.FieldDefs + // Fields that are nullable even from F# perspective has an [Nullable] attribute on them + // Non-nullable fields are implicit in F#, therefore not annotated separately + |> Array.filter (fun f -> TryFindILAttribute g.attrib_NullableAttribute f.ILField.CustomAttrs |> not) + + let fieldNames = + notnullfields + |> Array.map (fun f -> f.LowerName) + |> Array.append (notnullfields |> Array.map (fun f -> f.Name)) + + if fieldNames |> Array.isEmpty then + emptyILCustomAttrs + else + mkILCustomAttrsFromArray [| GetNotNullWhenTrueAttribute g fieldNames |] + + else + emptyILCustomAttrs + [ - mkILNonGenericInstanceMethod ( + (mkILNonGenericInstanceMethod ( "get_" + mkTesterName altName, cud.HelpersAccessibility, [], @@ -830,7 +856,7 @@ let convAlternativeDef attr, imports ) - ) + )).With(customAttrs = additionalAttributes) |> addMethodGeneratedAttrs ], [ @@ -853,7 +879,7 @@ let convAlternativeDef propertyType = g.ilg.typ_Bool, init = None, args = [], - customAttrs = emptyILCustomAttrs + customAttrs = additionalAttributes ) |> addPropertyGeneratedAttrs |> addPropertyNeverAttrs @@ -862,9 +888,13 @@ let convAlternativeDef let baseMakerMeths, baseMakerProps = if alt.IsNullary then - let attributes = - if g.checkNullness && g.langFeatureNullness && repr.RepresentAlternativeAsNull(info,alt) then - GetNullableAttribute g [FSharp.Compiler.TypedTree.NullnessInfo.WithNull] + let attributes = + if + g.checkNullness + && g.langFeatureNullness + && repr.RepresentAlternativeAsNull(info, alt) + then + GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.WithNull ] |> Array.singleton |> mkILCustomAttrsFromArray else @@ -1297,11 +1327,7 @@ let mkClassUnionDef ] let fieldDefs = - // Since structs are flattened out for all cases together, all non-struct field are potentially nullable - // TODO nullness - // Invent C#-friendly access pattern that will work with nullability, e.g. bool this.TryGetCaseXXXData([NotNullWhen(true)]out field1,[NotNullWhen(true)]out field2) - // TODO nullness - // In case of type being a generic instantiation (e.g. | A of (list)), we can at least mark the generic arguments as being not null + // Since structs are flattened out for all cases together, all boxed fields are potentially nullable if isStruct && cud.UnionCases.Length > 1 @@ -1314,12 +1340,26 @@ let mkClassUnionDef field else let attrs = - field.ILField.CustomAttrs.AsArray() - |> Array.filter (IsILAttrib g.attrib_NullableAttribute >> not) - |> Array.append - [| - GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.AmbivalentToNull ] - |] + let existingAttrs = field.ILField.CustomAttrs.AsArray() + let nullableIdx = existingAttrs |> Array.tryFindIndex(IsILAttrib g.attrib_NullableAttribute) + match nullableIdx with + | None -> existingAttrs |> Array.append [|GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.AmbivalentToNull ]|] + | Some idx -> + let replacementAttr = + match existingAttrs[idx] with + (* + The attribute carries either a single byte, or a list of bytes for the fields itself and all its generic type arguments + The way we lay out DUs does not affect nullability of the typars of a field, therefore we just change the very first byte + If the field was already declared as nullable (value = 2uy) or ambivalent(value = 1uy), we can keep it that way + If it was marked as non-nullable within that UnionCase, we have to convert it to ambivalent due to other cases being possible + *) + | Encoded(method,_data,[ILAttribElem.Byte 1uy]) -> + mkILCustomAttribMethRef(method,[ILAttribElem.Byte 0uy],[]) + | Encoded(method,_data,[ILAttribElem.Array (elemType,(ILAttribElem.Byte 1uy) :: otherElems)]) -> + mkILCustomAttribMethRef(method,[ILAttribElem.Array (elemType,(ILAttribElem.Byte 0uy) :: otherElems)],[]) + | attrAsBefore -> attrAsBefore + + existingAttrs |> Array.replace idx replacementAttr field.ILField.With(customAttrs = mkILCustomAttrsFromArray attrs) |> IlxUnionCaseField) diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index 63be4542828..a9abb017b99 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -329,6 +329,20 @@ let GetNullableContextAttribute (g: TcGlobals) = mkILCustomAttribute (tref, [ g.ilg.typ_Byte ], [ ILAttribElem.Byte 1uy ], []) +let GetNotNullWhenTrueAttribute (g: TcGlobals) (propNames: string array) = + let tref = g.attrib_MemberNotNullWhenAttribute.TypeRef + + g.TryEmbedILType( + tref, + (fun () -> + let fields = Some [ "ReturnValue", g.ilg.typ_Bool ; "Members", g.ilg.typ_StringArray ] + mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, fields, EncapsulatedProperties)) + ) + + let stringArgs = propNames |> Array.map (Some >> ILAttribElem.String) |> List.ofArray + + mkILCustomAttribute (tref, [ g.ilg.typ_Bool; g.ilg.typ_StringArray ], [ ILAttribElem.Bool true; ILAttribElem.Array(g.ilg.typ_String, stringArgs)], []) + let GetNullableAttribute (g: TcGlobals) (nullnessInfos: TypedTree.NullnessInfo list) = let tref = g.attrib_NullableAttribute.TypeRef @@ -443,6 +457,7 @@ let GenNullnessIfNecessary (g: TcGlobals) ty = else None + let GenAdditionalAttributesForTy g ty = let readOnly = GenReadOnlyIfNecessary g ty |> Option.toList let nullable = GenNullnessIfNecessary g ty |> Option.toList diff --git a/src/Compiler/CodeGen/IlxGenSupport.fsi b/src/Compiler/CodeGen/IlxGenSupport.fsi index 36493718a91..6bd3723e886 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fsi +++ b/src/Compiler/CodeGen/IlxGenSupport.fsi @@ -24,3 +24,4 @@ val GetReadOnlyAttribute: g: TcGlobals -> ILAttribute val GetIsUnmanagedAttribute: g: TcGlobals -> ILAttribute val GetNullableAttribute: g: TcGlobals -> nullnessInfos: TypedTree.NullnessInfo list -> ILAttribute val GetNullableContextAttribute: g: TcGlobals -> ILAttribute +val GetNotNullWhenTrueAttribute: g: TcGlobals -> string array -> ILAttribute diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index d5b6eece644..9b09c35053b 100755 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -349,6 +349,7 @@ type TcGlobals( | "System.Runtime.CompilerServices.IsUnmanagedAttribute" | "System.Runtime.CompilerServices.NullableAttribute" | "System.Runtime.CompilerServices.NullableContextAttribute" + | "System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute" | "System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute" | "System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes" -> true | _ -> false @@ -1451,7 +1452,8 @@ type TcGlobals( member val attrib_IsUnmanagedAttribute = findOrEmbedSysPublicType "System.Runtime.CompilerServices.IsUnmanagedAttribute" member val attrib_DynamicDependencyAttribute = findOrEmbedSysPublicType "System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute" member val attrib_NullableAttribute = findOrEmbedSysPublicType "System.Runtime.CompilerServices.NullableAttribute" - member val attrib_NullableContextAttribute = findOrEmbedSysPublicType "System.Runtime.CompilerServices.NullableContextAttribute" + member val attrib_NullableContextAttribute = findOrEmbedSysPublicType "System.Runtime.CompilerServices.NullableContextAttribute" + member val attrib_MemberNotNullWhenAttribute = findOrEmbedSysPublicType "System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute" member val enum_DynamicallyAccessedMemberTypes = findOrEmbedSysPublicType "System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes" member val attrib_SystemObsolete = findSysAttrib "System.ObsoleteAttribute" diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs index d8d90423ccf..f6038521066 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs @@ -25,9 +25,9 @@ let mapNotNullableContents f myOpt = [] type MyStructOption<'T when 'T: not null> = | MyStructNone - | MyStructSome of notNullField1 : 'T * notNullField2 : string + | MyStructSome of nestedGenericField : list> * notNullField2 : string * canBeNullField : (string | null) * notNullField1 : 'T let mapStructContents f myOpt = match myOpt with | MyStructNone -> MyStructNone - | MyStructSome(x,s) -> MyStructSome (f x,s) \ No newline at end of file + | MyStructSome(ngf,s,ns,x) -> MyStructSome (ngf,s,ns,f x) \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl index 9614f241201..d13a78587ea 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl @@ -384,6 +384,14 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly string _canBeNullField + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .field assembly int32 _tag .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -416,12 +424,18 @@ .method public static valuetype TestModule/MyStructOption`1 NewMyStructSome(!T _notNullField1, - string _notNullField2) cil managed + string _notNullField2, + string _canBeNullField, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + .param [3] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [4] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) - .maxstack 3 + .maxstack 5 .locals init (valuetype TestModule/MyStructOption`1 V_0) IL_0000: ldloca.s V_0 IL_0002: initobj valuetype TestModule/MyStructOption`1 @@ -434,13 +448,25 @@ IL_0018: ldloca.s V_0 IL_001a: ldarg.1 IL_001b: stfld string valuetype TestModule/MyStructOption`1::_notNullField2 - IL_0020: ldloc.0 - IL_0021: ret + IL_0020: ldloca.s V_0 + IL_0022: ldarg.2 + IL_0023: stfld string valuetype TestModule/MyStructOption`1::_canBeNullField + IL_0028: ldloca.s V_0 + IL_002a: ldarg.3 + IL_002b: stfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_0030: ldloc.0 + IL_0031: ret } .method public hidebysig instance bool get_IsMyStructSome() cil managed { + .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, + class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 + 69 65 6C 64 31 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 32 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -497,6 +523,34 @@ IL_0006: ret } + .method public hidebysig instance string + get_canBeNullField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string valuetype TestModule/MyStructOption`1::_canBeNullField + IL_0006: ret + } + + .method public hidebysig instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + get_nestedGenericField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_0006: ret + } + .method public hidebysig instance int32 get_Tag() cil managed { @@ -564,6 +618,12 @@ } .property instance bool IsMyStructSome() { + .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, + class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 + 69 65 6C 64 31 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 32 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) @@ -589,6 +649,27 @@ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string TestModule/MyStructOption`1::get_notNullField2() } + .property instance string canBeNullField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 02 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string TestModule/MyStructOption`1::get_canBeNullField() + } + .property instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + nestedGenericField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 03 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() + } } .method public static class TestModule/MyNullableOption`1 @@ -677,10 +758,12 @@ .param [2] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) - .maxstack 4 + .maxstack 6 .locals init (valuetype TestModule/MyStructOption`1 V_0, !!a V_1, - string V_2) + string V_2, + string V_3, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> V_4) IL_0000: ldarg.1 IL_0001: stloc.0 IL_0002: ldloca.s V_0 @@ -699,13 +782,23 @@ IL_001c: ldloca.s V_0 IL_001e: ldfld string valuetype TestModule/MyStructOption`1::_notNullField2 IL_0023: stloc.2 - IL_0024: ldarg.0 - IL_0025: ldloc.1 - IL_0026: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) - IL_002b: ldloc.2 - IL_002c: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(!0, - string) - IL_0031: ret + IL_0024: ldloca.s V_0 + IL_0026: ldfld string valuetype TestModule/MyStructOption`1::_canBeNullField + IL_002b: stloc.3 + IL_002c: ldloca.s V_0 + IL_002e: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_0033: stloc.s V_4 + IL_0035: ldarg.0 + IL_0036: ldloc.1 + IL_0037: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_003c: ldloc.2 + IL_003d: ldloc.3 + IL_003e: ldloc.s V_4 + IL_0040: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(!0, + string, + string, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1>) + IL_0045: ret } } @@ -808,6 +901,73 @@ } } +.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute + extends [runtime]System.Attribute +{ + .field private bool ReturnValue@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [runtime]System.Array Members@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(bool ReturnValue, + class [runtime]System.Array Members) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::ReturnValue@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ + IL_0014: ret + } + + .method public hidebysig specialname instance class [runtime]System.Array + get_Members() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ + IL_0006: ret + } + + .method public hidebysig specialname instance bool + get_ReturnValue() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::ReturnValue@ + IL_0006: ret + } + + .property instance bool ReturnValue() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_ReturnValue() + } + .property instance class [runtime]System.Array + Members() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_Members() + } +} + .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl index a6adfcf985f..7e7a9c69148 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl @@ -384,6 +384,14 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly string _canBeNullField + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field assembly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .field assembly int32 _tag .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -416,12 +424,18 @@ .method public static valuetype TestModule/MyStructOption`1 NewMyStructSome(!T _notNullField1, - string _notNullField2) cil managed + string _notNullField2, + string _canBeNullField, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + .param [3] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .param [4] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) - .maxstack 3 + .maxstack 5 .locals init (valuetype TestModule/MyStructOption`1 V_0) IL_0000: ldloca.s V_0 IL_0002: initobj valuetype TestModule/MyStructOption`1 @@ -434,13 +448,25 @@ IL_0018: ldloca.s V_0 IL_001a: ldarg.1 IL_001b: stfld string valuetype TestModule/MyStructOption`1::_notNullField2 - IL_0020: ldloc.0 - IL_0021: ret + IL_0020: ldloca.s V_0 + IL_0022: ldarg.2 + IL_0023: stfld string valuetype TestModule/MyStructOption`1::_canBeNullField + IL_0028: ldloca.s V_0 + IL_002a: ldarg.3 + IL_002b: stfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_0030: ldloc.0 + IL_0031: ret } .method public hidebysig instance bool get_IsMyStructSome() cil managed { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, + class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 + 69 65 6C 64 31 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 32 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -497,6 +523,34 @@ IL_0006: ret } + .method public hidebysig instance string + get_canBeNullField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string valuetype TestModule/MyStructOption`1::_canBeNullField + IL_0006: ret + } + + .method public hidebysig instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + get_nestedGenericField() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .param [0] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_0006: ret + } + .method public hidebysig instance int32 get_Tag() cil managed { @@ -564,6 +618,12 @@ } .property instance bool IsMyStructSome() { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, + class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 + 69 65 6C 64 31 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 32 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) @@ -589,6 +649,27 @@ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string TestModule/MyStructOption`1::get_notNullField2() } + .property instance string canBeNullField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 02 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance string TestModule/MyStructOption`1::get_canBeNullField() + } + .property instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + nestedGenericField() + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, + int32, + int32) = ( 01 00 04 00 00 00 01 00 00 00 03 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() + } } .method public static class TestModule/MyNullableOption`1 @@ -677,10 +758,12 @@ .param [2] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) - .maxstack 4 + .maxstack 6 .locals init (valuetype TestModule/MyStructOption`1 V_0, !!a V_1, - string V_2) + string V_2, + string V_3, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> V_4) IL_0000: ldarg.1 IL_0001: stloc.0 IL_0002: ldloca.s V_0 @@ -699,13 +782,23 @@ IL_001c: ldloca.s V_0 IL_001e: ldfld string valuetype TestModule/MyStructOption`1::_notNullField2 IL_0023: stloc.2 - IL_0024: ldarg.0 - IL_0025: ldloc.1 - IL_0026: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) - IL_002b: ldloc.2 - IL_002c: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(!0, - string) - IL_0031: ret + IL_0024: ldloca.s V_0 + IL_0026: ldfld string valuetype TestModule/MyStructOption`1::_canBeNullField + IL_002b: stloc.3 + IL_002c: ldloca.s V_0 + IL_002e: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_0033: stloc.s V_4 + IL_0035: ldarg.0 + IL_0036: ldloc.1 + IL_0037: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_003c: ldloc.2 + IL_003d: ldloc.3 + IL_003e: ldloc.s V_4 + IL_0040: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(!0, + string, + string, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1>) + IL_0045: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl index 3fc8df226c7..147b0b95e2e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl @@ -106,6 +106,10 @@ .method public hidebysig instance bool get_IsB() cil managed { + .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, + class [runtime]System.Array) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 + 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 + 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -189,7 +193,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -264,6 +268,10 @@ } .property instance bool IsB() { + .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, + class [runtime]System.Array) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 + 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 + 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) @@ -288,10 +296,10 @@ } .property instance string nullableString() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/Myassembly::get_nullableString() @@ -427,6 +435,73 @@ } } +.class private auto ansi beforefieldinit System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute + extends [runtime]System.Attribute +{ + .field private bool ReturnValue@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field private class [runtime]System.Array Members@ + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method public specialname rtspecialname + instance void .ctor(bool ReturnValue, + class [runtime]System.Array Members) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [runtime]System.Attribute::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::ReturnValue@ + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ + IL_0014: ret + } + + .method public hidebysig specialname instance class [runtime]System.Array + get_Members() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ + IL_0006: ret + } + + .method public hidebysig specialname instance bool + get_ReturnValue() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::ReturnValue@ + IL_0006: ret + } + + .property instance bool ReturnValue() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_ReturnValue() + } + .property instance class [runtime]System.Array + Members() + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .get instance class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_Members() + } +} + .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl index 8c26a601665..4ffb61997c5 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl @@ -106,6 +106,10 @@ .method public hidebysig instance bool get_IsB() cil managed { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, + class [runtime]System.Array) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 + 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 + 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -189,7 +193,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -264,6 +268,10 @@ } .property instance bool IsB() { + .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, + class [runtime]System.Array) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 + 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 + 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) @@ -288,10 +296,10 @@ } .property instance string nullableString() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 02 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string MyTestModule/Myassembly::get_nullableString() From 1bd5813fe8dc8907d6a0b179dd4511c310f5dade Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 21 Sep 2023 16:48:44 +0200 Subject: [PATCH 26/33] il baseline fixed --- .../Nullness/NullAsTrueValue.fs.il.net472.bsl | 80 +++++++++---------- .../NullAsTrueValue.fs.il.netcore.bsl | 80 +++++++++---------- 2 files changed, 80 insertions(+), 80 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl index d13a78587ea..7e3f3d3f0b3 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl @@ -376,7 +376,7 @@ .field public static literal int32 MyStructSome = int32(0x00000001) } - .field assembly !T _notNullField1 + .field assembly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -388,7 +388,7 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .field assembly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField + .field assembly !T _notNullField1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -423,17 +423,17 @@ } .method public static valuetype TestModule/MyStructOption`1 - NewMyStructSome(!T _notNullField1, + NewMyStructSome(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField, string _notNullField2, string _canBeNullField, - class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField) cil managed + !T _notNullField1) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) .param [3] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - .param [4] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) .maxstack 5 .locals init (valuetype TestModule/MyStructOption`1 V_0) @@ -444,7 +444,7 @@ IL_000b: stfld int32 valuetype TestModule/MyStructOption`1::_tag IL_0010: ldloca.s V_0 IL_0012: ldarg.0 - IL_0013: stfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_0013: stfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField IL_0018: ldloca.s V_0 IL_001a: ldarg.1 IL_001b: stfld string valuetype TestModule/MyStructOption`1::_notNullField2 @@ -453,7 +453,7 @@ IL_0023: stfld string valuetype TestModule/MyStructOption`1::_canBeNullField IL_0028: ldloca.s V_0 IL_002a: ldarg.3 - IL_002b: stfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_002b: stfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 IL_0030: ldloc.0 IL_0031: ret } @@ -463,10 +463,10 @@ { .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 - 69 65 6C 64 31 0D 6E 6F 74 4E 75 6C 6C 46 69 65 - 6C 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C - 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 - 32 00 00 ) + 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 31 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -495,17 +495,17 @@ IL_0007: ret } - .method public hidebysig instance !T - get_notNullField1() cil managed + .method public hidebysig instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + get_nestedGenericField() cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField IL_0006: ret } @@ -537,17 +537,17 @@ IL_0006: ret } - .method public hidebysig instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> - get_nestedGenericField() cil managed + .method public hidebysig instance !T + get_notNullField1() cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_0001: ldfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 IL_0006: ret } @@ -620,24 +620,25 @@ { .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 - 69 65 6C 64 31 0D 6E 6F 74 4E 75 6C 6C 46 69 65 - 6C 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C - 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 - 32 00 00 ) + 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 31 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .get instance bool TestModule/MyStructOption`1::get_IsMyStructSome() } - .property instance !T notNullField1() + .property instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + nestedGenericField() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance !T TestModule/MyStructOption`1::get_notNullField1() + .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() } .property instance string notNullField2() { @@ -659,16 +660,15 @@ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string TestModule/MyStructOption`1::get_canBeNullField() } - .property instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> - nestedGenericField() + .property instance !T notNullField1() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 03 00 00 00 00 00 ) - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() + .get instance !T TestModule/MyStructOption`1::get_notNullField1() } } @@ -758,7 +758,7 @@ .param [2] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) - .maxstack 6 + .maxstack 7 .locals init (valuetype TestModule/MyStructOption`1 V_0, !!a V_1, string V_2, @@ -788,16 +788,16 @@ IL_002c: ldloca.s V_0 IL_002e: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField IL_0033: stloc.s V_4 - IL_0035: ldarg.0 - IL_0036: ldloc.1 - IL_0037: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) - IL_003c: ldloc.2 - IL_003d: ldloc.3 - IL_003e: ldloc.s V_4 - IL_0040: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(!0, + IL_0035: ldloc.s V_4 + IL_0037: ldloc.2 + IL_0038: ldloc.3 + IL_0039: ldarg.0 + IL_003a: ldloc.1 + IL_003b: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0040: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1>, string, string, - class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1>) + !0) IL_0045: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl index 7e7a9c69148..3fe2b3e2052 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl @@ -376,7 +376,7 @@ .field public static literal int32 MyStructSome = int32(0x00000001) } - .field assembly !T _notNullField1 + .field assembly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -388,7 +388,7 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .field assembly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField + .field assembly !T _notNullField1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -423,17 +423,17 @@ } .method public static valuetype TestModule/MyStructOption`1 - NewMyStructSome(!T _notNullField1, + NewMyStructSome(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField, string _notNullField2, string _canBeNullField, - class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> _nestedGenericField) cil managed + !T _notNullField1) cil managed { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) + .param [1] + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) .param [3] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) - .param [4] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) .maxstack 5 .locals init (valuetype TestModule/MyStructOption`1 V_0) @@ -444,7 +444,7 @@ IL_000b: stfld int32 valuetype TestModule/MyStructOption`1::_tag IL_0010: ldloca.s V_0 IL_0012: ldarg.0 - IL_0013: stfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_0013: stfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField IL_0018: ldloca.s V_0 IL_001a: ldarg.1 IL_001b: stfld string valuetype TestModule/MyStructOption`1::_notNullField2 @@ -453,7 +453,7 @@ IL_0023: stfld string valuetype TestModule/MyStructOption`1::_canBeNullField IL_0028: ldloca.s V_0 IL_002a: ldarg.3 - IL_002b: stfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_002b: stfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 IL_0030: ldloc.0 IL_0031: ret } @@ -463,10 +463,10 @@ { .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 - 69 65 6C 64 31 0D 6E 6F 74 4E 75 6C 6C 46 69 65 - 6C 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C - 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 - 32 00 00 ) + 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 31 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -495,17 +495,17 @@ IL_0007: ret } - .method public hidebysig instance !T - get_notNullField1() cil managed + .method public hidebysig instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + get_nestedGenericField() cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField IL_0006: ret } @@ -537,17 +537,17 @@ IL_0006: ret } - .method public hidebysig instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> - get_nestedGenericField() cil managed + .method public hidebysig instance !T + get_notNullField1() cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField + IL_0001: ldfld !0 valuetype TestModule/MyStructOption`1::_notNullField1 IL_0006: ret } @@ -620,24 +620,25 @@ { .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 - 69 65 6C 64 31 0D 6E 6F 74 4E 75 6C 6C 46 69 65 - 6C 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C - 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 - 32 00 00 ) + 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 31 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .get instance bool TestModule/MyStructOption`1::get_IsMyStructSome() } - .property instance !T notNullField1() + .property instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> + nestedGenericField() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance !T TestModule/MyStructOption`1::get_notNullField1() + .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() } .property instance string notNullField2() { @@ -659,16 +660,15 @@ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance string TestModule/MyStructOption`1::get_canBeNullField() } - .property instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> - nestedGenericField() + .property instance !T notNullField1() { + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 03 00 00 00 00 00 ) - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() + .get instance !T TestModule/MyStructOption`1::get_notNullField1() } } @@ -758,7 +758,7 @@ .param [2] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) - .maxstack 6 + .maxstack 7 .locals init (valuetype TestModule/MyStructOption`1 V_0, !!a V_1, string V_2, @@ -788,16 +788,16 @@ IL_002c: ldloca.s V_0 IL_002e: ldfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> valuetype TestModule/MyStructOption`1::_nestedGenericField IL_0033: stloc.s V_4 - IL_0035: ldarg.0 - IL_0036: ldloc.1 - IL_0037: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) - IL_003c: ldloc.2 - IL_003d: ldloc.3 - IL_003e: ldloc.s V_4 - IL_0040: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(!0, + IL_0035: ldloc.s V_4 + IL_0037: ldloc.2 + IL_0038: ldloc.3 + IL_0039: ldarg.0 + IL_003a: ldloc.1 + IL_003b: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0040: call valuetype TestModule/MyStructOption`1 valuetype TestModule/MyStructOption`1::NewMyStructSome(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1>, string, string, - class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1>) + !0) IL_0045: ret } From 23ee4abefcc6fe9f1c6111ad45682f9ffe3cd062 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 21 Sep 2023 16:50:04 +0200 Subject: [PATCH 27/33] fantomas --- src/Compiler/AbstractIL/il.fs | 4 +++- src/Compiler/AbstractIL/il.fsi | 2 +- src/Compiler/CodeGen/EraseUnions.fs | 37 ++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 18178d4ae54..fbe612d22b8 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -3413,7 +3413,9 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly let mkSysILTypeRef nm = mkILTyRef (primaryScopeRef, nm) let byteIlType = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_Byte)) - let stringIlType = mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_String)) + + let stringIlType = + mkILBoxedType (mkILNonGenericTySpec (mkSysILTypeRef tname_String)) member _.primaryAssemblyScopeRef = primaryScopeRef diff --git a/src/Compiler/AbstractIL/il.fsi b/src/Compiler/AbstractIL/il.fsi index 8ae8704265c..b5cf43d628c 100644 --- a/src/Compiler/AbstractIL/il.fsi +++ b/src/Compiler/AbstractIL/il.fsi @@ -1876,7 +1876,7 @@ type internal ILGlobals = member typ_Enum: ILType member typ_Object: ILType member typ_String: ILType - member typ_StringArray : ILType + member typ_StringArray: ILType member typ_Type: ILType member typ_Array: ILType member typ_IntPtr: ILType diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index db110e82a45..633f73a0d56 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -823,13 +823,13 @@ let convAlternativeDef && repr.RepresentAlternativeAsStructValue info && not alt.IsNullary then - let notnullfields = + let notnullfields = alt.FieldDefs // Fields that are nullable even from F# perspective has an [Nullable] attribute on them // Non-nullable fields are implicit in F#, therefore not annotated separately |> Array.filter (fun f -> TryFindILAttribute g.attrib_NullableAttribute f.ILField.CustomAttrs |> not) - let fieldNames = + let fieldNames = notnullfields |> Array.map (fun f -> f.LowerName) |> Array.append (notnullfields |> Array.map (fun f -> f.Name)) @@ -838,7 +838,7 @@ let convAlternativeDef emptyILCustomAttrs else mkILCustomAttrsFromArray [| GetNotNullWhenTrueAttribute g fieldNames |] - + else emptyILCustomAttrs @@ -856,7 +856,8 @@ let convAlternativeDef attr, imports ) - )).With(customAttrs = additionalAttributes) + )) + .With(customAttrs = additionalAttributes) |> addMethodGeneratedAttrs ], [ @@ -1341,11 +1342,19 @@ let mkClassUnionDef else let attrs = let existingAttrs = field.ILField.CustomAttrs.AsArray() - let nullableIdx = existingAttrs |> Array.tryFindIndex(IsILAttrib g.attrib_NullableAttribute) + + let nullableIdx = + existingAttrs |> Array.tryFindIndex (IsILAttrib g.attrib_NullableAttribute) + match nullableIdx with - | None -> existingAttrs |> Array.append [|GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.AmbivalentToNull ]|] + | None -> + existingAttrs + |> Array.append + [| + GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.AmbivalentToNull ] + |] | Some idx -> - let replacementAttr = + let replacementAttr = match existingAttrs[idx] with (* The attribute carries either a single byte, or a list of bytes for the fields itself and all its generic type arguments @@ -1353,10 +1362,16 @@ let mkClassUnionDef If the field was already declared as nullable (value = 2uy) or ambivalent(value = 1uy), we can keep it that way If it was marked as non-nullable within that UnionCase, we have to convert it to ambivalent due to other cases being possible *) - | Encoded(method,_data,[ILAttribElem.Byte 1uy]) -> - mkILCustomAttribMethRef(method,[ILAttribElem.Byte 0uy],[]) - | Encoded(method,_data,[ILAttribElem.Array (elemType,(ILAttribElem.Byte 1uy) :: otherElems)]) -> - mkILCustomAttribMethRef(method,[ILAttribElem.Array (elemType,(ILAttribElem.Byte 0uy) :: otherElems)],[]) + | Encoded (method, _data, [ ILAttribElem.Byte 1uy ]) -> + mkILCustomAttribMethRef (method, [ ILAttribElem.Byte 0uy ], []) + | Encoded (method, + _data, + [ ILAttribElem.Array (elemType, (ILAttribElem.Byte 1uy) :: otherElems) ]) -> + mkILCustomAttribMethRef ( + method, + [ ILAttribElem.Array(elemType, (ILAttribElem.Byte 0uy) :: otherElems) ], + [] + ) | attrAsBefore -> attrAsBefore existingAttrs |> Array.replace idx replacementAttr From 1fbc35f6ae1a0d488e7a4d1aa74507d76a496b60 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Thu, 21 Sep 2023 16:50:15 +0200 Subject: [PATCH 28/33] fantomas --- src/Compiler/CodeGen/IlxGenSupport.fs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index a9abb017b99..b4856c0e0d4 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -335,13 +335,21 @@ let GetNotNullWhenTrueAttribute (g: TcGlobals) (propNames: string array) = g.TryEmbedILType( tref, (fun () -> - let fields = Some [ "ReturnValue", g.ilg.typ_Bool ; "Members", g.ilg.typ_StringArray ] + let fields = + Some [ "ReturnValue", g.ilg.typ_Bool; "Members", g.ilg.typ_StringArray ] + mkLocalPrivateAttributeWithPropertyConstructors (g, tref.Name, fields, EncapsulatedProperties)) ) - let stringArgs = propNames |> Array.map (Some >> ILAttribElem.String) |> List.ofArray + let stringArgs = + propNames |> Array.map (Some >> ILAttribElem.String) |> List.ofArray - mkILCustomAttribute (tref, [ g.ilg.typ_Bool; g.ilg.typ_StringArray ], [ ILAttribElem.Bool true; ILAttribElem.Array(g.ilg.typ_String, stringArgs)], []) + mkILCustomAttribute ( + tref, + [ g.ilg.typ_Bool; g.ilg.typ_StringArray ], + [ ILAttribElem.Bool true; ILAttribElem.Array(g.ilg.typ_String, stringArgs) ], + [] + ) let GetNullableAttribute (g: TcGlobals) (nullnessInfos: TypedTree.NullnessInfo list) = let tref = g.attrib_NullableAttribute.TypeRef @@ -457,7 +465,6 @@ let GenNullnessIfNecessary (g: TcGlobals) ty = else None - let GenAdditionalAttributesForTy g ty = let readOnly = GenReadOnlyIfNecessary g ty |> Option.toList let nullable = GenNullnessIfNecessary g ty |> Option.toList From 8a2edf932315ded51eb6c7ce40555c51e155c32a Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 29 Sep 2023 12:35:20 +0200 Subject: [PATCH 29/33] add test-signature file to VCS so that we can spot differences in it --- tests/adhoc/nullness/out.fsi | 346 +++++++++++++++++++++++++++++++++++ 1 file changed, 346 insertions(+) create mode 100644 tests/adhoc/nullness/out.fsi diff --git a/tests/adhoc/nullness/out.fsi b/tests/adhoc/nullness/out.fsi new file mode 100644 index 00000000000..10b41edf5ca --- /dev/null +++ b/tests/adhoc/nullness/out.fsi @@ -0,0 +1,346 @@ + +module FSharp.BuildProperties + +val internal fsProductVersion: string + +val internal fsLanguageVersion: string + + + +namespace FSharp + + +module ExistingPositive + +module Extractions0a = + + val x: 'a | null + + val result: bool + +module Extractions0b = + + val x: 'a | null + + val f: x: 'T * y: 'T -> unit + + val result: unit + +module Extractions0d = + + val x: 'a | null + + val f: x: 'T * y: 'T -> unit when 'T: null + + val result: unit + +module Basics = + + val x1: System.String + + val x4: System.String + +module Basics2 = + + val f1: unit -> 'a | null + + val f8: unit -> System.String + +type C = + + new: s: System.String -> C + + member Value: System.String + +module InteropBasics = + + val s0: string + + val s1: System.String + + val test1: unit -> string + + val test2: s1: System.String * s2: System.String -> string + + val test3: unit -> System.String + + val test4: unit -> System.AppDomain + + val test5: System.AppDomain + +val f0: line: string -> unit + +module NullConstraintTests = + + type C<'T when 'T: null> = + + new: unit -> C<'T> + + val f3: y: C -> C + +module DefaultValueTests = + + module StructExamples = + + [] + type C2 = + + [] + val mutable Whoops: System.String + + module ClassExamples = + + type C2 = + + [] + val mutable Whoops: System.String + + +module EnabledPositive + +module Basics = + + val x2: System.String | null + + val x3: System.String | null + +module NotNullConstraint = + + val f3: x: 'T -> int when 'T: not null + + val v1: int + + val v2: int + + val v3: int + + val v4: int + + val v5: int + + val w1: int + + val w2: int + + val w3: int + + val w4: int + + val w5: int + +module MemberBasics = + + type C = + + new: unit -> C + + member M: unit -> int + + member P: int + + val c: C | null + + val v1: int + + val v2: int + + val f1: (unit -> int) + +module Basics2 = + + val f1: unit -> 'a | null + + val f2: unit -> System.String | null + + val f3: unit -> 'T | null when 'T: not null + + val f4: unit -> 'T | null when 'T: not null and 'T: not struct + + val f5: unit -> 'T when 'T: not struct and 'T: null + + val f8: unit -> System.String + +type C = + + new: s: System.String -> C + + member Value: System.String + +val f: x: 'T | null * y: 'T | null -> unit when 'T: not null + +module Extractions0c = + + val x: 'a | null + + val f: x: 'T | null * y: 'T | null -> unit when 'T: not null + + val s: System.String + + val result: unit + +module Extractions0e = + + val x: 'a | null + + val f: x: 'T | null * y: 'T | null -> unit when 'T: not null + + val result: unit + +module Extractions1 = + + val mutable x: string + +module InteropBasics = + + val s0: string + + val s1: System.String + + val test1: unit -> string + + val test2: s1: System.String * s2: System.String -> string + + val test3: unit -> System.String + + val test4: unit -> System.AppDomain + + val test5: System.AppDomain + +[] +type KonsoleWithNulls = + + static member WriteLine: s: System.String -> unit + + static member + WriteLine: fmt: System.String * [] args: obj array -> + unit + + static member WriteLine: fmt: System.String * arg1: System.String -> unit + + static member WriteLineC: s: C -> unit + + static member WriteLineC: fmt: C * arg1: C -> unit + +module KonsoleWithNullsModule = + + val WriteLine: s: System.String | null -> unit + + val WriteLine2: + fmt: System.String | null * arg1: System.String | null -> unit + + val WriteLineC: s: C | null -> unit + + val WriteLineC2: fmt: C | null * arg1: C | null -> unit + +module KonsoleWithNullsModule2 = + + val WriteLine: x: System.String | null -> unit + + val WriteLine2: + fmt: System.String | null * arg1: System.String | null -> unit + + val WriteLineC: s: C | null -> unit + + val WriteLineC2: fmt: C | null * arg1: C | null -> unit + +[] +type KonsoleNoNulls = + + static member WriteLine: s: System.String -> unit + + static member + WriteLine: fmt: System.String * [] args: obj array -> + unit + + static member WriteLine: fmt: System.String * arg1: System.String -> unit + + static member WriteLineC: s: C -> unit + + static member WriteLineC: fmt: C * arg1: C -> unit + +module KonsoleNoNullsModule = + + val WriteLine: s: System.String -> unit + + val WriteLine2: fmt: System.String * arg1: System.String -> unit + + val WriteLineC: s: C -> unit + + val WriteLineC2: fmt: C * arg1: C -> unit + +module KonsoleNoNullsModule2 = + + val WriteLine: x: System.String -> unit + + val WriteLine2: fmt: System.String * arg1: System.String -> unit + + val WriteLineC: s: C -> unit + + val WriteLineC2: fmt: C * arg1: C -> unit + +val f0: line: string -> unit + +module NullConstraintTests = + + type C<'T when 'T: null> = + + new: unit -> C<'T> + + val f3: y: C -> C + + val f4: y: C -> C + + val f5: y: C | null> -> C | null> + + val f6: y: C | null> -> C | null> + +module DefaultValueTests = + + module StructExamples = + + [] + type C2 = + + [] + val mutable Whoops: System.String + + [] + type C3 = + + [] + val mutable Whoops: System.String | null + + [] + type C4b = + + [] + val mutable Whoops: List | null + + [] + type C7 = + + [] + val mutable Whoops: (int -> int | null) + + module ClassExamples = + + type C2 = + + [] + val mutable Whoops: System.String + + type C3 = + + [] + val mutable Whoops: System.String | null + + type C4b = + + [] + val mutable Whoops: List | null + + type C7 = + + [] + val mutable Whoops: (int -> int | null) + From ba4786e8bc56aeb3b4bc1555efce1826a70a4a26 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 29 Sep 2023 17:48:39 +0200 Subject: [PATCH 30/33] Nullness C# (consumer) interop test -> TODOs are inside the .cs test case, THIS IS NOT READY! --- .../EmittedIL/Nullness/CsharpConsumer.cs | 35 +++++++++++++++++++ .../EmittedIL/Nullness/NullnessMetadata.fs | 32 +++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CsharpConsumer.cs diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CsharpConsumer.cs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CsharpConsumer.cs new file mode 100644 index 00000000000..01de577913d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CsharpConsumer.cs @@ -0,0 +1,35 @@ +namespace CsharpNamespace +{ +#nullable enable + public static class CsharpClass + { + public static string MyApiWhichHatesNulls(string x) + { + return x.Length.ToString(); + } + + public static string JustUseAllOfItHere() + { + var thisShouldWarn = MyTestModule.nonNullableInputOutputFunc(null); + var thisIsPossiblyNullAndIsOk = MyTestModule.nullableStringInputOutputFunc(thisShouldWarn); + var thereforeThisShouldWarnAgain = MyTestModule.nonNullableInputOutputFunc(thisIsPossiblyNullAndIsOk); + + string? nullString = null; + + var myStructTuple = (nullString,nullString,1,2,3,4); + var thisShouldBeAWarningForSecondTypar = MyTestModule.genericValueTypeTest(myStructTuple); + // The line below gives a warning, but should not => FIX IT + var thisShouldNotSayAnything = MyTestModule.genericValueTypeTest(("I am not nulll",null,1,2,3,4)); + // The line below should give a warning, but it is missing => FIX IT + var thisShouldWarnFor2ndItem = MyTestModule.nonNullableInputOutputFunc(thisShouldNotSayAnything.Item2); + var thisIsOkBecauseItem1IsNotNullable = MyTestModule.nonNullableInputOutputFunc(thisShouldNotSayAnything.Item1); + + var refTuple = MyTestModule.genericRefTypeTest(nullString,nullString,1,2,3,4); + // The one below should warn for using .Item2 for 1st argument, but it does not => FIX IT + MyTestModule.genericRefTypeTest(refTuple.Item2,refTuple.Item2,1,2,3,4); + + + return MyTestModule.multiArgumentTest(null,null); + } + } +} \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index 4f0fad2f3a9..d50032435af 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -69,3 +69,35 @@ let ``Nullable attr for Option clones`` compilation = compilation |> verifyCompilation DoNotOptimize + +module Interop = + open System.IO + + let FsharpFunctins = + Path.Combine(__SOURCE_DIRECTORY__,"ModuleLevelFunctions.fs") + |> File.ReadAllText + |> FSharp + |> asLibrary + |> withLangVersionPreview + |> withName "MyTestModule" + |> withOptions ["--checknulls"] + + [] + let ``Csharp code can work with annotated FSharp module`` () = + Path.Combine(__SOURCE_DIRECTORY__,"CsharpConsumer.cs") + |> File.ReadAllText + |> CSharp + |> withReferences [FsharpFunctins] + |> withCSharpLanguageVersion CSharpLanguageVersion.Preview + |> asLibrary + |> withName "CsharpAppConsumingNullness" + |> compile + |> shouldFail + |> withDiagnostics [ + Error 29, Line 31, Col 20, Line 31, Col 61, "Cannot implicitly convert type 'int' to 'string'" + Warning 8625, Line 12, Col 74, Line 12, Col 78, "Cannot convert null literal to non-nullable reference type." + Warning 8604, Line 14, Col 88, Line 14, Col 113, "Possible null reference argument for parameter 'x' in 'string MyTestModule.nonNullableInputOutputFunc(string x)'." + Warning 8620, Line 19, Col 88, Line 19, Col 101, "Argument of type '(string?, string?, int, int, int, int)' cannot be used for parameter 'x' of type '(string, string, int, int, int, int)' in '(string, string, int, int, int, int) MyTestModule.genericValueTypeTest((string, string, int, int, int, int) x)' due to differences in the nullability of reference types." + Warning 8620, Line 21, Col 78, Line 21, Col 109, "Argument of type '(string, string?, int, int, int, int)' cannot be used for parameter 'x' of type '(string, string, int, int, int, int)' in '(string, string, int, int, int, int) MyTestModule.genericValueTypeTest((string, string, int, int, int, int) x)' due to differences in the nullability of reference types." + Warning 8604, Line 26, Col 60, Line 26, Col 70, "Possible null reference argument for parameter 'x_0' in 'Tuple MyTestModule.genericRefTypeTest(string x_0, string? x_1, int x_2, int x_3, int x_4, int x_5)'." + Warning 8625, Line 31, Col 51, Line 31, Col 55, "Cannot convert null literal to non-nullable reference type."] From 4de0a7e307ae361fc57a2fe80a146fb9b62ef546 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 3 Oct 2023 15:27:40 +0200 Subject: [PATCH 31/33] Changing NullableAttribute codegen (System.Array is not the same as byte[] ) --- src/Compiler/AbstractIL/il.fs | 4 +- src/Compiler/CodeGen/EraseUnions.fs | 8 +- src/Compiler/CodeGen/IlxGenSupport.fs | 2 +- .../Nullness/AnonRecords.fs.il.net472.bsl | 32 +++---- .../Nullness/AnonRecords.fs.il.netcore.bsl | 32 +++---- .../EmittedIL/Nullness/CsharpConsumer.cs | 3 - .../Nullness/CurriedFunctions.fs.il.bsl | 32 +++---- .../EmittedIL/Nullness/CustomType.fs.il.bsl | 30 +++--- .../Nullness/ModuleLevelBindings.fs.il.bsl | 28 +++--- .../Nullness/ModuleLevelFunctions.fs.il.bsl | 34 +++---- .../ModuleLevelFunctionsOpt.fs.il.bsl | 34 +++---- .../Nullness/NullAsTrueValue.fs.il.net472.bsl | 69 +++++++------- .../NullAsTrueValue.fs.il.netcore.bsl | 54 +++++------ .../EmittedIL/Nullness/NullnessMetadata.fs | 95 +++++++++++++++---- .../Nullness/Records.fs.il.net472.bsl | 30 +++--- .../Nullness/Records.fs.il.netcore.bsl | 30 +++--- .../Nullness/ReferenceDU.fs.il.net472.bsl | 28 +++--- .../Nullness/ReferenceDU.fs.il.netcore.bsl | 28 +++--- .../Nullness/StructDU.fs.il.net472.bsl | 55 ++++++----- .../Nullness/StructDU.fs.il.netcore.bsl | 40 ++++---- 20 files changed, 359 insertions(+), 309 deletions(-) diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index fbe612d22b8..becb0c3f46d 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -3450,9 +3450,9 @@ type ILGlobals(primaryScopeRef: ILScopeRef, equivPrimaryAssemblyRefs: ILAssembly member val typ_Byte = byteIlType - member val typ_ByteArray = mkILBoxedType (mkILTySpec (mkSysILTypeRef tname_Array, [ byteIlType ])) + member val typ_ByteArray = ILType.Array(ILArrayShape.SingleDimensional, byteIlType) - member val typ_StringArray = mkILBoxedType (mkILTySpec (mkSysILTypeRef tname_Array, [ stringIlType ])) + member val typ_StringArray = ILType.Array(ILArrayShape.SingleDimensional, stringIlType) member val typ_UInt16 = ILType.Value(mkILNonGenericTySpec (mkSysILTypeRef tname_UInt16)) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 633f73a0d56..49000d2cf65 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -1359,17 +1359,17 @@ let mkClassUnionDef (* The attribute carries either a single byte, or a list of bytes for the fields itself and all its generic type arguments The way we lay out DUs does not affect nullability of the typars of a field, therefore we just change the very first byte - If the field was already declared as nullable (value = 2uy) or ambivalent(value = 1uy), we can keep it that way - If it was marked as non-nullable within that UnionCase, we have to convert it to ambivalent due to other cases being possible + If the field was already declared as nullable (value = 2uy) or ambivalent(value = 0uy), we can keep it that way + If it was marked as non-nullable within that UnionCase, we have to convert it to WithNull (2uy) due to other cases being possible *) | Encoded (method, _data, [ ILAttribElem.Byte 1uy ]) -> - mkILCustomAttribMethRef (method, [ ILAttribElem.Byte 0uy ], []) + mkILCustomAttribMethRef (method, [ ILAttribElem.Byte 2uy ], []) | Encoded (method, _data, [ ILAttribElem.Array (elemType, (ILAttribElem.Byte 1uy) :: otherElems) ]) -> mkILCustomAttribMethRef ( method, - [ ILAttribElem.Array(elemType, (ILAttribElem.Byte 0uy) :: otherElems) ], + [ ILAttribElem.Array(elemType, (ILAttribElem.Byte 2uy) :: otherElems) ], [] ) | attrAsBefore -> attrAsBefore diff --git a/src/Compiler/CodeGen/IlxGenSupport.fs b/src/Compiler/CodeGen/IlxGenSupport.fs index b4856c0e0d4..3fcd1821a35 100644 --- a/src/Compiler/CodeGen/IlxGenSupport.fs +++ b/src/Compiler/CodeGen/IlxGenSupport.fs @@ -204,7 +204,7 @@ let mkLocalPrivateAttributeWithByteAndByteArrayConstructors (g: TcGlobals, name: ILGenericParameterDefs.Empty, g.ilg.typ_Attribute, ILTypes.Empty, - mkILMethods ([ ilArrayCtorDef; ilScalarCtorDef ]), + mkILMethods ([ ilScalarCtorDef; ilArrayCtorDef ]), mkILFields [ fieldDef ], emptyILTypeDefs, emptyILProperties, diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl index aec9e4e9869..cfed4707176 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl @@ -62,7 +62,7 @@ giveMeA() cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) .maxstack 8 IL_0000: call string MyTestModule::get_maybeString() @@ -92,7 +92,7 @@ giveMeC() cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) .maxstack 8 IL_0000: call string MyTestModule::get_maybeString() @@ -776,11 +776,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -789,13 +789,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -804,14 +809,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl index 7ae9d6301fc..1f5eb583c76 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.netcore.bsl @@ -62,7 +62,7 @@ giveMeA() cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) .maxstack 8 IL_0000: call string MyTestModule::get_maybeString() @@ -92,7 +92,7 @@ giveMeC() cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 04 00 00 00 01 02 02 02 00 00 ) .maxstack 8 IL_0000: call string MyTestModule::get_maybeString() @@ -683,11 +683,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -696,13 +696,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -711,14 +716,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CsharpConsumer.cs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CsharpConsumer.cs index 01de577913d..0f459a37a79 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CsharpConsumer.cs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CsharpConsumer.cs @@ -18,14 +18,11 @@ public static string JustUseAllOfItHere() var myStructTuple = (nullString,nullString,1,2,3,4); var thisShouldBeAWarningForSecondTypar = MyTestModule.genericValueTypeTest(myStructTuple); - // The line below gives a warning, but should not => FIX IT var thisShouldNotSayAnything = MyTestModule.genericValueTypeTest(("I am not nulll",null,1,2,3,4)); - // The line below should give a warning, but it is missing => FIX IT var thisShouldWarnFor2ndItem = MyTestModule.nonNullableInputOutputFunc(thisShouldNotSayAnything.Item2); var thisIsOkBecauseItem1IsNotNullable = MyTestModule.nonNullableInputOutputFunc(thisShouldNotSayAnything.Item1); var refTuple = MyTestModule.genericRefTypeTest(nullString,nullString,1,2,3,4); - // The one below should warn for using .Item2 for 1st argument, but it does not => FIX IT MyTestModule.genericRefTypeTest(refTuple.Item2,refTuple.Item2,1,2,3,4); diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl index 4153e65f617..e785503e5b7 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CurriedFunctions.fs.il.bsl @@ -73,7 +73,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 02 01 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 02 01 00 00 ) .param [1] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) @@ -91,7 +91,7 @@ partiallyAplied(string propperString) cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 06 00 00 00 01 01 01 01 02 01 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 06 00 00 00 01 01 01 01 02 01 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -133,11 +133,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -146,13 +146,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -161,14 +166,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl index 8c7e3af2bcd..93c51018c48 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/CustomType.fs.il.bsl @@ -36,7 +36,7 @@ .field static assembly string uglyGlobalMutableNullableString .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .field static assembly class [FSharp.Core]Microsoft.FSharp.Collections.FSharpMap`2 dict - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 02 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 02 02 00 00 ) .field assembly string Nullable@ .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .field assembly string NonNullable@ @@ -281,11 +281,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -294,13 +294,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -309,14 +314,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl index 9bba1aebc80..b4741b88b22 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelBindings.fs.il.bsl @@ -160,11 +160,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -173,13 +173,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -188,14 +193,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs.il.bsl index ad450d7738c..0860bb96bd6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctions.fs.il.bsl @@ -68,9 +68,9 @@ genericValueTypeTest(valuetype [runtime]System.ValueTuple`6 x) cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .param [1] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -86,7 +86,7 @@ int32 x_5) cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 01 02 00 00 ) .param [2] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) @@ -144,11 +144,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -157,13 +157,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -172,14 +177,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs.il.bsl index 083abbb1f07..6ffc03c1573 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ModuleLevelFunctionsOpt.fs.il.bsl @@ -68,9 +68,9 @@ genericValueTypeTest(valuetype [runtime]System.ValueTuple`6 x) cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .param [1] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -86,7 +86,7 @@ int32 x_5) cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 01 02 00 00 ) .param [2] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) @@ -141,11 +141,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -154,13 +154,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -169,14 +174,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl index 7e3f3d3f0b3..c86b6a5c3ff 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl @@ -431,7 +431,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) .param [1] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 01 02 00 00 ) .param [3] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) @@ -462,11 +462,11 @@ get_IsMyStructSome() cil managed { .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, - class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 - 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 - 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C - 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 - 31 00 00 ) + string[]) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 + 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 31 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -501,7 +501,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -619,11 +619,11 @@ .property instance bool IsMyStructSome() { .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, - class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 - 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 - 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C - 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 - 31 00 00 ) + string[]) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 + 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 31 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) @@ -635,7 +635,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() @@ -907,12 +907,12 @@ .field private bool ReturnValue@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .field private class [runtime]System.Array Members@ + .field private string[] Members@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname instance void .ctor(bool ReturnValue, - class [runtime]System.Array Members) cil managed + string[] Members) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -925,11 +925,11 @@ IL_0008: stfld bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::ReturnValue@ IL_000d: ldarg.0 IL_000e: ldarg.2 - IL_000f: stfld class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ + IL_000f: stfld string[] System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ IL_0014: ret } - .method public hidebysig specialname instance class [runtime]System.Array + .method public hidebysig specialname instance string[] get_Members() cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -937,7 +937,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ + IL_0001: ldfld string[] System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ IL_0006: ret } @@ -959,23 +959,22 @@ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_ReturnValue() } - .property instance class [runtime]System.Array - Members() + .property instance string[] Members() { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_Members() + .get instance string[] System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_Members() } } .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -984,13 +983,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -999,14 +1003,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl index 3fe2b3e2052..a0ece1bbbb7 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl @@ -431,7 +431,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32) = ( 01 00 08 00 00 00 01 00 00 00 00 00 ) .param [1] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 01 02 00 00 ) .param [3] .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) @@ -462,11 +462,11 @@ get_IsMyStructSome() cil managed { .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, - class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 - 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 - 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C - 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 - 31 00 00 ) + string[]) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 + 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 31 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -501,7 +501,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -619,11 +619,11 @@ .property instance bool IsMyStructSome() { .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, - class [runtime]System.Array) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 - 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 - 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C - 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 - 31 00 00 ) + string[]) = ( 01 00 01 04 00 00 00 0D 6E 6F 74 4E 75 6C 6C 46 + 69 65 6C 64 32 0D 6E 6F 74 4E 75 6C 6C 46 69 65 + 6C 64 31 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C + 64 32 0E 5F 6E 6F 74 4E 75 6C 6C 46 69 65 6C 64 + 31 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) @@ -635,7 +635,7 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() @@ -811,11 +811,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -824,13 +824,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -839,14 +844,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index d50032435af..9f313dd228c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -73,31 +73,86 @@ let ``Nullable attr for Option clones`` compilation = module Interop = open System.IO - let FsharpFunctins = - Path.Combine(__SOURCE_DIRECTORY__,"ModuleLevelFunctions.fs") + let fsharpLibCreator = + FSharp + >> asLibrary + >> withLangVersionPreview + >> withName "MyFSharpLib" + >> withOptions ["--checknulls"] + + let csharpLibCompile fsLibReference = + CSharp + >> withReferences [fsLibReference] + >> withCSharpLanguageVersion CSharpLanguageVersion.Preview + >> asLibrary + >> withName "CsharpAppConsumingNullness" + >> compile + + let FsharpFromFile filename = + Path.Combine(__SOURCE_DIRECTORY__, filename) |> File.ReadAllText - |> FSharp - |> asLibrary - |> withLangVersionPreview - |> withName "MyTestModule" - |> withOptions ["--checknulls"] + |> fsharpLibCreator + + [] + let ``Csharp understands Fsharp-produced struct unions via IsXXX flow analysis`` () = + let csharpCode = """ +#nullable enable +public class C { + public void M() { + var data = MyTestModule.MyStructDU.A; + if(data.IsA){ + string thisMustWarn = data.nonNullableString; + string? thisIsOk = data.nonNullableString; + string? thisIsAlsoOk = data.nullableString; + System.Console.Write(thisMustWarn + thisIsOk + thisIsAlsoOk); + } else if(data.IsB){ + string thisMustBeOK = data.nonNullableString; + System.Console.Write(thisMustBeOK.Length); + } else if (data.IsC){ + string evenThoughItIsC_ThisMustStillFailBecauseFieldIsNullable = data.nullableString; + System.Console.Write(evenThoughItIsC_ThisMustStillFailBecauseFieldIsNullable.Length); + } + + var thisCreationIsBad = MyTestModule.MyStructDU.NewB(null); + var thisCreationIsFine = MyTestModule.MyStructDU.NewC(null); + + System.Console.Write(thisCreationIsBad.ToString() + thisCreationIsFine.ToString() ); + } +}""" + csharpCode + |> csharpLibCompile (FsharpFromFile "StructDU.fs") + |> withDiagnostics [] + + [] + let ``Csharp code understands Fsharp-produced generics`` () = + let fsharpcode = """ +module MyFSharpLib +let stringTupleInOut(x:struct(string * string|null)) = x """ + let fsLib = fsharpLibCreator fsharpcode + let csharpCode = """ +#nullable enable +public class C { + public void M() { + string? nullString = null; + MyFSharpLib.stringTupleInOut(("a good string here",nullString)); + } +}""" + csharpCode + |> csharpLibCompile fsLib + |> withDiagnostics [] [] let ``Csharp code can work with annotated FSharp module`` () = Path.Combine(__SOURCE_DIRECTORY__,"CsharpConsumer.cs") |> File.ReadAllText - |> CSharp - |> withReferences [FsharpFunctins] - |> withCSharpLanguageVersion CSharpLanguageVersion.Preview - |> asLibrary - |> withName "CsharpAppConsumingNullness" - |> compile + |> csharpLibCompile (FsharpFromFile "ModuleLevelFunctions.fs") |> shouldFail |> withDiagnostics [ - Error 29, Line 31, Col 20, Line 31, Col 61, "Cannot implicitly convert type 'int' to 'string'" - Warning 8625, Line 12, Col 74, Line 12, Col 78, "Cannot convert null literal to non-nullable reference type." - Warning 8604, Line 14, Col 88, Line 14, Col 113, "Possible null reference argument for parameter 'x' in 'string MyTestModule.nonNullableInputOutputFunc(string x)'." - Warning 8620, Line 19, Col 88, Line 19, Col 101, "Argument of type '(string?, string?, int, int, int, int)' cannot be used for parameter 'x' of type '(string, string, int, int, int, int)' in '(string, string, int, int, int, int) MyTestModule.genericValueTypeTest((string, string, int, int, int, int) x)' due to differences in the nullability of reference types." - Warning 8620, Line 21, Col 78, Line 21, Col 109, "Argument of type '(string, string?, int, int, int, int)' cannot be used for parameter 'x' of type '(string, string, int, int, int, int)' in '(string, string, int, int, int, int) MyTestModule.genericValueTypeTest((string, string, int, int, int, int) x)' due to differences in the nullability of reference types." - Warning 8604, Line 26, Col 60, Line 26, Col 70, "Possible null reference argument for parameter 'x_0' in 'Tuple MyTestModule.genericRefTypeTest(string x_0, string? x_1, int x_2, int x_3, int x_4, int x_5)'." - Warning 8625, Line 31, Col 51, Line 31, Col 55, "Cannot convert null literal to non-nullable reference type."] + Error 29, Line 28, Col 20, Line 28, Col 61, "Cannot implicitly convert type 'int' to 'string'" + Warning 8625, Line 12, Col 74, Line 12, Col 78, "Cannot convert null literal to non-nullable reference type." + Warning 8604, Line 14, Col 88, Line 14, Col 113, "Possible null reference argument for parameter 'x' in 'string MyTestModule.nonNullableInputOutputFunc(string x)'." + Warning 8620, Line 19, Col 88, Line 19, Col 101, "Argument of type '(string?, string?, int, int, int, int)' cannot be used for parameter 'x' of type '(string, string?, int, int, int, int)' in '(string, string?, int, int, int, int) MyTestModule.genericValueTypeTest((string, string?, int, int, int, int) x)' due to differences in the nullability of reference types." + Warning 8604, Line 21, Col 84, Line 21, Col 114, "Possible null reference argument for parameter 'x' in 'string MyTestModule.nonNullableInputOutputFunc(string x)'." + Warning 8604, Line 24, Col 60, Line 24, Col 70, "Possible null reference argument for parameter 'x_0' in 'Tuple MyTestModule.genericRefTypeTest(string x_0, string? x_1, int x_2, int x_3, int x_4, int x_5)'." + Warning 8604, Line 25, Col 45, Line 25, Col 59, "Possible null reference argument for parameter 'x_0' in 'Tuple MyTestModule.genericRefTypeTest(string x_0, string? x_1, int x_2, int x_3, int x_4, int x_5)'." + Warning 8625, Line 28, Col 51, Line 28, Col 55, "Cannot convert null literal to non-nullable reference type."] \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl index feada7bde4e..ce45234c3e9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.net472.bsl @@ -261,7 +261,7 @@ createAnInstance() cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 02 01 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 02 01 00 00 ) .maxstack 9 IL_0000: ldc.i4.s 42 @@ -390,11 +390,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -403,13 +403,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -418,14 +423,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl index 66faee727eb..b29b5667144 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/Records.fs.il.netcore.bsl @@ -261,7 +261,7 @@ createAnInstance() cil managed { .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(class [runtime]System.Array) = ( 01 00 03 00 00 00 01 02 01 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 01 02 01 00 00 ) .maxstack 9 IL_0000: ldc.i4.s 42 @@ -297,11 +297,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -310,13 +310,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -325,14 +330,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl index eb38e7bad87..d84066219d8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.net472.bsl @@ -702,11 +702,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -715,13 +715,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -730,14 +735,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl index 1815f073173..da1235dd5eb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/ReferenceDU.fs.il.netcore.bsl @@ -609,11 +609,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -622,13 +622,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -637,14 +642,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl index 147b0b95e2e..6877e2466ea 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl @@ -107,9 +107,9 @@ get_IsB() cil managed { .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, - class [runtime]System.Array) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 - 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 - 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) + string[]) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 + 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 + 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -269,9 +269,9 @@ .property instance bool IsB() { .custom instance void System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, - class [runtime]System.Array) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 - 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 - 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) + string[]) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 + 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 + 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) @@ -441,12 +441,12 @@ .field private bool ReturnValue@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .field private class [runtime]System.Array Members@ + .field private string[] Members@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname instance void .ctor(bool ReturnValue, - class [runtime]System.Array Members) cil managed + string[] Members) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -459,11 +459,11 @@ IL_0008: stfld bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::ReturnValue@ IL_000d: ldarg.0 IL_000e: ldarg.2 - IL_000f: stfld class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ + IL_000f: stfld string[] System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ IL_0014: ret } - .method public hidebysig specialname instance class [runtime]System.Array + .method public hidebysig specialname instance string[] get_Members() cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -471,7 +471,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ + IL_0001: ldfld string[] System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::Members@ IL_0006: ret } @@ -493,23 +493,22 @@ .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance bool System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_ReturnValue() } - .property instance class [runtime]System.Array - Members() + .property instance string[] Members() { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .get instance class [runtime]System.Array System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_Members() + .get instance string[] System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::get_Members() } } .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -518,13 +517,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -533,14 +537,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl index 4ffb61997c5..07ada38600d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl @@ -107,9 +107,9 @@ get_IsB() cil managed { .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, - class [runtime]System.Array) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 - 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 - 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) + string[]) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 + 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 + 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -269,9 +269,9 @@ .property instance bool IsB() { .custom instance void [runtime]System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute::.ctor(bool, - class [runtime]System.Array) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 - 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 - 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) + string[]) = ( 01 00 01 02 00 00 00 11 6E 6F 6E 4E 75 6C 6C 61 + 62 6C 65 53 74 72 69 6E 67 12 5F 6E 6F 6E 4E 75 + 6C 6C 61 62 6C 65 53 74 72 69 6E 67 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) @@ -345,11 +345,11 @@ .class private auto ansi beforefieldinit System.Runtime.CompilerServices.NullableAttribute extends [runtime]System.Attribute { - .field public class [runtime]System.Array NullableFlags + .field public uint8[] NullableFlags .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .method public specialname rtspecialname - instance void .ctor(class [runtime]System.Array NullableFlags) cil managed + instance void .ctor(uint8 scalarByteValue) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -358,13 +358,18 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_000d: ret + IL_0007: ldc.i4.1 + IL_0008: newarr [runtime]System.Byte + IL_000d: dup + IL_000e: ldc.i4.0 + IL_000f: ldarg.1 + IL_0010: stelem.i1 + IL_0011: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_0016: ret } .method public specialname rtspecialname - instance void .ctor(uint8 scalarByteValue) cil managed + instance void .ctor(uint8[] NullableFlags) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) @@ -373,14 +378,9 @@ IL_0000: ldarg.0 IL_0001: call instance void [runtime]System.Attribute::.ctor() IL_0006: ldarg.0 - IL_0007: ldc.i4.1 - IL_0008: newarr [runtime]System.Byte - IL_000d: dup - IL_000e: ldc.i4.0 - IL_000f: ldarg.1 - IL_0010: stelem.i1 - IL_0011: stfld class [runtime]System.Array System.Runtime.CompilerServices.NullableAttribute::NullableFlags - IL_0016: ret + IL_0007: ldarg.1 + IL_0008: stfld uint8[] System.Runtime.CompilerServices.NullableAttribute::NullableFlags + IL_000d: ret } } From c21c416f8549fb83c94faeeeefcfee3db6c7414f Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 3 Oct 2023 15:37:06 +0200 Subject: [PATCH 32/33] Get stricter for DUs - WithNull instead of Ambivalent if fields are not guaranteed to be filled --- src/Compiler/CodeGen/EraseUnions.fs | 2 +- .../Nullness/NullAsTrueValue.fs.il.net472.bsl | 12 ++++++------ .../Nullness/NullAsTrueValue.fs.il.netcore.bsl | 12 ++++++------ .../EmittedIL/Nullness/NullnessMetadata.fs | 6 +++++- .../EmittedIL/Nullness/StructDU.fs.il.net472.bsl | 4 ++-- .../EmittedIL/Nullness/StructDU.fs.il.netcore.bsl | 4 ++-- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 49000d2cf65..9aeaaedf7d9 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -1351,7 +1351,7 @@ let mkClassUnionDef existingAttrs |> Array.append [| - GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.AmbivalentToNull ] + GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.WithNull ] |] | Some idx -> let replacementAttr = diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl index c86b6a5c3ff..7c42b07d649 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.net472.bsl @@ -501,7 +501,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 02 01 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -515,7 +515,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -543,7 +543,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -635,14 +635,14 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 02 01 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() } .property instance string notNullField2() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 00 00 ) @@ -662,7 +662,7 @@ } .property instance !T notNullField1() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 03 00 00 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl index a0ece1bbbb7..8520df5ca9f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullAsTrueValue.fs.il.netcore.bsl @@ -501,7 +501,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 02 01 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -515,7 +515,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -543,7 +543,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -635,14 +635,14 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 00 01 02 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8[]) = ( 01 00 03 00 00 00 02 01 02 00 00 ) .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .get instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1> TestModule/MyStructOption`1::get_nestedGenericField() } .property instance string notNullField2() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 00 00 ) @@ -662,7 +662,7 @@ } .property instance !T notNullField1() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 03 00 00 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs index 9f313dd228c..fc9425ee4e2 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/NullnessMetadata.fs @@ -121,7 +121,11 @@ public class C { }""" csharpCode |> csharpLibCompile (FsharpFromFile "StructDU.fs") - |> withDiagnostics [] + |> withDiagnostics [ + Warning 8600, Line 6, Col 35, Line 6, Col 57, "Converting null literal or possible null value to non-nullable type." + Warning 8600, Line 14, Col 78, Line 14, Col 97, "Converting null literal or possible null value to non-nullable type." + Warning 8602, Line 15, Col 34, Line 15, Col 89, "Dereference of a possibly null reference." + Warning 8625, Line 18, Col 62, Line 18, Col 66, "Cannot convert null literal to non-nullable reference type."] [] let ``Csharp code understands Fsharp-produced generics`` () = diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl index 6877e2466ea..f2b77a10594 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.net472.bsl @@ -179,7 +179,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -286,7 +286,7 @@ } .property instance string nonNullableString() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl index 07ada38600d..03597845da5 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/StructDU.fs.il.netcore.bsl @@ -179,7 +179,7 @@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .param [0] - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -286,7 +286,7 @@ } .property instance string nonNullableString() { - .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 00 00 00 ) + .custom instance void System.Runtime.CompilerServices.NullableAttribute::.ctor(uint8) = ( 01 00 02 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags, int32, int32) = ( 01 00 04 00 00 00 01 00 00 00 00 00 00 00 00 00 ) From 27eeeb023de95061fbffe244e3a183c95024b977 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 3 Oct 2023 20:23:17 +0200 Subject: [PATCH 33/33] do not emit NullableContext for DU alttypes if not asked for via the --checknulls switch --- src/Compiler/CodeGen/EraseUnions.fs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Compiler/CodeGen/EraseUnions.fs b/src/Compiler/CodeGen/EraseUnions.fs index 9aeaaedf7d9..fd0d9660914 100644 --- a/src/Compiler/CodeGen/EraseUnions.fs +++ b/src/Compiler/CodeGen/EraseUnions.fs @@ -1189,6 +1189,12 @@ let convAlternativeDef .With(customAttrs = mkILCustomAttrs [ GetDynamicDependencyAttribute g 0x660 baseTy ]) |> addMethodGeneratedAttrs + let attrs = + if g.checkNullness && g.langFeatureNullness then + GetNullableContextAttribute g :: debugAttrs + else + debugAttrs + let altTypeDef = mkILGenericClass ( altTy.TypeSpec.Name, @@ -1207,7 +1213,7 @@ let convAlternativeDef emptyILTypeDefs, mkILProperties basicProps, emptyILEvents, - mkILCustomAttrs (GetNullableContextAttribute g :: debugAttrs), + mkILCustomAttrs attrs, ILTypeInit.BeforeField ) @@ -1349,10 +1355,7 @@ let mkClassUnionDef match nullableIdx with | None -> existingAttrs - |> Array.append - [| - GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.WithNull ] - |] + |> Array.append [| GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.WithNull ] |] | Some idx -> let replacementAttr = match existingAttrs[idx] with