diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 5d7848f246e..c6ba41c76df 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -2519,6 +2519,7 @@ type ILTypeDefLayout = | Auto | Sequential of ILTypeDefLayoutInfo | Explicit of ILTypeDefLayoutInfo (* REVIEW: add field info here *) + | Extended and ILTypeDefLayoutInfo = { @@ -2632,6 +2633,10 @@ let convertLayout layout = | ILTypeDefLayout.Auto -> TypeAttributes.AutoLayout | ILTypeDefLayout.Sequential _ -> TypeAttributes.SequentialLayout | ILTypeDefLayout.Explicit _ -> TypeAttributes.ExplicitLayout + | ILTypeDefLayout.Extended -> + // Extended layout is represented by TypeAttributes value 0x18 (both Sequential and Explicit bits set) + // This is defined by the ECMA-335 spec for extended layout types + enum (0x18) let convertEncoding encoding = match encoding with diff --git a/src/Compiler/AbstractIL/il.fsi b/src/Compiler/AbstractIL/il.fsi index 3d6f88bb6ca..f75092724ea 100644 --- a/src/Compiler/AbstractIL/il.fsi +++ b/src/Compiler/AbstractIL/il.fsi @@ -1458,6 +1458,7 @@ type ILTypeDefLayout = | Auto | Sequential of ILTypeDefLayoutInfo | Explicit of ILTypeDefLayoutInfo + | Extended type internal ILTypeDefLayoutInfo = { Size: int32 option diff --git a/src/Compiler/AbstractIL/ilprint.fs b/src/Compiler/AbstractIL/ilprint.fs index 12e421f6829..d9fa4368a2e 100644 --- a/src/Compiler/AbstractIL/ilprint.fs +++ b/src/Compiler/AbstractIL/ilprint.fs @@ -776,6 +776,7 @@ let splitTypeLayout = | ILTypeDefLayout.Auto -> "auto", (fun _os () -> ()) | ILTypeDefLayout.Sequential info -> "sequential", (fun os () -> output_type_layout_info os info) | ILTypeDefLayout.Explicit info -> "explicit", (fun os () -> output_type_layout_info os info) + | ILTypeDefLayout.Extended -> "extended", (fun _os () -> ()) let goutput_fdefs tref env os (fdefs: ILFieldDefs) = for f in fdefs.AsList() do diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 9aa2a2672ef..ca4e54723f2 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -2044,6 +2044,8 @@ and typeLayoutOfFlags (ctxt: ILMetadataReader) mdv flags tidx = ILTypeDefLayout.Sequential(seekReadClassLayout ctxt mdv tidx) elif f = 0x00000010 then ILTypeDefLayout.Explicit(seekReadClassLayout ctxt mdv tidx) + elif f = 0x00000018 then + ILTypeDefLayout.Extended else ILTypeDefLayout.Auto diff --git a/src/Compiler/AbstractIL/ilreflect.fs b/src/Compiler/AbstractIL/ilreflect.fs index 03a6f829d64..1e205756363 100644 --- a/src/Compiler/AbstractIL/ilreflect.fs +++ b/src/Compiler/AbstractIL/ilreflect.fs @@ -2106,6 +2106,7 @@ let typeAttributesOfTypeLayout cenv emEnv x = | ILTypeDefLayout.Auto -> None | ILTypeDefLayout.Explicit p -> (attr 0x02 p) | ILTypeDefLayout.Sequential p -> (attr 0x00 p) + | ILTypeDefLayout.Extended -> None // No StructLayoutAttribute needed; user's ExtendedLayoutAttribute is preserved //---------------------------------------------------------------------------- // buildTypeDefPass1 cenv diff --git a/src/Compiler/AbstractIL/ilwrite.fs b/src/Compiler/AbstractIL/ilwrite.fs index 40254a11965..297b0267bc1 100644 --- a/src/Compiler/AbstractIL/ilwrite.fs +++ b/src/Compiler/AbstractIL/ilwrite.fs @@ -2883,6 +2883,7 @@ let rec GenTypeDefPass3 enc cenv (tdef: ILTypeDef) = // ClassLayout entry if needed match tdef.Layout with | ILTypeDefLayout.Auto -> () + | ILTypeDefLayout.Extended -> () // No ClassLayout row for Extended; bits are in TypeAttributes | ILTypeDefLayout.Sequential layout | ILTypeDefLayout.Explicit layout -> if Option.isSome layout.Pack || Option.isSome layout.Size then AddUnsharedRow cenv TableNames.ClassLayout diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 6ed83af8136..7f69813cb7a 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -3416,6 +3416,7 @@ module EstablishTypeDefinitionCores = let hasMeasureableAttr = HasFSharpAttribute g g.attrib_MeasureableAttribute attrs let structLayoutAttr = TryFindFSharpInt32Attribute g g.attrib_StructLayoutAttribute attrs + let hasExtendedLayoutAttr = HasFSharpAttributeOpt g g.attrib_ExtendedLayoutAttribute_opt attrs let hasAllowNullLiteralAttr = TryFindFSharpBoolAttribute g g.attrib_AllowNullLiteralAttribute attrs = Some true if hasAbstractAttr then @@ -3436,7 +3437,13 @@ module EstablishTypeDefinitionCores = let structLayoutAttributeCheck allowed = let explicitKind = int32 System.Runtime.InteropServices.LayoutKind.Explicit + // LayoutKind.Extended will have enum value 1 in future .NET versions (currently unused slot) + // It cannot be specified via StructLayoutAttribute - users must use ExtendedLayoutAttribute instead + // See: https://github.com/dotnet/runtime/issues/102727 + let extendedLayoutKind = 1 match structLayoutAttr with + | Some kind when kind = extendedLayoutKind -> + errorR (Error(FSComp.SR.tcInvalidStructLayoutExtendedKind(), m)) | Some kind -> if allowed then if kind = explicitKind then @@ -3446,6 +3453,22 @@ module EstablishTypeDefinitionCores = else errorR (Error(FSComp.SR.tcGenericTypesCannotHaveStructLayout(), m)) | None -> () + + let extendedLayoutAttributeCheck () = + if hasExtendedLayoutAttr then + // Check runtime support + match g.attrib_ExtendedLayoutAttribute_opt with + | None -> + errorR (Error(FSComp.SR.tcRuntimeDoesNotSupportExtendedLayoutTypes(), m)) + | Some _ -> () + + // Check not combined with StructLayoutAttribute + if structLayoutAttr.IsSome then + errorR (Error(FSComp.SR.tcStructLayoutAndExtendedLayout(), m)) + + let noExtendedLayoutAttributeCheck () = + if hasExtendedLayoutAttr then + errorR (Error(FSComp.SR.tcOnlyStructsCanHaveExtendedLayout(), m)) let hiddenReprChecks hasRepr = structLayoutAttributeCheck false @@ -3684,17 +3707,20 @@ module EstablishTypeDefinitionCores = if not (isNil slotsigs) then errorR (Error(FSComp.SR.tcStructTypesCannotContainAbstractMembers(), m)) structLayoutAttributeCheck true + extendedLayoutAttributeCheck() TFSharpStruct | SynTypeDefnKind.Interface -> if hasSealedAttr = Some true then errorR (Error(FSComp.SR.tcInterfaceTypesCannotBeSealed(), m)) structLayoutAttributeCheck false + noExtendedLayoutAttributeCheck() noAbstractClassAttributeCheck() allowNullLiteralAttributeCheck() noFieldsCheck userFields TFSharpInterface | SynTypeDefnKind.Class -> structLayoutAttributeCheck(not isIncrClass) + noExtendedLayoutAttributeCheck() allowNullLiteralAttributeCheck() for slot in abstractSlots do if not slot.IsInstanceMember then @@ -3703,6 +3729,7 @@ module EstablishTypeDefinitionCores = | SynTypeDefnKind.Delegate (ty, arity) -> noSealedAttributeCheck FSComp.SR.tcTypesAreAlwaysSealedDelegate structLayoutAttributeCheck false + noExtendedLayoutAttributeCheck() noAllowNullLiteralAttributeCheck() noAbstractClassAttributeCheck() noFieldsCheck userFields diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index b4460b92e55..96c32026229 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -11564,60 +11564,64 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option tdef let tdLayout, tdEncoding = - match TryFindFSharpAttribute g g.attrib_StructLayoutAttribute tycon.Attribs with - | Some(Attrib(_, _, [ AttribInt32Arg layoutKind ], namedArgs, _, _, _)) -> - let decoder = AttributeDecoder namedArgs - let ilPack = decoder.FindInt32 "Pack" 0x0 - let ilSize = decoder.FindInt32 "Size" 0x0 - - let tdEncoding = - match (decoder.FindInt32 "CharSet" 0x0) with - (* enumeration values for System.Runtime.InteropServices.CharSet taken from mscorlib.il *) - | 0x03 -> ILDefaultPInvokeEncoding.Unicode - | 0x04 -> ILDefaultPInvokeEncoding.Auto - | _ -> ILDefaultPInvokeEncoding.Ansi - - let layoutInfo = - if ilPack = 0x0 && ilSize = 0x0 then - { Size = None; Pack = None } - else - { - Size = Some ilSize - Pack = Some(uint16 ilPack) - } - - let tdLayout = - match layoutKind with - (* enumeration values for System.Runtime.InteropServices.LayoutKind taken from mscorlib.il *) - | 0x0 -> ILTypeDefLayout.Sequential layoutInfo - | 0x2 -> ILTypeDefLayout.Explicit layoutInfo - | _ -> ILTypeDefLayout.Auto - - tdLayout, tdEncoding - | Some(Attrib(_, _, _, _, _, _, m)) -> - errorR (Error(FSComp.SR.ilStructLayoutAttributeCouldNotBeDecoded (), m)) - ILTypeDefLayout.Auto, ILDefaultPInvokeEncoding.Ansi - - | _ when - (match ilTypeDefKind with - | HasFlag ILTypeDefAdditionalFlags.ValueType -> true - | _ -> false) - -> + // Check for ExtendedLayoutAttribute first + if HasFSharpAttributeOpt g g.attrib_ExtendedLayoutAttribute_opt tycon.Attribs then + ILTypeDefLayout.Extended, ILDefaultPInvokeEncoding.Ansi + else + match TryFindFSharpAttribute g g.attrib_StructLayoutAttribute tycon.Attribs with + | Some(Attrib(_, _, [ AttribInt32Arg layoutKind ], namedArgs, _, _, _)) -> + let decoder = AttributeDecoder namedArgs + let ilPack = decoder.FindInt32 "Pack" 0x0 + let ilSize = decoder.FindInt32 "Size" 0x0 + + let tdEncoding = + match (decoder.FindInt32 "CharSet" 0x0) with + (* enumeration values for System.Runtime.InteropServices.CharSet taken from mscorlib.il *) + | 0x03 -> ILDefaultPInvokeEncoding.Unicode + | 0x04 -> ILDefaultPInvokeEncoding.Auto + | _ -> ILDefaultPInvokeEncoding.Ansi + + let layoutInfo = + if ilPack = 0x0 && ilSize = 0x0 then + { Size = None; Pack = None } + else + { + Size = Some ilSize + Pack = Some(uint16 ilPack) + } - // All structs are sequential by default - // Structs with no instance fields get size 1, pack 0 - if - tycon.AllFieldsArray |> Array.exists (fun f -> not f.IsStatic) - || - // Reflection emit doesn't let us emit 'pack' and 'size' for generic structs. - // In that case we generate a dummy field instead - (cenv.options.workAroundReflectionEmitBugs && not tycon.TyparsNoRange.IsEmpty) - then - ILTypeDefLayout.Sequential { Size = None; Pack = None }, ILDefaultPInvokeEncoding.Ansi - else - ILTypeDefLayout.Sequential { Size = Some 1; Pack = Some 0us }, ILDefaultPInvokeEncoding.Ansi + let tdLayout = + match layoutKind with + (* enumeration values for System.Runtime.InteropServices.LayoutKind taken from mscorlib.il *) + | 0x0 -> ILTypeDefLayout.Sequential layoutInfo + | 0x2 -> ILTypeDefLayout.Explicit layoutInfo + | _ -> ILTypeDefLayout.Auto + + tdLayout, tdEncoding + | Some(Attrib(_, _, _, _, _, _, m)) -> + errorR (Error(FSComp.SR.ilStructLayoutAttributeCouldNotBeDecoded (), m)) + ILTypeDefLayout.Auto, ILDefaultPInvokeEncoding.Ansi + + | _ when + (match ilTypeDefKind with + | HasFlag ILTypeDefAdditionalFlags.ValueType -> true + | _ -> false) + -> + + // All structs are sequential by default + // Structs with no instance fields get size 1, pack 0 + if + tycon.AllFieldsArray |> Array.exists (fun f -> not f.IsStatic) + || + // Reflection emit doesn't let us emit 'pack' and 'size' for generic structs. + // In that case we generate a dummy field instead + (cenv.options.workAroundReflectionEmitBugs && not tycon.TyparsNoRange.IsEmpty) + then + ILTypeDefLayout.Sequential { Size = None; Pack = None }, ILDefaultPInvokeEncoding.Ansi + else + ILTypeDefLayout.Sequential { Size = Some 1; Pack = Some 0us }, ILDefaultPInvokeEncoding.Ansi - | _ -> ILTypeDefLayout.Auto, ILDefaultPInvokeEncoding.Ansi + | _ -> ILTypeDefLayout.Auto, ILDefaultPInvokeEncoding.Ansi // if the type's layout is Explicit, ensure that each field has a valid offset let validateExplicit (fdef: ILFieldDef) = @@ -11641,6 +11645,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option match tdLayout with | ILTypeDefLayout.Explicit _ -> List.iter validateExplicit ilFieldDefs | ILTypeDefLayout.Sequential _ -> List.iter validateSequential ilFieldDefs + | ILTypeDefLayout.Extended -> List.iter validateSequential ilFieldDefs // Extended layout also disallows FieldOffset | _ -> () let tdef = diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 043a2ae30e2..626f66e7cc3 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -788,6 +788,10 @@ tcTypeAbbreviationHasTypeParametersMissingOnType,"This type abbreviation has one 935,tcAllowNullTypesMayOnlyInheritFromAllowNullTypes,"Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal" 936,tcGenericTypesCannotHaveStructLayout,"Generic types cannot be given the 'StructLayout' attribute" 937,tcOnlyStructsCanHaveStructLayout,"Only structs and classes without primary constructors may be given the 'StructLayout' attribute" +3879,tcStructLayoutAndExtendedLayout,"The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type" +3880,tcRuntimeDoesNotSupportExtendedLayoutTypes,"The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime." +3881,tcOnlyStructsCanHaveExtendedLayout,"Only structs may be given the 'ExtendedLayoutAttribute'" +3882,tcInvalidStructLayoutExtendedKind,"LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead." 938,tcRepresentationOfTypeHiddenBySignature,"The representation of this type is hidden by the signature. It must be given an attribute such as [], [] or [] to indicate the characteristics of the type." 939,tcOnlyClassesCanHaveAbstract,"Only classes may be given the 'AbstractClass' attribute" 940,tcOnlyTypesRepresentingUnitsOfMeasureCanHaveMeasure,"Only types representing units-of-measure may be given the 'Measure' attribute" diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index d00e6009231..5d1d604a40a 100644 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -1487,6 +1487,7 @@ type TcGlobals( member val attrib_IsByRefLikeAttribute_opt = tryFindSysAttrib "System.Runtime.CompilerServices.IsByRefLikeAttribute" member val attrib_DllImportAttribute = tryFindSysAttrib "System.Runtime.InteropServices.DllImportAttribute" member val attrib_StructLayoutAttribute = findSysAttrib "System.Runtime.InteropServices.StructLayoutAttribute" + member val attrib_ExtendedLayoutAttribute_opt = tryFindSysAttrib "System.Runtime.InteropServices.ExtendedLayoutAttribute" member val attrib_TypeForwardedToAttribute = findSysAttrib "System.Runtime.CompilerServices.TypeForwardedToAttribute" member val attrib_ComVisibleAttribute = findSysAttrib "System.Runtime.InteropServices.ComVisibleAttribute" member val attrib_ComImportAttribute = tryFindSysAttrib "System.Runtime.InteropServices.ComImportAttribute" diff --git a/src/Compiler/TypedTree/TcGlobals.fsi b/src/Compiler/TypedTree/TcGlobals.fsi index 27cbdb17748..fc6e5736c5e 100644 --- a/src/Compiler/TypedTree/TcGlobals.fsi +++ b/src/Compiler/TypedTree/TcGlobals.fsi @@ -481,6 +481,8 @@ type internal TcGlobals = member attrib_StructLayoutAttribute: BuiltinAttribInfo + member attrib_ExtendedLayoutAttribute_opt: BuiltinAttribInfo option + member attrib_StructuralComparisonAttribute: BuiltinAttribInfo member attrib_StructuralEqualityAttribute: BuiltinAttribInfo diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index a345e7b8bbf..7c25dc8defd 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -1557,6 +1557,11 @@ Neplatné omezení. Platné formuláře omezení zahrnují "T :> ISomeInterface\" pro omezení rozhraní a \"SomeConstrainingType<'T>\" pro vlastní omezení. Viz https://aka.ms/fsharp-type-constraints. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions Použití [<Struct>] u hodnot, funkcí a metod je povolené jenom u částečných aktivních definic vzorů. @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. Syntaxe expr1[expr2] je při použití jako argument nejednoznačná. Více informací: https://aka.ms/fsharp-index-notation. Pokud plánujete indexování nebo vytváření řezů, musíte použít expr1.[expr2] na pozici argumentu. Pokud voláte funkci s vícenásobnými curryfikovanými argumenty, přidejte mezi ně mezeru, třeba someFunction expr1 [expr2]. @@ -1752,6 +1762,11 @@ Použití obnovitelného kódu nebo obnovitelných stavových strojů vyžaduje /langversion:preview. + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization Nelze volat „{0}“ - metodu setter pro vlastnost pouze init. Použijte místo toho inicializaci objektu. Viz https://aka.ms/fsharp-assigning-values-to-properties-at-initialization @@ -1762,6 +1777,11 @@ Statické vazby nelze přidat do rozšíření extrinsic. Zvažte použití „statického člena“. + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. Pokud je typ sjednocení s více písmeny strukturou, musí být všechna pole se stejným názvem stejného typu. Toto pravidlo platí také pro vygenerovaný název Item v případě nepojmenovaných polí. diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index a2240970789..588be3e9ab0 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -1557,6 +1557,11 @@ Ungültige Einschränkung. Gültige Einschränkungsformen sind \"'T :> ISomeInterface\" für Schnittstelleneinschränkungen und\"SomeConstrainingType<'T>\" für Selbsteinschränkungen. Siehe https://aka.ms/fsharp-type-constraints. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions Die Verwendung von "[<Struct>]" für Werte, Funktionen und Methoden ist nur für partielle aktive Musterdefinitionen zulässig. @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. Die Syntax "expr1[expr2]" ist mehrdeutig, wenn sie als Argument verwendet wird. Siehe https://aka.ms/fsharp-index-notation. Wenn Sie indizieren oder aufteilen möchten, müssen Sie "expr1.[expr2]' in Argumentposition verwenden. Wenn Sie eine Funktion mit mehreren geschweiften Argumenten aufrufen, fügen Sie ein Leerzeichen dazwischen hinzu, z. B. "someFunction expr1 [expr2]". @@ -1752,6 +1762,11 @@ Die Verwendung von Fortsetzbarem Code oder fortsetzbaren Zustandscomputern erfordert /langversion:preview + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization „{0}“ kann nicht aufgerufen werden – ein Setter für die Eigenschaft nur für die Initialisierung. Bitte verwenden Sie stattdessen die Objektinitialisierung. Siehe https://aka.ms/fsharp-assigning-values-to-properties-at-initialization @@ -1762,6 +1777,11 @@ Statische Bindungen können extrinsischen Augmentationen nicht hinzugefügt werden. Verwenden Sie stattdessen "static member". + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. Wenn ein Union-Typ mit mehreren Großbuchstaben eine Struktur ist, müssen alle Felder mit demselben Namen denselben Typ aufweisen. Diese Regel gilt auch für den generierten Elementnamen bei unbenannten Feldern. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index e643ec6bb52..b55633f5f32 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -1557,6 +1557,11 @@ Restricción no válida. Los formularios de restricción válidos incluyen \"'T :> ISomeInterface\" para restricciones de interfaz y \"SomeConstrainingType<'T>\" para restricciones propias. Ver https://aka.ms/fsharp-type-constraints. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions El uso de "[<Struct>]" en valores, funciones y métodos solo se permite en definiciones de modelos activos parciales. @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. La sintaxis "expr1[expr2]" es ambigua cuando se usa como argumento. Vea https://aka.ms/fsharp-index-notation. Si piensa indexar o segmentar, debe usar "expr1.[expr2]" en la posición del argumento. Si se llama a una función con varios argumentos currificados, se agregará un espacio entre ellos, por ejemplo, "unaFunción expr1 [expr2]". @@ -1752,6 +1762,11 @@ El uso de código reanudable o de máquinas de estado reanudables requiere /langversion:preview + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization No se puede llamar a '{0}': un establecedor para una propiedad de solo inicialización. Use la inicialización del objeto en su lugar. Ver https://aka.ms/fsharp-assigning-values-to-properties-at-initialization @@ -1762,6 +1777,11 @@ No se pueden agregar enlaces estáticos a aumentos extrínsecos. Considere la posibilidad de usar un "miembro estático" en su lugar. + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. Si un tipo de unión multicase es un struct, todos los campos con el mismo nombre deben ser del mismo tipo. Esta regla se aplica también al nombre "Item" generado en el caso de campos sin nombre. diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 01f2038adb7..24fe9f416a9 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -1557,6 +1557,11 @@ Contrainte non valide. Les formes de contrainte valides incluent \"'T :> ISomeInterface\" pour les contraintes d’interface et \"SomeConstrainingType<'T>\" pour les contraintes automatiques. Consultez https://aka.ms/fsharp-type-constraints. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions L’utilisation de' [<Struct>] 'sur les valeurs, les fonctions et les méthodes n’est autorisée que sur les définitions de modèle actif partiel @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. La syntaxe « expr1[expr2] » est ambiguë lorsqu’elle est utilisée comme argument. Voir https://aka.ms/fsharp-index-notation. Si vous avez l’intention d’indexer ou de découper, vous devez utiliser « expr1.[expr2] » en position d’argument. Si vous appelez une fonction avec plusieurs arguments codés, ajoutez un espace entre eux, par exemple « someFunction expr1 [expr2] ». @@ -1752,6 +1762,11 @@ L’utilisation de code pouvant être repris ou de machines d’état pouvant être reprises nécessite /langversion:preview + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization Nous n’avons pas pu appeler '{0}' - méthode setter pour la propriété init-only. Utilisez plutôt l’initialisation d’objet. Consultez https://aka.ms/fsharp-assigning-values-to-properties-at-initialization. @@ -1762,6 +1777,11 @@ Les liaisons statiques ne peuvent pas être ajoutées aux augmentations extrinsèques. Pensez plutôt à utiliser un « membre statique ». + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. Si un type union multicase est un struct, tous les champs portant le même nom doivent être du même type. Cette règle s’applique également au nom « Item » généré en cas de champs sans nom. diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index ca030a8cbe4..ce5ff8a2ad3 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -1557,6 +1557,11 @@ Vincolo non valido. Forme di vincoli validi includono \"'T :> ISomeInterface\" per i vincoli di interfaccia e \"SomeConstrainingType<'T>\" per i vincoli automatici. Vedere https://aka.ms/fsharp-type-constraints. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions L'utilizzo di '[<Struct>]' su valori, funzioni e metodi è consentito solo per definizioni di criteri attivi parziali @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. La sintassi 'expr1[expr2]' è ambigua se usata come argomento. Vedere https://aka.ms/fsharp-index-notation. Se si intende eseguire l'indicizzazione o il sezionamento, è necessario usare 'expr1.[expr2]' nella posizione dell'argomento. Se si chiama una funzione con più argomenti sottoposti a corsi, aggiungere uno spazio tra di essi, ad esempio 'someFunction expr1 [expr2]'. @@ -1752,6 +1762,11 @@ Per l'uso del codice ripristinabile o delle macchine a stati ripristinabili è richiesto /langversion:preview + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization Non è possibile chiamare '{0}', un setter per la proprietà init-only. Usare invece l'inizializzazione dell'oggetto. Vedere https://aka.ms/fsharp-assigning-values-to-properties-at-initialization @@ -1762,6 +1777,11 @@ Non è possibile aggiungere binding statici ad aumenti estrinseci. Prendi in considerazione un "membro statico", in alternativa. + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. Se un tipo di unione multicase è uno struct, tutti i campi con lo stesso nome devono essere dello stesso tipo. Questa regola si applica anche al nome 'Elemento' generato in caso di campi senza nome. diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 6008dd1067f..5bb70507d2a 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -1557,6 +1557,11 @@ 制約が無効です。有効な制約フォームには、インターフェイス制約の場合は \"'T :> ISomeInterface\"、自己制約の場合には \"SomeConstrainingType<'T>\" があります。https://aka.ms/fsharp-type-constraints を参照してください。 + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions 値、関数、およびメソッドでの '[<Struct>]' は、部分的なアクティブ パターンの定義でのみ使うことができます @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. 構文 'expr1[expr2]' は引数として使用されている場合、あいまいです。https://aka.ms/fsharp-index-notation を参照してください。インデックス作成またはスライスを行う場合は、'expr1.[expr2]' を引数の位置に使用する必要があります。複数のカリー化された引数を持つ関数を呼び出す場合は、'expr1 [expr2]' のように間にスペースを追加します。 @@ -1752,6 +1762,11 @@ 再開可能なコードまたは再開可能なステート マシンを使用するには、/langversion:preview が必要です + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization '{0}' を呼び出すことはできません。これは init のみのプロパティのセッターなので、代わりにオブジェクトの初期化を使用してください。https://aka.ms/fsharp-assigning-values-to-properties-at-initialization を参照してください。 @@ -1762,6 +1777,11 @@ 静的バインディングを外部拡張に追加することはできません。代わりに'静的メンバー' を使用することを検討してください。 + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. マルチケース共用体型が構造体の場合、同じ名前を持つすべてのフィールドが同じ型である必要があります。このルールは、名前のないフィールドの場合に生成された 'Item' 名にも適用されます。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index d7e05c339be..aadf15bc322 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -1557,6 +1557,11 @@ 제약 조건이 잘못되었습니다. 유효한 제약 조건 양식은 인터페이스 제약 조건의 경우 \"'T :> ISomeInterface\", 자체 제약 조건의 경우 \"SomeConstrainingType<'T>\" 등입니다. https://aka.ms/fsharp-type-constraints를 참조하세요. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions 값, 함수 및 메서드에 '[<Struct>]'을(를) 사용하는 것은 부분 활성 패턴 정의에서만 허용됩니다. @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. 'expr1[expr2]' 구문은 인수로 사용될 때 모호합니다. https://aka.ms/fsharp-index-notation을 참조하세요. 인덱싱이나 슬라이싱을 하려면 인수 위치에 'expr1.[expr2]'를 사용해야 합니다. 여러 개의 커리된 인수로 함수를 호출하는 경우 그 사이에 공백을 추가하세요(예: 'someFunction expr1 [expr2]'). @@ -1752,6 +1762,11 @@ 다시 시작 가능한 코드 또는 다시 시작 가능한 상태 시스템을 사용하려면 /langversion:preview가 필요합니다. + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization init 전용 속성의 setter인 '{0}'을(를) 호출할 수 없습니다. 개체 초기화를 대신 사용하세요. https://aka.ms/fsharp-assigning-values-to-properties-at-initialization를 참조하세요. @@ -1762,6 +1777,11 @@ 정적 바인딩은 외적 증강에 추가할 수 없습니다. 대신 '정적 멤버'를 사용하는 것이 좋습니다. + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. 멀티캐시 공용 구조체 형식이 구조체이면 이름이 같은 모든 필드의 형식이 같아야 합니다. 이 규칙은 명명되지 않은 필드의 경우 생성된 '항목' 이름에도 적용됩니다. diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index beb757ca1bf..bad272b5322 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -1557,6 +1557,11 @@ Nieprawidłowe ograniczenie. Prawidłowe formularze ograniczeń obejmują \"'T :> ISomeInterface\" for interface constraints and \"SomeConstrainingType<'T>\" dla ograniczeń własnych. Zobacz https://aka.ms/fsharp-type-constraints. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions Używanie elementu "[<Struct>]" w przypadku wartości, funkcji i metod jest dozwolone tylko w definicjach częściowo aktywnego wzorca @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. Składnia wyrażenia „expr1[expr2]” jest niejednoznaczna, gdy jest używana jako argument. Zobacz https://aka.ms/fsharp-index-notation. Jeśli zamierzasz indeksować lub fragmentować, to w pozycji argumentu musi być użyte wyrażenie „expr1.[expr2]”. Jeśli wywołujesz funkcję z wieloma argumentami typu curried, dodaj spację między nimi, np. „someFunction expr1 [expr2]”. @@ -1752,6 +1762,11 @@ Używanie kodu z możliwością wznowienia lub automatów stanów z możliwością wznowienia wymaga parametru /langversion: wersja zapoznawcza + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization Nie można wywołać „{0}” — metody ustawiającej dla właściwości tylko do inicjowania. Zamiast tego użyj inicjowania obiektu. Zobacz https://aka.ms/fsharp-assigning-values-to-properties-at-initialization @@ -1762,6 +1777,11 @@ Nie można dodać powiązań statycznych do rozszerzeń wewnętrznych. Zamiast tego rozważ użycie „statycznego elementu członkowskiego”. + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. Jeśli typ unii wieloskładnikowej jest strukturą, wszystkie pola o tej samej nazwie muszą być tego samego typu. Ta reguła ma zastosowanie również do wygenerowanej nazwy „item” w przypadku pól bez nazwy. diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index ea5a6181948..721f6059569 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -1557,6 +1557,11 @@ Restrição inválida. Os formulários de restrição válidos incluem \"'T :> ISomeInterface\" para restrições de interface e \"SomeConstrainingType<'T>\" para auto-restrições. Confira https://aka.ms/fsharp-type-constraints. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions O uso de '[<Struct>]' em valores, funções e métodos somente é permitido em definições de padrões ativos parciais @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. A sintaxe '[expr1][expr2]' é ambígua quando usada como um argumento. Consulte https://aka.ms/fsharp-index-notation. Se você pretende indexar ou colocar em fatias, deve usar '(expr1).[expr2]' na posição do argumento. Se chamar uma função com vários argumentos na forma curried, adicione um espaço entre eles, por exemplo, 'someFunction [expr1] [expr2]'. @@ -1752,6 +1762,11 @@ Usar código retomável ou máquinas de estado retomável requer /langversion:preview + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization Não é possível chamar '{0}' – um setter da propriedade somente inicialização, use a inicialização de objeto. Confira https://aka.ms/fsharp-assigning-values-to-properties-at-initialization @@ -1762,6 +1777,11 @@ Associações estáticas não podem ser adicionadas a aumentos extrínsecos. Considere usar um "membro estático". + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. Se um tipo de união multicase for um struct, todos os campos com o mesmo nome deverão ser do mesmo tipo. Essa regra também se aplica ao nome 'Item' gerado no caso de campos sem nome. diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index b997715c857..a9e92fba884 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -1557,6 +1557,11 @@ Недопустимое ограничение. Допустимые формы ограничения включают \"'T:> ISomeInterface\" для ограничений интерфейса и \"SomeConstrainingType<'T>\" для собственных ограничений. См. https://aka.ms/fsharp-type-constraints. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions Использование '[<Struct>]' для значений, функций и методов разрешено только для определений частичных активных шаблонов @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. Синтаксис "expr1[expr2]" неоднозначен при использовании в качестве аргумента. См. https://aka.ms/fsharp-index-notation. Если вы намереваетесь индексировать или разрезать, необходимо использовать "expr1.[expr2]" в позиции аргумента. При вызове функции с несколькими каррированными аргументами добавьте пробел между ними, например "someFunction expr1 [expr2]". @@ -1752,6 +1762,11 @@ Для использования возобновляемого кода или возобновляемых конечных автоматов требуется /langversion:preview + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization Не удается вызвать '{0}' — установщик для свойства только для инициализации, вместо этого используйте инициализацию объекта. См. https://aka.ms/fsharp-assigning-values-to-properties-at-initialization. @@ -1762,6 +1777,11 @@ Статические привязки нельзя добавлять к внешним расширениям. Вместо этого рекомендуется использовать "static member". + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. Если тип объединения нескольких регистров является структурой, то все поля с одинаковым именем должны быть одного типа. Это правило также применяется к сгенерированному имени «Элемент» в случае безымянных полей. diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 7ef128ca435..025e0377d8f 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -1557,6 +1557,11 @@ Geçersiz kısıtlama. Geçerli kısıtlama formları arabirim kısıtlamaları için \"'T :> ISomeInterface\" ve kendi kendine kısıtlamalar için \"SomeConstrainingType<'T>\" içerir. Bkz. https://aka.ms/fsharp-type-constraints. + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions Değerler, işlevler ve yöntemler üzerinde '[<Struct>]' kullanımına yalnızca kısmi etkin model tanımlarında izin verilir @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. Söz dizimi “expr1[expr2]” artık dizin oluşturma için ayrılmıştır ve bağımsız değişken olarak kullanıldığında belirsizdir. https://aka.ms/fsharp-index-notation'a bakın. Dizin oluşturmayı veya dilimlemeyi düşünüyorsanız, bağımsız değişken konumunda “expr1.[expr2]” kullanmalısınız. Birden çok curry bağımsız değişkenli bir işlev çağırıyorsanız, aralarına bir boşluk ekleyin, örn. “someFunction expr1 [expr2]”. @@ -1752,6 +1762,11 @@ Sürdürülebilir kod veya sürdürülebilir durum makinelerini kullanmak için /langversion:preview gerekir + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization Yalnızca başlatma özelliği için ayarlayıcı olan '{0}' çağrılamaz, lütfen bunun yerine nesne başlatmayı kullanın. bkz. https://aka.ms/fsharp-assigning-values-to-properties-at-initialization @@ -1762,6 +1777,11 @@ Statik bağlamalar dış genişletmelere eklenemez. Bunun yerine 'static member' kullanmayı düşünün. + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. Çok durumlu bir birleşim türü bir yapıysa, aynı ada sahip tüm alanların aynı türde olması gerekir. Bu kural adlandırılmamış alanlar olması durumunda oluşturulan ‘Öğe’ adı için de geçerlidir. diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 9a008a0bb89..e13859956fa 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -1557,6 +1557,11 @@ 约束无效。有效的约束形式包括 \"'T :> ISomeInterface\" (接口约束)和 \"SomeConstrainingType<'T>\" (自我约束)。请参阅 https://aka.ms/fsharp-type-constraints。 + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions 只允许在部分活动模式定义中对值、函数和方法使用 "[<Struct>]" @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. 语法“expr1[expr2]”用作参数时不明确。请参阅 https://aka.ms/fsharp-index-notation。如果要索引或切片,则必须在参数位置使用“expr1.[expr2]”。如果使用多个扩充参数调用函数,请在它们之间添加空格,例如“someFunction expr1 [expr2]”。 @@ -1752,6 +1762,11 @@ 使用可恢复代码或可恢复状态机需要 /langversion:preview + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization 无法调用 "{0}",它是仅限 init 属性的资源库,请改用对象初始化。请参阅 https://aka.ms/fsharp-assigning-values-to-properties-at-initialization @@ -1762,6 +1777,11 @@ 无法将静态绑定添加到外部增强。请考虑改用 "static member"。 + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. 如果多重联合类型是结构,则具有相同名称的所有字段必须具有相同的类型。对于未命名字段,此规则也适用于生成的“Item”名称。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 27b200ce286..593121fea2c 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -1557,6 +1557,11 @@ 限制無效。有效的限制式表單包括 \「'T :>ISomeInterface\」介面限制和 \」SomeConstrainingType<'T>\」自我限制式。請參閱 https://aka.ms/fsharp-type-constraints。 + + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead. + + The use of '[<Struct>]' on values, functions and methods is only allowed on partial active pattern definitions 只允許在部分現用模式定義上對值、函式和方法使用 '[<Struct>]' @@ -1657,6 +1662,11 @@ The 'nullness checking' language feature is not enabled. This use of a nullness checking construct will be ignored. + + Only structs may be given the 'ExtendedLayoutAttribute' + Only structs may be given the 'ExtendedLayoutAttribute' + + The syntax 'expr1[expr2]' is ambiguous when used as an argument. See https://aka.ms/fsharp-index-notation. If you intend indexing or slicing then you must use 'expr1.[expr2]' in argument position. If calling a function with multiple curried arguments, add a space between them, e.g. 'someFunction expr1 [expr2]'. 語法 'expr1[expr2]' 用作引數時不明確。請參閱 https://aka.ms/fsharp-index-notation。如果您要編製索引或切割,則必須在引數位置使用 'expr1.[expr2]'。如果要呼叫具有多個調用引數的函式,請在它們之間新增空格,例如 'someFunction expr1 [expr2]'。 @@ -1752,6 +1762,11 @@ 使用可繼續的程式碼或可繼續的狀態機器需要 /langversion:preview + + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + The target runtime does not support extended layout types. ExtendedLayoutAttribute requires a newer runtime. + + Cannot call '{0}' - a setter for init-only property, please use object initialization instead. See https://aka.ms/fsharp-assigning-values-to-properties-at-initialization 無法呼叫 '{0}' - 僅初始化屬性的 setter,請改為使用物件初始化。請參閱 https://aka.ms/fsharp-assigning-values-to-properties-at-initialization @@ -1762,6 +1777,11 @@ 無法將靜態繫結新增至外來擴充。請考慮改用「靜態成員」。 + + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type + + If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields. 如果多寫聯集類型是結構,則所有具有相同名稱的欄位都必須是相同的類型。此規則也適用於未命名欄位時產生的 'Item' 名稱。 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs index 2b51fbf11f7..952a6787703 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/Basic.fs @@ -380,6 +380,81 @@ module CustomAttributes_Basic = """ ] + + // SOURCE=ExtendedLayout.fs + [] + let ``ExtendedLayout_fs`` compilation = + compilation + |> verifyCompileAndRun + |> shouldSucceed + + // SOURCE=ExtendedLayout_IL.fs - Verify IL has correct TypeAttributes + [] + let ``ExtendedLayout_IL_fs`` compilation = + compilation + |> asLibrary + |> withOptions ["--nowarn:988"] + |> compile + |> shouldSucceed + |> verifyIL [ + """ + .class public extended ansi sealed beforefieldinit Test.MyExtendedStruct + extends [runtime]System.ValueType + { + .custom instance void System.Runtime.InteropServices.ExtendedLayoutAttribute::.ctor(valuetype System.Runtime.InteropServices.ExtendedLayoutKind) = ( 01 00 00 00 00 00 00 00 ) + .field public int32 X + .field public float64 Y + """ + ] + + // SOURCE=E_ExtendedLayout_OnClass.fs + [] + let ``E_ExtendedLayout_OnClass_fs`` compilation = + compilation + |> verifyCompile + |> shouldFail + |> withSingleDiagnostic (Error 3881, Line 6, Col 6, Line 6, Col 18, "Only structs may be given the 'ExtendedLayoutAttribute'") + + // SOURCE=E_ExtendedLayout_OnInterface.fs + [] + let ``E_ExtendedLayout_OnInterface_fs`` compilation = + compilation + |> verifyCompile + |> shouldFail + |> withSingleDiagnostic (Error 3881, Line 6, Col 6, Line 6, Col 23, "Only structs may be given the 'ExtendedLayoutAttribute'") + + // SOURCE=E_ExtendedLayout_OnDelegate.fs + [] + let ``E_ExtendedLayout_OnDelegate_fs`` compilation = + compilation + |> verifyCompile + |> shouldFail + |> withSingleDiagnostic (Error 3881, Line 6, Col 6, Line 6, Col 21, "Only structs may be given the 'ExtendedLayoutAttribute'") + + // SOURCE=E_ExtendedLayout_WithStructLayout.fs + [] + let ``E_ExtendedLayout_WithStructLayout_fs`` compilation = + compilation + |> verifyCompile + |> shouldFail + |> withSingleDiagnostic (Error 3879, Line 8, Col 6, Line 8, Col 24, "The attributes 'StructLayoutAttribute' and 'ExtendedLayoutAttribute' cannot be used together on the same type") + + // SOURCE=E_ExtendedLayout_FieldOffset.fs + [] + let ``E_ExtendedLayout_FieldOffset_fs`` compilation = + compilation + |> verifyCompile + |> shouldFail + |> withSingleDiagnostic (Error 1211, Line 10, Col 9, Line 10, Col 24, "The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)") + + // SOURCE=E_StructLayout_Extended.fs + [] + let ``E_StructLayout_Extended_fs`` compilation = + compilation + |> verifyCompile + |> shouldFail + |> withSingleDiagnostic (Error 3882, Line 6, Col 16, Line 6, Col 37, "LayoutKind value 1 (Extended) cannot be specified via StructLayoutAttribute. Use ExtendedLayoutAttribute instead.") + [] let ``StructLayoutAttribute has size=1 for struct DUs with no instance fields`` () = Fsx """ diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_FieldOffset.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_FieldOffset.fs new file mode 100644 index 00000000000..07cf6d7d439 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_FieldOffset.fs @@ -0,0 +1,23 @@ +// FieldOffsetAttribute on ExtendedLayout struct field should fail +namespace System.Runtime.InteropServices + +// Mock ExtendedLayoutAttribute and ExtendedLayoutKind for testing +type ExtendedLayoutKind = + | CStruct = 0 + | CUnion = 1 + +[] +type ExtendedLayoutAttribute(kind: ExtendedLayoutKind) = + inherit System.Attribute() + member _.Kind = kind + +namespace Test + +open System.Runtime.InteropServices + +[] +type InvalidFieldOffset = + struct + [] + val mutable X: int + end diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_OnClass.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_OnClass.fs new file mode 100644 index 00000000000..5fb6b77d530 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_OnClass.fs @@ -0,0 +1,20 @@ +// ExtendedLayoutAttribute on class should fail +namespace System.Runtime.InteropServices + +// Mock ExtendedLayoutAttribute and ExtendedLayoutKind for testing +type ExtendedLayoutKind = + | CStruct = 0 + | CUnion = 1 + +[] +type ExtendedLayoutAttribute(kind: ExtendedLayoutKind) = + inherit System.Attribute() + member _.Kind = kind + +namespace Test + +open System.Runtime.InteropServices + +[] +type InvalidClass() = + member val X = 0 with get, set diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_OnDelegate.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_OnDelegate.fs new file mode 100644 index 00000000000..d3a8e1409ba --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_OnDelegate.fs @@ -0,0 +1,19 @@ +// ExtendedLayoutAttribute on delegate should fail +namespace System.Runtime.InteropServices + +// Mock ExtendedLayoutAttribute and ExtendedLayoutKind for testing +type ExtendedLayoutKind = + | CStruct = 0 + | CUnion = 1 + +[] +type ExtendedLayoutAttribute(kind: ExtendedLayoutKind) = + inherit System.Attribute() + member _.Kind = kind + +namespace Test + +open System.Runtime.InteropServices + +[] +type InvalidDelegate = delegate of int -> int diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_OnInterface.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_OnInterface.fs new file mode 100644 index 00000000000..9ef11be935e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_OnInterface.fs @@ -0,0 +1,20 @@ +// ExtendedLayoutAttribute on interface should fail +namespace System.Runtime.InteropServices + +// Mock ExtendedLayoutAttribute and ExtendedLayoutKind for testing +type ExtendedLayoutKind = + | CStruct = 0 + | CUnion = 1 + +[] +type ExtendedLayoutAttribute(kind: ExtendedLayoutKind) = + inherit System.Attribute() + member _.Kind = kind + +namespace Test + +open System.Runtime.InteropServices + +[] +type IInvalidInterface = + abstract member DoSomething: unit -> unit diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_WithStructLayout.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_WithStructLayout.fs new file mode 100644 index 00000000000..be0957e3846 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_ExtendedLayout_WithStructLayout.fs @@ -0,0 +1,23 @@ +// ExtendedLayoutAttribute + StructLayoutAttribute should fail +namespace System.Runtime.InteropServices + +// Mock ExtendedLayoutAttribute and ExtendedLayoutKind for testing +type ExtendedLayoutKind = + | CStruct = 0 + | CUnion = 1 + +[] +type ExtendedLayoutAttribute(kind: ExtendedLayoutKind) = + inherit System.Attribute() + member _.Kind = kind + +namespace Test + +open System.Runtime.InteropServices + +[] +[] +type ConflictingStruct = + struct + val mutable X: int + end diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_StructLayout_Extended.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_StructLayout_Extended.fs new file mode 100644 index 00000000000..fc0d9bee1e1 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/E_StructLayout_Extended.fs @@ -0,0 +1,10 @@ +// LayoutKind.Extended (value 1) via StructLayoutAttribute should fail +namespace Test + +open System.Runtime.InteropServices + +[(1))>] +type InvalidExtendedViaStructLayout = + struct + val mutable X: int + end diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/ExtendedLayout.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/ExtendedLayout.fs new file mode 100644 index 00000000000..d1da756af00 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/ExtendedLayout.fs @@ -0,0 +1,33 @@ +// Test: ExtendedLayoutAttribute on struct compiles successfully +namespace System.Runtime.InteropServices + +// Mock ExtendedLayoutAttribute and ExtendedLayoutKind for testing +// (will be replaced by real runtime types when available) +type ExtendedLayoutKind = + | CStruct = 0 + | CUnion = 1 + +[] +type ExtendedLayoutAttribute(kind: ExtendedLayoutKind) = + inherit System.Attribute() + member _.Kind = kind + +namespace Test + +open System.Runtime.InteropServices + +[] +type ValidStruct = + struct + val mutable X: int + val mutable Y: int + end + +// Entry point +module Program = + [] + let main _ = + let mutable s = ValidStruct() + s.X <- 42 + s.Y <- 24 + if s.X = 42 && s.Y = 24 then 0 else 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/ExtendedLayout_IL.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/ExtendedLayout_IL.fs new file mode 100644 index 00000000000..5f78abb296c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/Basic/ExtendedLayout_IL.fs @@ -0,0 +1,30 @@ +// Test: Verify IL for ExtendedLayoutAttribute +namespace System.Runtime.InteropServices + +// Mock ExtendedLayoutAttribute and ExtendedLayoutKind for testing +type ExtendedLayoutKind = + | CStruct = 0 + | CUnion = 1 + +[] +type ExtendedLayoutAttribute(kind: ExtendedLayoutKind) = + inherit System.Attribute() + member _.Kind = kind + +namespace Test + +open System.Runtime.InteropServices + +[] +type MyExtendedStruct = + struct + val mutable X: int + val mutable Y: float + end + +module Main = + let test () = + let mutable s = MyExtendedStruct() + s.X <- 10 + s.Y <- 20.0 + ()