From 307db6afaa3add2751faf9bd166422f76f15db14 Mon Sep 17 00:00:00 2001 From: Alex Berezhnykh Date: Fri, 16 Sep 2022 03:02:57 +0300 Subject: [PATCH 1/6] Don't allow union case unnamed fields in xmldoc --- src/Compiler/Checking/CheckDeclarations.fs | 6 ++++- .../Language/XmlComments.fs | 26 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 0d9b0df134b..7ed01ddda42 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -531,7 +531,11 @@ module TcRecdUnionAndEnumDeclarations = error(Error(FSComp.SR.tcReturnTypesForUnionMustBeSameAsType(), m)) rfields, recordTy - let names = rfields |> List.map (fun f -> f.DisplayNameCore) + let names = rfields + |> Seq.filter (fun f -> not f.rfield_name_generated) + |> Seq.map (fun f -> f.DisplayNameCore) + |> Seq.toList + let xmlDoc = xmldoc.ToXmlDoc(true, Some names) Construct.NewUnionCase id rfields recordTy attrs xmlDoc vis diff --git a/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs b/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs index fc554d1fcc9..356b8727c9f 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs @@ -206,4 +206,28 @@ module M = |> ignoreWarnings |> compile |> shouldSucceed - |> withDiagnostics [ ] \ No newline at end of file + |> withDiagnostics [ ] + + [] + let ``Union field - unnamed 01`` () = + Fsx""" + type A = + /// A + /// Item + | A of int + """ + |> withXmlCommentChecking + |> compile + |> withDiagnostics [ Warning 3390, Line 3, Col 13, Line 4, Col 48, "This XML comment is invalid: unknown parameter 'Item'" ] + + [] + let ``Union field - unnamed 02`` () = + Fsx""" + type A = + /// A + /// a + | A of int * a: int + """ + |> withXmlCommentChecking + |> compile + |> withDiagnostics [ ] From aa3db97a49452db638406af86434e18949e45fcd Mon Sep 17 00:00:00 2001 From: Alex Berezhnykh Date: Fri, 16 Sep 2022 03:04:01 +0300 Subject: [PATCH 2/6] . --- tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs b/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs index 356b8727c9f..c0378ae4208 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs @@ -230,4 +230,4 @@ module M = """ |> withXmlCommentChecking |> compile - |> withDiagnostics [ ] + |> withDiagnostics [ ] From be3950f5ad7576aa06bd1dd3f29ccb4645b1a1f7 Mon Sep 17 00:00:00 2001 From: Alex Berezhnykh Date: Fri, 16 Sep 2022 04:25:54 +0300 Subject: [PATCH 3/6] fix doc --- src/FSharp.Core/prim-types.fsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FSharp.Core/prim-types.fsi b/src/FSharp.Core/prim-types.fsi index ccac892f8fc..85ba2e913a9 100644 --- a/src/FSharp.Core/prim-types.fsi +++ b/src/FSharp.Core/prim-types.fsi @@ -2438,10 +2438,10 @@ namespace Microsoft.FSharp.Core /// The representation of "Value of type 'T" /// - /// The input value. + /// The input value. /// /// An option representing the value. - | ValueSome: 'T -> 'T voption + | ValueSome: value:'T -> 'T voption /// Get the value of a 'ValueSome' option. An InvalidOperationException is raised if the option is 'ValueNone'. member Value: 'T From 578030bed518b01120f343e1af3acbb862c04ea3 Mon Sep 17 00:00:00 2001 From: Alex Berezhnykh Date: Fri, 16 Sep 2022 04:38:38 +0300 Subject: [PATCH 4/6] fix --- src/FSharp.Core/prim-types.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs index 1178620d63b..5f2a6b641e3 100644 --- a/src/FSharp.Core/prim-types.fs +++ b/src/FSharp.Core/prim-types.fs @@ -3854,7 +3854,7 @@ namespace Microsoft.FSharp.Core [] type ValueOption<'T> = | ValueNone : 'T voption - | ValueSome : 'T -> 'T voption + | ValueSome : value: 'T -> 'T voption member x.Value = match x with ValueSome x -> x | ValueNone -> raise (new InvalidOperationException("ValueOption.Value")) From 3fa3953b89894e608424216c04b733f7ac33a3c8 Mon Sep 17 00:00:00 2001 From: Alex Berezhnykh Date: Fri, 16 Sep 2022 04:40:46 +0300 Subject: [PATCH 5/6] fix --- src/FSharp.Core/prim-types.fs | 2 +- src/FSharp.Core/prim-types.fsi | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs index 5f2a6b641e3..05571313d56 100644 --- a/src/FSharp.Core/prim-types.fs +++ b/src/FSharp.Core/prim-types.fs @@ -3854,7 +3854,7 @@ namespace Microsoft.FSharp.Core [] type ValueOption<'T> = | ValueNone : 'T voption - | ValueSome : value: 'T -> 'T voption + | ValueSome : Value: 'T -> 'T voption member x.Value = match x with ValueSome x -> x | ValueNone -> raise (new InvalidOperationException("ValueOption.Value")) diff --git a/src/FSharp.Core/prim-types.fsi b/src/FSharp.Core/prim-types.fsi index 85ba2e913a9..e6c55e34391 100644 --- a/src/FSharp.Core/prim-types.fsi +++ b/src/FSharp.Core/prim-types.fsi @@ -2438,10 +2438,10 @@ namespace Microsoft.FSharp.Core /// The representation of "Value of type 'T" /// - /// The input value. + /// The input value. /// /// An option representing the value. - | ValueSome: value:'T -> 'T voption + | ValueSome: Value:'T -> 'T voption /// Get the value of a 'ValueSome' option. An InvalidOperationException is raised if the option is 'ValueNone'. member Value: 'T From c9b695d6ad936495d27116d696d7ec8b29eeb54d Mon Sep 17 00:00:00 2001 From: Alex Berezhnykh Date: Fri, 16 Sep 2022 05:08:24 +0300 Subject: [PATCH 6/6] fix --- src/FSharp.Core/prim-types.fs | 2 +- src/FSharp.Core/prim-types.fsi | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FSharp.Core/prim-types.fs b/src/FSharp.Core/prim-types.fs index 05571313d56..eb92de29cba 100644 --- a/src/FSharp.Core/prim-types.fs +++ b/src/FSharp.Core/prim-types.fs @@ -3854,7 +3854,7 @@ namespace Microsoft.FSharp.Core [] type ValueOption<'T> = | ValueNone : 'T voption - | ValueSome : Value: 'T -> 'T voption + | ValueSome : Item: 'T -> 'T voption member x.Value = match x with ValueSome x -> x | ValueNone -> raise (new InvalidOperationException("ValueOption.Value")) diff --git a/src/FSharp.Core/prim-types.fsi b/src/FSharp.Core/prim-types.fsi index e6c55e34391..e639f3cb85e 100644 --- a/src/FSharp.Core/prim-types.fsi +++ b/src/FSharp.Core/prim-types.fsi @@ -2438,10 +2438,10 @@ namespace Microsoft.FSharp.Core /// The representation of "Value of type 'T" /// - /// The input value. + /// The input value. /// /// An option representing the value. - | ValueSome: Value:'T -> 'T voption + | ValueSome: Item:'T -> 'T voption /// Get the value of a 'ValueSome' option. An InvalidOperationException is raised if the option is 'ValueNone'. member Value: 'T