未验证 提交 2f471ded 编写于 作者: A Alex Berezhnykh 提交者: GitHub

Don't allow union case unnamed fields in <param> xmldoc (#13914)

* Don't allow union case unnamed fields in xmldoc

* .

* fix doc

* fix

* fix

* fix
上级 ff0f8921
......@@ -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
......
......@@ -3854,7 +3854,7 @@ namespace Microsoft.FSharp.Core
[<DebuggerDisplay("{DebugDisplay,nq}")>]
type ValueOption<'T> =
| ValueNone : 'T voption
| ValueSome : 'T -> 'T voption
| ValueSome : Item: 'T -> 'T voption
member x.Value = match x with ValueSome x -> x | ValueNone -> raise (new InvalidOperationException("ValueOption.Value"))
......
......@@ -2441,7 +2441,7 @@ namespace Microsoft.FSharp.Core
/// <param name="Item">The input value.</param>
///
/// <returns>An option representing the value.</returns>
| ValueSome: 'T -> 'T voption
| ValueSome: Item:'T -> 'T voption
/// <summary>Get the value of a 'ValueSome' option. An InvalidOperationException is raised if the option is 'ValueNone'.</summary>
member Value: 'T
......
......@@ -206,4 +206,28 @@ module M =
|> ignoreWarnings
|> compile
|> shouldSucceed
|> withDiagnostics [ ]
\ No newline at end of file
|> withDiagnostics [ ]
[<Fact>]
let ``Union field - unnamed 01`` () =
Fsx"""
type A =
/// <summary>A</summary>
/// <param name="Item">Item</param>
| A of int
"""
|> withXmlCommentChecking
|> compile
|> withDiagnostics [ Warning 3390, Line 3, Col 13, Line 4, Col 48, "This XML comment is invalid: unknown parameter 'Item'" ]
[<Fact>]
let ``Union field - unnamed 02`` () =
Fsx"""
type A =
/// <summary>A</summary>
/// <param name="a">a</param>
| A of int * a: int
"""
|> withXmlCommentChecking
|> compile
|> withDiagnostics [ ]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册