From 205b9a8908e71e5c158cc211af41b3bc7b1c1cf3 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Tue, 12 Jul 2022 16:48:04 +0100 Subject: [PATCH] Mark backing fields as CompilerGenerated (fixes serialization of fields in FSI multiemit) (#13494) --- VisualFSharp.sln | 10 +- src/Compiler/CodeGen/IlxGen.fs | 8 +- .../GenericComparison/Compare06.fsx.il.bsl | 2 + .../GenericComparison/Equals05.fsx.il.bsl | 2 + .../GenericComparison/Hash08.fsx.il.bsl | 2 + .../EmittedIL/Misc/AnonRecd.fs.il.bsl | 2 + .../TestFunction17.fs.il.debug.bsl | 2 + .../TestFunction17.fs.il.release.bsl | 2 + .../TestFunction24.fs.il.debug.bsl | 2 + .../TestFunction24.fs.il.release.bsl | 2 + tests/FSharp.Test.Utilities/TestFramework.fs | 4 +- .../core/printing/output.1000.stdout.bsl | 53 +++++++++ .../core/printing/output.200.stdout.bsl | 53 +++++++++ .../fsharp/core/printing/output.47.stderr.bsl | 108 ++++++++++++++++++ .../fsharp/core/printing/output.47.stdout.bsl | 2 +- .../core/printing/output.multiemit.stdout.bsl | 53 +++++++++ .../core/printing/output.off.stdout.bsl | 53 +++++++++ .../core/printing/output.quiet.stdout.bsl | 3 + tests/fsharp/core/printing/output.stdout.bsl | 53 +++++++++ tests/fsharp/core/printing/test.fsx | 40 +++++++ tests/fsharp/tests.fs | 11 +- 21 files changed, 456 insertions(+), 11 deletions(-) diff --git a/VisualFSharp.sln b/VisualFSharp.sln index c99c08c29c5..fa4c376c818 100644 --- a/VisualFSharp.sln +++ b/VisualFSharp.sln @@ -84,6 +84,14 @@ EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Test.Utilities", "tests\FSharp.Test.Utilities\FSharp.Test.Utilities.fsproj", "{60D275B0-B14A-41CB-A1B2-E815A7448FCB}" EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpSuite.Tests", "tests\fsharp\FSharpSuite.Tests.fsproj", "{C163E892-5BF7-4B59-AA99-B0E8079C67C4}" + ProjectSection(ProjectDependencies) = postProject + {0973C362-585C-4838-9459-D7E45C6B784B} = {0973C362-585C-4838-9459-D7E45C6B784B} + {37EB3E54-ABC6-4CF5-8273-7CE4B61A42C1} = {37EB3E54-ABC6-4CF5-8273-7CE4B61A42C1} + {511C95D9-3BA6-451F-B6F8-F033F40878A5} = {511C95D9-3BA6-451F-B6F8-F033F40878A5} + {597D9896-4B90-4E9E-9C99-445C2CB9FF60} = {597D9896-4B90-4E9E-9C99-445C2CB9FF60} + {E54456F4-D51A-4334-B225-92EBBED92B40} = {E54456F4-D51A-4334-B225-92EBBED92B40} + {EB015235-1E07-4CDA-9CC6-3FBCC27910D1} = {EB015235-1E07-4CDA-9CC6-3FBCC27910D1} + EndProjectSection EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.UnitTests", "tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj", "{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}" EndProject @@ -149,8 +157,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Service", " EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Service.Tests", "tests\FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj", "{14F3D3D6-5C8E-43C2-98A2-17EA704D4DEA}" ProjectSection(ProjectDependencies) = postProject - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B} = {FF76BD3C-5E0A-4752-B6C3-044F6E15719B} {887630A3-4B1D-40EA-B8B3-2D842E9C40DB} = {887630A3-4B1D-40EA-B8B3-2D842E9C40DB} + {FF76BD3C-5E0A-4752-B6C3-044F6E15719B} = {FF76BD3C-5E0A-4752-B6C3-044F6E15719B} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualFSharpDebug", "vsintegration\Vsix\VisualFSharpFull\VisualFSharpDebug.csproj", "{A422D673-8E3B-4924-821B-DD3174173426}" diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 361f9078495..63c543cfed2 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -2073,7 +2073,7 @@ type AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbu mkILFields [ for _, fldName, fldTy in flds -> - // Don't hide fields when splitting to multiple assemblies. + let access = if cenv.options.isInteractive && cenv.options.fsiMultiAssemblyEmit then ILMemberAccess.Public @@ -2081,7 +2081,8 @@ type AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbu ILMemberAccess.Private let fdef = mkILInstanceField (fldName, fldTy, None, access) - fdef.With(customAttrs = mkILCustomAttrs [ g.DebuggerBrowsableNeverAttribute ]) + let attrs = [ g.CompilerGeneratedAttribute; g.DebuggerBrowsableNeverAttribute ] + fdef.With(customAttrs = mkILCustomAttrs attrs) ] // Generate property definitions for the fields compiled as properties @@ -10676,7 +10677,8 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = let extraAttribs = match tyconRepr with - | TFSharpRecdRepr _ when not useGenuineField -> [ g.DebuggerBrowsableNeverAttribute ] // hide fields in records in debug display + | TFSharpRecdRepr _ when not useGenuineField -> + [ g.CompilerGeneratedAttribute; g.DebuggerBrowsableNeverAttribute ] | _ -> [] // don't hide fields in classes in debug display let access = ComputeMemberAccess isFieldHidden diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.bsl index 30f333f36c8..b7aea842a83 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.bsl @@ -66,8 +66,10 @@ { .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 ) .field assembly int32 key1@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 key2@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_key1() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.bsl index 78d4df8f587..34ab1b1e85c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.bsl @@ -66,8 +66,10 @@ { .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 ) .field assembly int32 key1@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 key2@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_key1() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.bsl index b23967fe77b..c94a00b3427 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.bsl @@ -66,8 +66,10 @@ { .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 ) .field assembly int32 key1@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 key2@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_key1() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.bsl index 0b4d87cf293..31112ecefe0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.bsl @@ -99,8 +99,10 @@ .custom instance void [mscorlib]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 ) .field private !'j__TPar' A@ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field private !'j__TPar' B@ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public specialname rtspecialname instance void .ctor(!'j__TPar' A, diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.debug.bsl index ded94e51adc..de3a5062203 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.debug.bsl @@ -62,8 +62,10 @@ { .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 ) .field assembly int32 x@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 y@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_x() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.release.bsl index d34dc778f67..17ff542c4ed 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.release.bsl @@ -62,8 +62,10 @@ { .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 ) .field assembly int32 x@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field assembly int32 y@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_x() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.debug.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.debug.bsl index 1139c1cdb0d..6047356613b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.debug.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.debug.bsl @@ -62,8 +62,10 @@ { .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 ) .field public int32 x@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field public int32 y@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_x() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.release.bsl index 51afb9c71dd..97404f6bb4a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.release.bsl @@ -62,8 +62,10 @@ { .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 ) .field public int32 x@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field public int32 y@ + .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [System.Runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .method public hidebysig specialname instance int32 get_x() cil managed diff --git a/tests/FSharp.Test.Utilities/TestFramework.fs b/tests/FSharp.Test.Utilities/TestFramework.fs index f2d93c0513c..60aac52400a 100644 --- a/tests/FSharp.Test.Utilities/TestFramework.fs +++ b/tests/FSharp.Test.Utilities/TestFramework.fs @@ -652,8 +652,8 @@ let diff normalize path1 path2 = if x >= 0 then line.Substring(x+cwd.Length) else line else line - let line1 = normalizePath lines1[i] - let line2 = normalizePath lines2[i] + let line1 = lines1[i] |> normalizePath + let line2 = lines2[i] |> normalizePath if line1 <> line2 then append <| sprintf "diff between [%s] and [%s]" path1 path2 diff --git a/tests/fsharp/core/printing/output.1000.stdout.bsl b/tests/fsharp/core/printing/output.1000.stdout.bsl index cc3eaef035e..cdf91519c8d 100644 --- a/tests/fsharp/core/printing/output.1000.stdout.bsl +++ b/tests/fsharp/core/printing/output.1000.stdout.bsl @@ -2764,4 +2764,57 @@ val ShortName: string = "hi" > val list2: int list = [1] +module FSI_0317. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit = () + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit = () + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0324.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string = "{"ImmutableField3":12}" + +> val test3b: R3 = { ImmutableField3 = 12 } + +> val test3c: string = "{"ImmutableField3":13}" + +> val test3d: R3 = { ImmutableField3 = 13 } + +> type R4 = + { mutable MutableField4: int } +val test4a: string = "{"MutableField4":15}" + +> val test4b: R4 = { MutableField4 = 15 } + +> val test4c: string = "{"MutableField4":16}" + +> val test4d: R4 = { MutableField4 = 16 } + +> type R5 = {| AnonRecordField5: int |} +val test5a: string = "{"AnonRecordField5":17}" + +> val test5b: R5 = { AnonRecordField5 = 17 } + +> val test5c: string = "{"AnonRecordField5":18}" + +> val test5d: R5 = { AnonRecordField5 = 18 } + > > > diff --git a/tests/fsharp/core/printing/output.200.stdout.bsl b/tests/fsharp/core/printing/output.200.stdout.bsl index 6d1b4c6dfc9..cb22322c94a 100644 --- a/tests/fsharp/core/printing/output.200.stdout.bsl +++ b/tests/fsharp/core/printing/output.200.stdout.bsl @@ -2009,4 +2009,57 @@ val ShortName: string = "hi" > val list2: int list = [1] +module FSI_0317. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit = () + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit = () + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0324.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string = "{"ImmutableField3":12}" + +> val test3b: R3 = { ImmutableField3 = 12 } + +> val test3c: string = "{"ImmutableField3":13}" + +> val test3d: R3 = { ImmutableField3 = 13 } + +> type R4 = + { mutable MutableField4: int } +val test4a: string = "{"MutableField4":15}" + +> val test4b: R4 = { MutableField4 = 15 } + +> val test4c: string = "{"MutableField4":16}" + +> val test4d: R4 = { MutableField4 = 16 } + +> type R5 = {| AnonRecordField5: int |} +val test5a: string = "{"AnonRecordField5":17}" + +> val test5b: R5 = { AnonRecordField5 = 17 } + +> val test5c: string = "{"AnonRecordField5":18}" + +> val test5d: R5 = { AnonRecordField5 = 18 } + > > > diff --git a/tests/fsharp/core/printing/output.47.stderr.bsl b/tests/fsharp/core/printing/output.47.stderr.bsl index 4d3209ca246..3e98bca2fc4 100644 --- a/tests/fsharp/core/printing/output.47.stderr.bsl +++ b/tests/fsharp/core/printing/output.47.stderr.bsl @@ -334,3 +334,111 @@ stdin(838,6): error FS1210: Active pattern '|A|B|' has a result type containing stdin(844,6): error FS1209: Active pattern '|A|B|' is not a function + + #r "nuget:Newtonsoft.Json, 13.0.1" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +stdin(1117,1): error FS3302: The 'package management' feature requires language version 5.0 or above + + + JsonConvert.SerializeObject { ImmutableField0 = 7 } + ^^^^^^^^^^^ + +stdin(1122,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + JsonConvert.SerializeObject { MutableField1 = 8 } |> printfn "%s";; + ^^^^^^^^^^^ + +stdin(1126,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + JsonConvert.SerializeObject { MutableField1 = 9 } + ^^^^^^^^^^^ + +stdin(1128,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + JsonConvert.SerializeObject {| AnonRecordField2 = 10 |} |> printfn "%s";; + ^^^^^^^^^^^ + +stdin(1131,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + JsonConvert.SerializeObject {| AnonRecordField2 = 11 |} + ^^^^^^^^^^^ + +stdin(1133,1): error FS0039: The value, namespace, type or module 'JsonConvert' is not defined. + + + #r "nuget: System.Text.Json" + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +stdin(1136,1): error FS3302: The 'package management' feature requires language version 5.0 or above + + + let test3b = JsonSerializer.Deserialize test3a;; + -------------^^^^^^^^^^^^^^ + +stdin(1140,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test3c = JsonSerializer.Serialize { ImmutableField3 = 13 };; + -------------^^^^^^^^^^^^^^ + +stdin(1141,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test3d = JsonSerializer.Deserialize test3c;; + -------------^^^^^^^^^^^^^^ + +stdin(1142,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test4a = JsonSerializer.Serialize { MutableField4 = 15 };; + -------------^^^^^^^^^^^^^^ + +stdin(1145,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test4b = JsonSerializer.Deserialize test4a;; + -------------^^^^^^^^^^^^^^ + +stdin(1146,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test4c = JsonSerializer.Serialize { MutableField4 = 16 };; + -------------^^^^^^^^^^^^^^ + +stdin(1147,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test4d = JsonSerializer.Deserialize test4c;; + -------------^^^^^^^^^^^^^^ + +stdin(1148,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test5a = JsonSerializer.Serialize {| AnonRecordField5 = 17 |};; + -------------^^^^^^^^^^^^^^ + +stdin(1151,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test5b = JsonSerializer.Deserialize test5a;; + -------------^^^^^^^^^^^^^^ + +stdin(1152,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test5c = JsonSerializer.Serialize {| AnonRecordField5 = 18 |};; + -------------^^^^^^^^^^^^^^ + +stdin(1153,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + + + let test5d = JsonSerializer.Deserialize test5c;; + -------------^^^^^^^^^^^^^^ + +stdin(1154,14): error FS0039: The value, namespace, type or module 'JsonSerializer' is not defined. + diff --git a/tests/fsharp/core/printing/output.47.stdout.bsl b/tests/fsharp/core/printing/output.47.stdout.bsl index af2d597eaad..b6f38074b36 100644 --- a/tests/fsharp/core/printing/output.47.stdout.bsl +++ b/tests/fsharp/core/printing/output.47.stdout.bsl @@ -6309,4 +6309,4 @@ val ShortName: string = "hi" > val list2: int list = [1] -> > > +> > > > > > > > > > > > > > > > > > > > > diff --git a/tests/fsharp/core/printing/output.multiemit.stdout.bsl b/tests/fsharp/core/printing/output.multiemit.stdout.bsl index acdcf6c63d8..9183285f872 100644 --- a/tests/fsharp/core/printing/output.multiemit.stdout.bsl +++ b/tests/fsharp/core/printing/output.multiemit.stdout.bsl @@ -6311,4 +6311,57 @@ val ShortName: string = "hi" > val list2: int list = [1] +module FSI_0316. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit = () + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit = () + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0323.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string = "{"ImmutableField3":12}" + +> val test3b: R3 = { ImmutableField3 = 12 } + +> val test3c: string = "{"ImmutableField3":13}" + +> val test3d: R3 = { ImmutableField3 = 13 } + +> type R4 = + { mutable MutableField4: int } +val test4a: string = "{"MutableField4":15}" + +> val test4b: R4 = { MutableField4 = 15 } + +> val test4c: string = "{"MutableField4":16}" + +> val test4d: R4 = { MutableField4 = 16 } + +> type R5 = {| AnonRecordField5: int |} +val test5a: string = "{"AnonRecordField5":17}" + +> val test5b: R5 = { AnonRecordField5 = 17 } + +> val test5c: string = "{"AnonRecordField5":18}" + +> val test5d: R5 = { AnonRecordField5 = 18 } + > > > diff --git a/tests/fsharp/core/printing/output.off.stdout.bsl b/tests/fsharp/core/printing/output.off.stdout.bsl index 2bd43f77f8f..586d7a58860 100644 --- a/tests/fsharp/core/printing/output.off.stdout.bsl +++ b/tests/fsharp/core/printing/output.off.stdout.bsl @@ -1778,4 +1778,57 @@ val ShortName: string = "hi" > val list2: int list +module FSI_0317. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0324.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string + +> val test3b: R3 + +> val test3c: string + +> val test3d: R3 + +> type R4 = + { mutable MutableField4: int } +val test4a: string + +> val test4b: R4 + +> val test4c: string + +> val test4d: R4 + +> type R5 = {| AnonRecordField5: int |} +val test5a: string + +> val test5b: R5 + +> val test5c: string + +> val test5d: R5 + > > > diff --git a/tests/fsharp/core/printing/output.quiet.stdout.bsl b/tests/fsharp/core/printing/output.quiet.stdout.bsl index 26683b52103..d8d778aca70 100644 --- a/tests/fsharp/core/printing/output.quiet.stdout.bsl +++ b/tests/fsharp/core/printing/output.quiet.stdout.bsl @@ -11,3 +11,6 @@ [Building 5 3...done] Expect ABC = ABC Expect ABC = ABC +{"ImmutableField0":6} +{"MutableField1":8} +{"AnonRecordField2":10} diff --git a/tests/fsharp/core/printing/output.stdout.bsl b/tests/fsharp/core/printing/output.stdout.bsl index acdcf6c63d8..9183285f872 100644 --- a/tests/fsharp/core/printing/output.stdout.bsl +++ b/tests/fsharp/core/printing/output.stdout.bsl @@ -6311,4 +6311,57 @@ val ShortName: string = "hi" > val list2: int list = [1] +module FSI_0316. + D27805741a339047ef3ed7a2ca8faae3c17e6ef2371984011e49a6c9c3286641 + +{"ImmutableField0":6} +type R1 = + { ImmutableField0: int } +val it: unit = () + +> val it: R1 = { ImmutableField0 = 7 } + +> {"MutableField1":8} +type R2 = + { mutable MutableField1: int } +val it: unit = () + +> val it: R2 = { MutableField1 = 9 } + +> {"AnonRecordField2":10} +val it: unit = () + +> val it: {| AnonRecordField2: int |} = { AnonRecordField2 = 11 } + +module FSI_0323.Project.fsproj + +type R3 = + { ImmutableField3: int } +val test3a: string = "{"ImmutableField3":12}" + +> val test3b: R3 = { ImmutableField3 = 12 } + +> val test3c: string = "{"ImmutableField3":13}" + +> val test3d: R3 = { ImmutableField3 = 13 } + +> type R4 = + { mutable MutableField4: int } +val test4a: string = "{"MutableField4":15}" + +> val test4b: R4 = { MutableField4 = 15 } + +> val test4c: string = "{"MutableField4":16}" + +> val test4d: R4 = { MutableField4 = 16 } + +> type R5 = {| AnonRecordField5: int |} +val test5a: string = "{"AnonRecordField5":17}" + +> val test5b: R5 = { AnonRecordField5 = 17 } + +> val test5c: string = "{"AnonRecordField5":18}" + +> val test5d: R5 = { AnonRecordField5 = 18 } + > > > diff --git a/tests/fsharp/core/printing/test.fsx b/tests/fsharp/core/printing/test.fsx index 1bd15e348f8..c0943540b49 100644 --- a/tests/fsharp/core/printing/test.fsx +++ b/tests/fsharp/core/printing/test.fsx @@ -1114,6 +1114,46 @@ let list = [{ A = 1; B = "a" }];; let list2 = [ for x in list do x.A ];; +#r "nuget:Newtonsoft.Json, 13.0.1" +type R1 = { ImmutableField0: int } +open Newtonsoft.Json +JsonConvert.SerializeObject { ImmutableField0 = 6 } |> printfn "%s";; + +JsonConvert.SerializeObject { ImmutableField0 = 7 } +|> JsonConvert.DeserializeObject;; + +type R2 = { mutable MutableField1: int } +JsonConvert.SerializeObject { MutableField1 = 8 } |> printfn "%s";; + +JsonConvert.SerializeObject { MutableField1 = 9 } +|> JsonConvert.DeserializeObject;; + +JsonConvert.SerializeObject {| AnonRecordField2 = 10 |} |> printfn "%s";; + +JsonConvert.SerializeObject {| AnonRecordField2 = 11 |} +|> JsonConvert.DeserializeObject<{| AnonRecordField2 :int |}>;; + +#r "nuget: System.Text.Json" +open System.Text.Json +type R3 = { ImmutableField3: int } +let test3a = JsonSerializer.Serialize { ImmutableField3 = 12 };; +let test3b = JsonSerializer.Deserialize test3a;; +let test3c = JsonSerializer.Serialize { ImmutableField3 = 13 };; +let test3d = JsonSerializer.Deserialize test3c;; + +type R4 = { mutable MutableField4: int } +let test4a = JsonSerializer.Serialize { MutableField4 = 15 };; +let test4b = JsonSerializer.Deserialize test4a;; +let test4c = JsonSerializer.Serialize { MutableField4 = 16 };; +let test4d = JsonSerializer.Deserialize test4c;; + +type R5 = {| AnonRecordField5: int |} +let test5a = JsonSerializer.Serialize {| AnonRecordField5 = 17 |};; +let test5b = JsonSerializer.Deserialize test5a;; +let test5c = JsonSerializer.Serialize {| AnonRecordField5 = 18 |};; +let test5d = JsonSerializer.Deserialize test5c;; + + ;; (* ;; needed, to isolate error regressions *) ;;exit 0;; (* piped in to enable error regressions *) \ No newline at end of file diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index d8c4bd79cc2..d4da2adaf94 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -1060,10 +1060,13 @@ module CoreTests = let rawFileErr = tryCreateTemporaryFileName () ``fsi b 2>c`` "%s --nologo --preferreduilang:en-US %s" fsc_flags_errors_ok flag ("test.fsx", rawFileOut, rawFileErr) - // REM REVIEW: want to normalise CWD paths, not suppress them. - let ``findstr /v`` text = Seq.filter (fun (s: string) -> not <| s.Contains(text)) - let removeCDandHelp from' to' = - File.ReadLines from' |> (``findstr /v`` cfg.Directory) |> (``findstr /v`` "--help' for options") |> (fun lines -> File.WriteAllLines(getfullpath cfg to', lines)) + let removeCDandHelp fromFile toFile = + File.ReadAllLines fromFile + |> Array.filter (fun s -> not (s.Contains(cfg.Directory))) + |> Array.filter (fun s -> not (s.Contains("--help' for options"))) + |> Array.filter (fun s -> not (s.Contains("[Loading"))) + |> Array.filter (fun s -> not (s.Contains("Binding session"))) + |> (fun lines -> File.WriteAllLines(getfullpath cfg toFile, lines)) removeCDandHelp rawFileOut diffFileOut removeCDandHelp rawFileErr diffFileErr