You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, XML-documentation comments are sequentially collected and attached to the nearest (after comments) declaration that supports XmlDoc. This leads to errors when comments that should not be considered attached to declarations at all:
Also, at the moment, it is allowed to place comments up to the name of the binding/type definition, which seems redundant:
We propose redesigning the XML-documentation collecting mechanism to allow more predictable and C#-consistent positions for XML-docs.
The basic idea is to set a grab point for documentation after a non-comment expression is encountered. Then we can assume that the documentation comment block belongs to the declaration if its grab point matches the correct position in the declaration (for example, the beginning of the declaration).
The correct positions for setting grab points are those that comply with the rules described below:
Common
It is allowed to place documentation only at the beginning of the declarations (types, type members, bindings, etc.):
/// A1
type /// A2 - [discarded]
internal /// A3 - [discarded]
A
/// f1
let /// f2 - [discarded]
rec /// f3 - [discarded]
inline /// f4 - [discarded]private f x =...
/// B1
val /// B2 - [discarded]
mutable /// B3 - [discarded]
private /// B4 - [discarded]
B: int
Delimiters
Similar to C#, if another expression is encountered when collecting documentation,
then documentation before this expression cannot be attached to the declaration:
/// A1 - [discarded]1+1/// A2typeA
After documentation, it is allowed to place a group of simple comments ( //, ////, (* ... *) ):
It is allowed to place documentation for union cases, taking into account the rule for attributes:
typeA=///One
One
///Two| Two
typeA=///One1|[<Attr>]///One2 - [discarded]
One
///Two1|[<Attr>]///Two2 - [discarded]
Two
Union case/record fields
It is allowed to place documentation for fields, taking into account the rule for attributes:
typeA={///B1[<Attr>]///B3 - [discarded]
B:int }
typeFoo=| Thing of///a1
a: string *///b1
bool
Function parameters
The documentation for the function parameters should be described in the documentation for the function itself (for example, in the <param> tags)
and not allowed above parameter declarations:
/// function/// <param name='x'>...</param>/// ...
let f x (/// x - [discarded]
y,/// y - [discarded]
z)=...
Property accessors
It is allowed to place documentation only for the property itself,
property documentation will also apply to accessors:
member///A
x.A /// GET - [discarded]with get ()=.../// SET - [discarded]andset(_:int)=...
Compiler diagnostic
To detect invalid documentation blocks positions, a new compiler diagnostic will be required.
We should mark each documentation block when grabbing it and then report syntax warnings for blocks that haven't been grabbed after parsing finishes:
Pros and Cons
The advantages of making this adjustment to F# are:
Bug fixes in the current mechanism for collecting XML-documentation
More predictable and C#-consistent positions for XML-documentation
The disadvantages of making this adjustment to F# are:
Already existing projects may contain XML-documentation incompatible with the new design
This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.
Please tick all that apply:
This is not a breaking change to the F# language design
I or my company would be willing to help implement and/or test this
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
The text was updated successfully, but these errors were encountered:
Redesign XML-documentation collecting mechanism
At the moment, XML-documentation comments are sequentially collected and attached to the nearest (after comments) declaration that supports XmlDoc. This leads to errors when comments that should not be considered attached to declarations at all:
Also, at the moment, it is allowed to place comments up to the name of the binding/type definition, which seems redundant:
We propose redesigning the XML-documentation collecting mechanism to allow more predictable and C#-consistent positions for XML-docs.
The basic idea is to set a grab point for documentation after a non-comment expression is encountered. Then we can assume that the documentation comment block belongs to the declaration if its grab point matches the correct position in the declaration (for example, the beginning of the declaration).
The correct positions for setting grab points are those that comply with the rules described below:
Common
It is allowed to place documentation only at the beginning of the declarations (types, type members, bindings, etc.):
Delimiters
Similar to C#, if another expression is encountered when collecting documentation,
then documentation before this expression cannot be attached to the declaration:
After documentation, it is allowed to place a group of simple comments (
//
,////
,(* ... *)
):But it is still forbidden to separate documentation blocks with simple comments:
Attributes
Similar to C#, if there are attributes in front of the declaration, then documentation before the attributes are attached to the declaration:
This also means that if the declaration contains attributes after its beginning, then documentation before such attributes are discarded:
Recursive declarations group
Since there is a real use case dotnet/fsharp#11489 (comment), it is allowed to add documentation before
and
keywordAlso, documentation is allowed to be left after
and
, taking into account the rule for attributes:However, if documentation blocks before and after
and
are present at the same time, then the priority is given to the documentation beforeand
:Primary constructor
It is allowed to place documentation before the declaration of the primary constructor, taking into account the rule for attributes:
Discriminated Unions
It is allowed to place documentation for union cases, taking into account the rule for attributes:
Union case/record fields
It is allowed to place documentation for fields, taking into account the rule for attributes:
Function parameters
The documentation for the function parameters should be described in the documentation for the function itself (for example, in the
<param>
tags)and not allowed above parameter declarations:
Property accessors
It is allowed to place documentation only for the property itself,
property documentation will also apply to accessors:
Compiler diagnostic
To detect invalid documentation blocks positions, a new compiler diagnostic will be required.
We should mark each documentation block when grabbing it and then report syntax warnings for blocks that haven't been grabbed after parsing finishes:
Pros and Cons
The advantages of making this adjustment to F# are:
The disadvantages of making this adjustment to F# are:
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S
Implementation: dotnet/fsharp#11973
Related suggestions:
#948
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
The text was updated successfully, but these errors were encountered: