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

Fix XmlDocs for namespaces and secondary constructor definitions (#12818)

* yet another xmldoc fixes

* fix xmldocs

* fix test
上级 7f4ef66d
......@@ -76,7 +76,7 @@ let parseFormatStringInternal (m: range) (fragRanges: range list) (g: TcGlobals)
// Note this also means that when compiling (command-line or background IncrementalBuilder in the IDE
// there are no accurate intra-string ranges available for exact error message locations within the string.
// The 'm' range passed as an input is however accurate and covers the whole string.
///
//
let fmt, fragments =
//printfn "--------------------"
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
/// Helper members to integrate DependencyManagers into F# codebase
// Helper members to integrate DependencyManagers into F# codebase
namespace FSharp.Compiler.DependencyManager
open System.Runtime.InteropServices
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// The International System of Units (SI)
// The International System of Units (SI)
namespace Microsoft.FSharp.Data.UnitSystems.SI.UnitNames
open Microsoft.FSharp.Core
......@@ -113,7 +113,7 @@ namespace Microsoft.FSharp.Data.UnitSystems.SI.UnitNames
type katal = mole/second
/// Common abbreviations for the International System of Units (SI)
// Common abbreviations for the International System of Units (SI)
namespace Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols
open Microsoft.FSharp.Core
open Microsoft.FSharp.Data.UnitSystems.SI.UnitNames
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// <summary>This namespace contains some common collections in a style primarily designed for use from F#.</summary>
// This namespace contains some common collections in a style primarily designed for use from F#.
namespace Microsoft.FSharp.Collections
open Microsoft.FSharp.Core
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// <summary>Pervasives: Additional bindings available at the top level</summary>
// Pervasives: Additional bindings available at the top level
namespace Microsoft.FSharp.Core
/// <summary>A set of extra operators and functions. This module is automatically opened in all F# code.</summary>
......
......@@ -17,7 +17,7 @@ module internal DetailedExceptions =
val invalidArgDifferentArrayLength: arg1:string -> len1:int -> arg2:string -> len2:int -> _
val invalidArg3ArraysDifferent: arg1:string -> arg2:string -> arg3:string -> len1:int -> len2:int -> len3:int -> _
/// Definitions internal for this library.
// Definitions internal for this library.
namespace Microsoft.FSharp.Primitives.Basics
open Microsoft.FSharp.Core
......
......@@ -4,7 +4,7 @@
#nowarn "61" // The containing type can use <c>null</c> as a representation value for its nullary union case. This member will be compiled as a static member.
#nowarn "62" // This construct is for ML compatibility. The syntax <c>module ... : sig .. end</c> is deprecated unless OCaml compatibility is enabled. Consider using <c>module ... = begin .. end'.
/// <summary>Basic F# type definitions, functions and operators.</summary>
// Basic F# type definitions, functions and operators.
namespace Microsoft.FSharp.Core
open System
......
......@@ -2319,7 +2319,7 @@ namespace Microsoft.FSharp.Core
// 0oOOOOOOO
// -0oOOOOOOO
// without leading/trailing spaces.
///
//
// Note: Parse defaults to NumberStyles.Integer = AllowLeadingWhite ||| AllowTrailingWhite ||| AllowLeadingSign
// However, that is not the required behaviour of 'int32', 'int64' etc. when used on string
// arguments: we explicitly disallow AllowLeadingWhite ||| AllowTrailingWhite
......
......@@ -3,7 +3,7 @@
#nowarn "35" // This construct is deprecated: the treatment of this operator is now handled directly by the F# compiler and its meaning may not be redefined.
#nowarn "61" // The containing type can use 'null' as a representation value for its nullary union case. This member will be compiled as a static member.
/// <summary>Basic F# type definitions, functions and operators </summary>
// Basic F# type definitions, functions and operators
namespace Microsoft.FSharp.Core
open System
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// <summary>This namespace contains types and modules for generating and formatting text with F#</summary>
// This namespace contains types and modules for generating and formatting text with F#
namespace Microsoft.FSharp.Core
open Microsoft.FSharp.Core
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// <summary>Types and functions related to expression quotations</summary>
// Types and functions related to expression quotations
namespace Microsoft.FSharp.Quotations
open Microsoft.FSharp.Core
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// <summary>This namespace contains constructs for reflecting on the representation of
/// F# values and types. It augments the design of System.Reflection.</summary>
// This namespace contains constructs for reflecting on the representation of
// F# values and types. It augments the design of System.Reflection.
namespace Microsoft.FSharp.Reflection
open System
......
......@@ -164,7 +164,7 @@ namespace Microsoft.FSharp.Control
val backgroundTask: BackgroundTaskBuilder
/// Contains the `task` computation expression builder.
// Contains the `task` computation expression builder.
namespace Microsoft.FSharp.Control.TaskBuilderExtensions
open System
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// DSL to create structured layout objects with optional breaks and render them
// DSL to create structured layout objects with optional breaks and render them
namespace FSharp.Compiler.Text
open System.Text
......
......@@ -680,7 +680,7 @@ let u_lazy u st =
let res =
lazy (let st = { st with is = st.is.CloneAndSeek idx1 }
u st)
/// Force the reading of the data as a "tripwire" for each of the OSGN thunks
// Force the reading of the data as a "tripwire" for each of the OSGN thunks
for i = otyconsIdx1 to otyconsIdx2-1 do wire (st.ientities.Get i) res done
for i = ovalsIdx1 to ovalsIdx2-1 do wire (st.ivals.Get i) res done
for i = otyparsIdx1 to otyparsIdx2-1 do wire (st.itypars.Get i) res done
......
......@@ -19,8 +19,8 @@ namespace FSharp.Compiler.Interactive
/// <summary>Schedule a restart for the event loop.</summary>
abstract ScheduleRestart : unit -> unit
/// Operations supported by the currently executing F# Interactive session.
[<Sealed>]
/// <summary>Operations supported by the currently executing F# Interactive session.</summary>
type InteractiveSession =
/// <summary>Get or set the floating point format used in the output of the interactive session.</summary>
......
......@@ -432,7 +432,7 @@ type MethInfo =
member ImplementedSlotSignatures: SlotSig list
// Is this particular MethInfo one that doesn't provide an implementation?
///
//
// For F# methods, this is 'true' for the MethInfos corresponding to 'abstract' declarations,
// and false for the (potentially) matching 'default' implementation MethInfos that eventually
// provide an implementation for the dispatch slot.
......
......@@ -754,7 +754,8 @@ fileModuleSpec:
| _ ->
let lastDeclRange = List.tryLast $1 |> Option.map (fun decl -> decl.Range) |> Option.defaultValue (rhs parseState 1)
let m = mkRange lastDeclRange.FileName (lhs parseState).Start lastDeclRange.End
ParsedSigFileFragment.NamespaceFragment(path, isRec, SynModuleOrNamespaceKind.DeclaredNamespace, $1, xml, [], m)) }
xml.MarkAsInvalid()
ParsedSigFileFragment.NamespaceFragment(path, isRec, SynModuleOrNamespaceKind.DeclaredNamespace, $1, PreXmlDoc.Empty, [], m)) }
moduleSpfnsPossiblyEmptyBlock:
......@@ -1242,7 +1243,8 @@ fileModuleImpl:
| _ ->
let lastDeclRange = List.tryLast $1 |> Option.map (fun decl -> decl.Range) |> Option.defaultValue (rhs parseState 1)
let m = mkRange lastDeclRange.FileName (lhs parseState).Start lastDeclRange.End
ParsedImplFileFragment.NamespaceFragment(path, isRec, SynModuleOrNamespaceKind.DeclaredNamespace, $1, xml, [], m)) }
xml.MarkAsInvalid()
ParsedImplFileFragment.NamespaceFragment(path, isRec, SynModuleOrNamespaceKind.DeclaredNamespace, $1, PreXmlDoc.Empty, [], m)) }
/* A collection/block of definitions or expressions making up a module or namespace, possibly empty */
......@@ -2120,7 +2122,8 @@ classDefnMember:
| opt_attributes opt_declVisibility NEW atomicPattern optAsSpec EQUALS typedSequentialExprBlock opt_ODECLEND
{ let mWholeBindLhs = rhs2 parseState 1 (if Option.isSome $5 then 5 else 4)
let m = unionRanges mWholeBindLhs $7.Range
let xmlDoc = grabXmlDoc(parseState, $1, 1)
let m = unionRanges mWholeBindLhs $7.Range |> unionRangeWithXmlDoc xmlDoc
let mEquals = rhs parseState 6
let expr = $7
let valSynData = SynValData (Some (CtorMemberFlags SynMemberFlagsTrivia.Zero), SynValInfo([SynInfo.InferSynArgInfoFromPat $4], SynInfo.unnamedRetVal), $5)
......@@ -2129,7 +2132,7 @@ classDefnMember:
// Check that 'SynPatForConstructorDecl' matches this correctly
assert (match declPat with SynPatForConstructorDecl _ -> true | _ -> false)
let synBindingTrivia: SynBindingTrivia = { LetKeyword = None; EqualsRange = Some mEquals }
[ SynMemberDefn.Member(SynBinding (None, SynBindingKind.Normal, false, false, $1, grabXmlDoc(parseState, $1, 1), valSynData, declPat, None, expr, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, synBindingTrivia), m) ] }
[ SynMemberDefn.Member(SynBinding (None, SynBindingKind.Normal, false, false, $1, xmlDoc, valSynData, declPat, None, expr, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, synBindingTrivia), m) ] }
| opt_attributes opt_declVisibility STATIC typeKeyword tyconDefn
{ if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2))
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// Anything to do with special names of identifiers and other lexical rules
// Anything to do with special names of identifiers and other lexical rules
namespace FSharp.Compiler.Text
open System
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// The Range and Pos types form part of the public API of FSharp.Compiler.Service
// The Range and Pos types form part of the public API of FSharp.Compiler.Service
namespace FSharp.Compiler.Text
open System.Collections.Generic
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// API for declaration lists and method overload lists
// API for declaration lists and method overload lists
namespace FSharp.Compiler.EditorServices
open FSharp.Compiler.NameResolution
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// SourceCodeServices API to the compiler as an incremental service for parsing,
/// type checking and intellisense-like environment-reporting.
// SourceCodeServices API to the compiler as an incremental service for parsing,
// type checking and intellisense-like environment-reporting.
namespace FSharp.Compiler.CodeAnalysis
open System
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// Functions to map real paths to paths to be written to PDB/IL
// Functions to map real paths to paths to be written to PDB/IL
namespace Internal.Utilities
open System
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// Functions to map real paths to paths to be written to PDB/IL
// Functions to map real paths to paths to be written to PDB/IL
namespace Internal.Utilities
type internal PathMap
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
/// This namespace contains FSharp.PowerPack extensions for the F# collection types
// This namespace contains FSharp.PowerPack extensions for the F# collection types
namespace Internal.Utilities.Collections.Tagged
open System
......
......@@ -40,7 +40,6 @@ module SignatureGenerationTests =
[<Test>]
let ``can generate sigs with comments`` () =
"""
/// namespace comments
namespace Sample
/// exception comments
......
......@@ -940,7 +940,7 @@ type A ///CTOR1
failwith $"Unexpected ParsedInput %A{x}"
[<Test>]
let ``type members 07 - explicit ctor``(): unit =
let ``type members 07 - explicit ctor signature``(): unit =
let parseResults, checkResults = getParseAndCheckResultsOfSignatureFile """
module Test
......@@ -963,6 +963,29 @@ type A =
| x ->
failwith $"Unexpected ParsedInput %A{x}"
[<Test>]
let ``type members 08 - explicit ctor definition``(): unit =
let parseResults, checkResults = getParseAndCheckResults """
type A =
///ctor
new() = ()
"""
checkResults
|> checkXmls [
"A", [||]
".ctor", [|"ctor"|]
]
parseResults
|> checkParsingErrors [||]
match parseResults.ParseTree with
| Members([SynMemberDefn.Member(range = range)]) ->
assertRange (3, 4) (4, 14) range
| x ->
failwith $"Unexpected ParsedInput %A{x}"
[<Test>]
let record(): unit =
checkSignatureAndImplementation """
......@@ -1327,6 +1350,24 @@ val a: int
| x ->
failwith $"Unexpected ParsedInput %A{x}"
[<Test>]
let ``namespace 01``(): unit =
checkSignatureAndImplementation """
///N
namespace N
"""
(checkXml "N" [||])
(fun parseResults ->
parseResults |>
checkParsingErrors [|Information 3520, Line 2, Col 0, Line 2, Col 4, "XML comment is not placed on a valid language element."|]
match parseResults.ParseTree with
| ParsedInput.ImplFile(ParsedImplFileInput(modules = [SynModuleOrNamespace.SynModuleOrNamespace(range = range)]))
| ParsedInput.SigFile(ParsedSigFileInput(modules = [SynModuleOrNamespaceSig.SynModuleOrNamespaceSig(range = range)])) ->
assertRange (3, 0) (3, 11) range
| x ->
failwith $"Unexpected ParsedInput %A{x}")
[<Test>]
let ``Verify that OCaml style xml-doc are gone (i.e. treated as regular comments)``(): unit =
let parseResults, checkResults = getParseAndCheckResultsOfSignatureFile """
......
......@@ -394,8 +394,8 @@ type ProvidedAssembly =
#endif
[<Class>]
/// Represents the context for which code is to be generated. Normally you should not need to use this directly.
[<Class>]
type ProvidedTypesContext =
/// Try to find the given target assembly in the context
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册