diff --git a/src/fsharp/CheckDeclarations.fs b/src/fsharp/CheckDeclarations.fs index 28ca2c85c0c..14c0aff2831 100644 --- a/src/fsharp/CheckDeclarations.fs +++ b/src/fsharp/CheckDeclarations.fs @@ -483,9 +483,9 @@ module TcRecdUnionAndEnumDeclarations = | Some fieldId, Parent tcref -> let item = Item.UnionCaseField (UnionCaseInfo (thisTyInst, UnionCaseRef (tcref, id.idText)), i) CallNameResolutionSink cenv.tcSink (fieldId.idRange, env.NameEnv, item, emptyTyparInst, ItemOccurence.Binding, env.AccessRights) - | _ -> () - - TcAnonFieldDecl cenv env parent tpenv (mkUnionCaseFieldName nFields i) fld) + TcNamedFieldDecl cenv env parent false tpenv fld + | _ -> + TcAnonFieldDecl cenv env parent tpenv (mkUnionCaseFieldName nFields i) fld) ValidateFieldNames(flds, rfields) rfields, thisTy @@ -878,12 +878,21 @@ module IncrClassChecking = not arity.HasNoArgs && not v.IsMutable + /// /// Choose how a binding is represented - member localRep.ChooseRepresentation (cenv: cenv, env: TcEnv, isStatic, isCtorArg, - ctorInfo: IncrClassCtorLhs, - /// The vars forced to be fields due to static member bindings, instance initialization expressions or instance member bindings - staticForcedFieldVars: FreeLocals, - /// The vars forced to be fields due to instance member bindings + /// + /// + /// + /// + /// + /// + /// The vars forced to be fields due to static member bindings, instance initialization expressions or instance member bindings + /// The vars forced to be fields due to instance member bindings + /// + /// + member localRep.ChooseRepresentation (cenv: cenv, env: TcEnv, isStatic, isCtorArg, + ctorInfo: IncrClassCtorLhs, + staticForcedFieldVars: FreeLocals, instanceForcedFieldVars: FreeLocals, takenFieldNames: Set, bind: Binding) = @@ -1091,9 +1100,9 @@ module IncrClassChecking = /// Given localRep saying how locals have been represented, e.g. as fields. /// Given an expr under a given thisVal context. // - /// Fix up the references to the locals, e.g. - /// v -> this.fieldv - /// f x -> this.method x + // Fix up the references to the locals, e.g. + // v -> this.fieldv + // f x -> this.method x member localRep.FixupIncrClassExprPhase2C cenv thisValOpt safeStaticInitInfo (thisTyInst: TypeInst) expr = // fixup: intercept and expr rewrite let FixupExprNode rw e = @@ -1143,21 +1152,27 @@ module IncrClassChecking = | Phase2CCtorJustAfterSuperInit | Phase2CCtorJustAfterLastLet - /// Given a set of 'let' bindings (static or not, recursive or not) that make up a class, - /// generate their initialization expression(s). - let MakeCtorForIncrClassConstructionPhase2C + /// + /// Given a set of 'let' bindings (static or not, recursive or not) that make up a class, + /// generate their initialization expression(s). + /// + /// + /// + /// The lhs information about the implicit constructor + /// The call to the super class constructor + /// Should we place a sequence point at the 'inheritedTys call? + /// The declarations + /// + /// Record any unconstrained type parameters generalized for the outer members as "free choices" in the let bindings + /// + let MakeCtorForIncrClassConstructionPhase2C (cenv: cenv, - env: TcEnv, - /// The lhs information about the implicit constructor - ctorInfo: IncrClassCtorLhs, - /// The call to the super class constructor - inheritsExpr, - /// Should we place a sequence point at the 'inheritedTys call? - inheritsIsVisible, - /// The declarations + env: TcEnv, + ctorInfo: IncrClassCtorLhs, + inheritsExpr, + inheritsIsVisible, decs: IncrClassConstructionBindingsPhase2C list, - memberBinds: Binding list, - /// Record any unconstrained type parameters generalized for the outer members as "free choices" in the let bindings + memberBinds: Binding list, generalizedTyparsForRecursiveBlock, safeStaticInitInfo: SafeInitData) = @@ -1459,7 +1474,7 @@ module IncrClassChecking = ctorBody let cctorBodyOpt = - /// Omit the .cctor if it's empty + // Omit the .cctor if it's empty match cctorInitActions with | [] -> None | _ -> @@ -3586,7 +3601,7 @@ module EstablishTypeDefinitionCores = /// Note that for /// type PairOfInts = int * int /// then after running this phase and checking for cycles, operations - // such as 'isRefTupleTy' will return reliable results, e.g. isRefTupleTy on the + /// such as 'isRefTupleTy' will return reliable results, e.g. isRefTupleTy on the /// TAST type for 'PairOfInts' will report 'true' // let private TcTyconDefnCore_Phase1C_Phase1E_EstablishAbbreviations (cenv: cenv) envinner inSig tpenv pass (MutRecDefnsPhase1DataForTycon(_, synTyconRepr, _, _, _, _)) (tycon: Tycon) (attrs: Attribs) = diff --git a/src/fsharp/CheckExpressions.fs b/src/fsharp/CheckExpressions.fs index d4b8e08d9d6..f966e8e5b60 100644 --- a/src/fsharp/CheckExpressions.fs +++ b/src/fsharp/CheckExpressions.fs @@ -1031,8 +1031,8 @@ let noArgOrRetAttribs = ArgAndRetAttribs ([], []) /// shares the same code paths (e.g. TcLetBinding and TcLetrec) as processing expression bindings (such as "let x = 1 in ...") /// Member bindings also use this path. // -/// However there are differences in how different bindings get processed, -/// i.e. module bindings get published to the implicitly accumulated module type, but expression 'let' bindings don't. +// However there are differences in how different bindings get processed, +// i.e. module bindings get published to the implicitly accumulated module type, but expression 'let' bindings don't. type DeclKind = | ModuleOrMemberBinding @@ -5971,7 +5971,7 @@ and TcExprUndelayed cenv (overallTy: OverallTy) env tpenv (synExpr: SynExpr) = let e3', tpenv = TcExpr cenv overallTy env tpenv e3 Expr.StaticOptimization (constraints', e2', e3', m), tpenv - /// e1.longId <- e2 + // e1.longId <- e2 | SynExpr.DotSet (e1, (LongIdentWithDots(longId, _) as lidwd), e2, mStmt) -> if lidwd.ThereIsAnExtraDotAtTheEnd then // just drop rhs on the floor @@ -5981,11 +5981,11 @@ and TcExprUndelayed cenv (overallTy: OverallTy) env tpenv (synExpr: SynExpr) = let mExprAndDotLookup = unionRanges e1.Range (rangeOfLid longId) TcExprThen cenv overallTy env tpenv false e1 [DelayedDotLookup(longId, mExprAndDotLookup); MakeDelayedSet(e2, mStmt)] - /// e1 <- e2 + // e1 <- e2 | SynExpr.Set (e1, e2, mStmt) -> TcExprThen cenv overallTy env tpenv false e1 [MakeDelayedSet(e2, mStmt)] - /// e1.longId(e2) <- e3, very rarely used named property setters + // e1.longId(e2) <- e3, very rarely used named property setters | SynExpr.DotNamedIndexedPropertySet (e1, (LongIdentWithDots(longId, _) as lidwd), e2, e3, mStmt) -> if lidwd.ThereIsAnExtraDotAtTheEnd then // just drop rhs on the floor diff --git a/src/fsharp/CheckExpressions.fsi b/src/fsharp/CheckExpressions.fsi index e430ce66fa0..765ecd35c93 100644 --- a/src/fsharp/CheckExpressions.fsi +++ b/src/fsharp/CheckExpressions.fsi @@ -46,10 +46,10 @@ val InitialImplicitCtorInfo: unit -> CtorInfo [] type UngeneralizableItem -[] /// Represents the type environment at a particular scope. Includes the name /// resolution environment, the ungeneralizable items from earlier in the scope /// and other information about the scope. +[] type TcEnv = { /// Name resolution information eNameResEnv: NameResolutionEnv diff --git a/src/fsharp/CompilerConfig.fs b/src/fsharp/CompilerConfig.fs index f93653b1d8c..dae491a9d44 100644 --- a/src/fsharp/CompilerConfig.fs +++ b/src/fsharp/CompilerConfig.fs @@ -860,8 +860,8 @@ type TcConfigBuilder = // TcConfig //-------------------------------------------------------------------------- -[] /// This type is immutable and must be kept as such. Do not extract or mutate the underlying data except by cloning it. +[] type TcConfig private (data: TcConfigBuilder, validate: bool) = // Validate the inputs - this helps ensure errors in options are shown in visual studio rather than only when built diff --git a/src/fsharp/CompilerImports.fsi b/src/fsharp/CompilerImports.fsi index 4b91bb7c52d..0eeb5e23c29 100644 --- a/src/fsharp/CompilerImports.fsi +++ b/src/fsharp/CompilerImports.fsi @@ -117,8 +117,8 @@ type ImportedAssembly = } -[] /// Tables of assembly resolutions +[] type TcAssemblyResolutions = member GetAssemblyResolutions: unit -> AssemblyResolution list diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index 34f20beda0c..d178d9b23a2 100644 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -143,8 +143,8 @@ let FreshenMethInfo m (minfo: MethInfo) = // Subsumption of types: solve/record subtyping constraints //------------------------------------------------------------------------- -[] /// Information about the context of a type equation. +[] type ContextInfo = /// No context was given. diff --git a/src/fsharp/ConstraintSolver.fsi b/src/fsharp/ConstraintSolver.fsi index fb0d76a2b4e..dee696470e5 100644 --- a/src/fsharp/ConstraintSolver.fsi +++ b/src/fsharp/ConstraintSolver.fsi @@ -43,8 +43,8 @@ val FreshenTypars: range -> Typars -> TType list val FreshenMethInfo: range -> MethInfo -> TType list -[] /// Information about the context of a type equation. +[] type ContextInfo = /// No context was given. diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 3648742e205..ae3e646f3c6 100644 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -1629,3 +1629,4 @@ reprStateMachineInvalidForm,"The state machine has an unexpected form" 3517,optFailedToInlineSuggestedValue,"The value '%s' was marked 'InlineIfLambda' but was not determined to have a lambda value. This warning is for informational purposes only." 3518,implMissingInlineIfLambda,"The 'InlineIfLambda' attribute is present in the signature but not the implementation." 3519,tcInlineIfLambdaUsedOnNonInlineFunctionOrMethod,"The 'InlineIfLambda' attribute may only be used on parameters of inlined functions of methods whose type is a function or F# delegate type." +3520,invalidXmlDocPosition,"XML comment is not placed on a valid language element." diff --git a/src/fsharp/FSharp.Core/FSharp.Core.fsproj b/src/fsharp/FSharp.Core/FSharp.Core.fsproj index 6b1e945d68f..0b197c4f143 100644 --- a/src/fsharp/FSharp.Core/FSharp.Core.fsproj +++ b/src/fsharp/FSharp.Core/FSharp.Core.fsproj @@ -17,6 +17,8 @@ $(OtherFlags) --warnon:1182 $(OtherFlags) --warnon:3390 + + $(OtherFlags) --warnon:3520 $(OtherFlags) --nowarn:57 diff --git a/src/fsharp/FSharp.Core/Linq.fs b/src/fsharp/FSharp.Core/Linq.fs index 8bc7fcf5615..d46d9eedb56 100644 --- a/src/fsharp/FSharp.Core/Linq.fs +++ b/src/fsharp/FSharp.Core/Linq.fs @@ -497,7 +497,7 @@ module LeafExpressionConverter = // or type T to an argument expecting Expression. | ImplicitExpressionConversionHelperQ (_, [_], [x1]) -> ConvExprToLinqInContext env x1 - /// Use witnesses if they are available + // Use witnesses if they are available | CallWithWitnesses (objArgOpt, _, minfo2, witnessArgs, args) -> let fullArgs = witnessArgs @ args let replacementExpr = diff --git a/src/fsharp/FSharp.Core/Query.fsi b/src/fsharp/FSharp.Core/Query.fsi index 118cf4b0e9d..62f7697c0fe 100644 --- a/src/fsharp/FSharp.Core/Query.fsi +++ b/src/fsharp/FSharp.Core/Query.fsi @@ -10,15 +10,15 @@ namespace Microsoft.FSharp.Linq open System.Collections open System.Collections.Generic - [] /// /// A partial input or result in an F# query. This type is used to support the F# query syntax. /// /// /// - /// Library functionality for F# query syntax and interoperability with .NET LINQ Expressions. See + /// Library functionality for F# query syntax and interoperability with .NET LINQ Expressions. See /// also F# Query Expressions in the F# Language Guide. /// + [] type QuerySource<'T, 'Q> = /// /// A method used to support the F# query syntax. @@ -30,9 +30,9 @@ namespace Microsoft.FSharp.Linq /// member Source: seq<'T> - [] - /// The type used to support the F# query syntax. Use 'query { ... }' to use the query syntax. See + /// The type used to support the F# query syntax. Use 'query { ... }' to use the query syntax. See /// also F# Query Expressions in the F# Language Guide. + [] type QueryBuilder = /// Create an instance of this builder. Use 'query { ... }' to use the query syntax. new: unit -> QueryBuilder diff --git a/src/fsharp/FSharp.Core/SI.fs b/src/fsharp/FSharp.Core/SI.fs index b0ec79e91f9..10a0798445c 100644 --- a/src/fsharp/FSharp.Core/SI.fs +++ b/src/fsharp/FSharp.Core/SI.fs @@ -4,112 +4,112 @@ namespace Microsoft.FSharp.Data.UnitSystems.SI.UnitNames open Microsoft.FSharp.Core - [] /// The SI unit of length + [] type metre - [] /// The SI unit of length + [] type meter = metre - [] /// The SI unit of mass + [] type kilogram - [] /// The SI unit of time + [] type second - [] /// The SI unit of electric current + [] type ampere - [] /// The SI unit of thermodynamic temperature + [] type kelvin - [] /// The SI unit of amount of substance + [] type mole - [] /// The SI unit of luminous intensity + [] type candela - [] /// The SI unit of frequency + [] type hertz = / second - [] /// The SI unit of force + [] type newton = kilogram metre / second^2 - [] /// The SI unit of pressure, stress + [] type pascal = newton / metre^2 - [] /// The SI unit of energy, work, amount of heat + [] type joule = newton metre - [] /// The SI unit of power, radiant flux + [] type watt = joule / second - [] /// The SI unit of electric charge, amount of electricity + [] type coulomb = second ampere - [] /// The SI unit of electric potential difference, electromotive force + [] type volt = watt/ampere - [] /// The SI unit of capacitance + [] type farad = coulomb/volt - [] /// The SI unit of electric resistance + [] type ohm = volt/ampere - [] /// The SI unit of electric conductance + [] type siemens = ampere/volt - [] /// The SI unit of magnetic flux + [] type weber = volt second - [] /// The SI unit of magnetic flux density + [] type tesla = weber/metre^2 - [] /// The SI unit of inductance + [] type henry = weber/ampere - [] /// The SI unit of luminous flux + [] type lumen = candela - [] /// The SI unit of illuminance + [] type lux = lumen/metre^2 - [] /// The SI unit of activity referred to a radionuclide + [] type becquerel = second^-1 - [] /// The SI unit of absorbed dose + [] type gray = joule/kilogram - [] /// The SI unit of does equivalent + [] type sievert = joule/kilogram - [] /// The SI unit of catalytic activity + [] type katal = mole/second @@ -118,106 +118,106 @@ namespace Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols open Microsoft.FSharp.Core open Microsoft.FSharp.Data.UnitSystems.SI.UnitNames - [] /// A synonym for Metre, the SI unit of length + [] type m = metre - [] /// A synonym for kilogram, the SI unit of mass + [] type kg = kilogram - [] /// A synonym for second, the SI unit of time + [] type s = second - [] /// A synonym for ampere, the SI unit of electric current + [] type A = ampere - [] /// A synonym for kelvin, the SI unit of thermodynamic temperature + [] type K = kelvin - [] /// A synonym for mole, the SI unit of amount of substance + [] type mol = mole - [] /// A synonym for candela, the SI unit of luminous intensity + [] type cd = candela - [] /// A synonym for hertz, the SI unit of frequency + [] type Hz = hertz - [] /// A synonym for newton, the SI unit of force + [] type N = newton - [] /// A synonym for pascal, the SI unit of pressure, stress + [] type Pa = pascal - [] /// A synonym for joule, the SI unit of energy, work, amount of heat + [] type J = joule - [] /// A synonym for watt, the SI unit of power, radiant flux + [] type W = watt - [] /// A synonym for coulomb, the SI unit of electric charge, amount of electricity + [] type C = coulomb - [] /// A synonym for volt, the SI unit of electric potential difference, electromotive force + [] type V = volt - [] /// A synonym for farad, the SI unit of capacitance + [] type F = farad - [] /// A synonym for siemens, the SI unit of electric conductance + [] type S = siemens - [] /// A synonym for UnitNames.ohm, the SI unit of electric resistance. + [] type ohm = Microsoft.FSharp.Data.UnitSystems.SI.UnitNames.ohm - [] /// A synonym for weber, the SI unit of magnetic flux + [] type Wb = weber - [] /// A synonym for tesla, the SI unit of magnetic flux density + [] type T = tesla - [] /// A synonym for lumen, the SI unit of luminous flux + [] type lm = lumen - [] /// A synonym for lux, the SI unit of illuminance + [] type lx = lux - [] /// A synonym for becquerel, the SI unit of activity referred to a radionuclide + [] type Bq = becquerel - [] /// A synonym for gray, the SI unit of absorbed dose + [] type Gy = gray - [] /// A synonym for sievert, the SI unit of does equivalent + [] type Sv = sievert - [] /// A synonym for katal, the SI unit of catalytic activity + [] type kat = katal - [] /// A synonym for henry, the SI unit of inductance + [] type H = henry diff --git a/src/fsharp/FSharp.Core/array.fsi b/src/fsharp/FSharp.Core/array.fsi index 0950c5e9a80..1dc582d5c95 100644 --- a/src/fsharp/FSharp.Core/array.fsi +++ b/src/fsharp/FSharp.Core/array.fsi @@ -345,10 +345,10 @@ module Array = /// Returns an empty array of the given type. /// The empty array. - [] /// /// - /// + /// + [] [] val empty<'T> : 'T[] diff --git a/src/fsharp/FSharp.Core/array2.fsi b/src/fsharp/FSharp.Core/array2.fsi index ec60c34a095..1216ea19c7f 100644 --- a/src/fsharp/FSharp.Core/array2.fsi +++ b/src/fsharp/FSharp.Core/array2.fsi @@ -6,8 +6,6 @@ open System open Microsoft.FSharp.Collections open Microsoft.FSharp.Core -[] -[] /// Contains operations for working with 2-dimensional arrays. /// /// @@ -23,6 +21,8 @@ open Microsoft.FSharp.Core /// Non-zero-based arrays can also be created using Array2D.zeroCreateBased, /// Array2D.createBased and Array2D.initBased. /// +[] +[] module Array2D = /// Fetches the base-index for the first dimension of the array. @@ -265,5 +265,3 @@ module Array2D = /// [] val get: array:'T[,] -> index1:int -> index2:int -> 'T - - diff --git a/src/fsharp/FSharp.Core/array3.fsi b/src/fsharp/FSharp.Core/array3.fsi index 49b585aa8eb..f4490408c33 100644 --- a/src/fsharp/FSharp.Core/array3.fsi +++ b/src/fsharp/FSharp.Core/array3.fsi @@ -7,13 +7,13 @@ open Microsoft.FSharp.Collections open Microsoft.FSharp.Core open Microsoft.FSharp.Core.Operators -[] -[] /// Contains operations for working with rank 3 arrays. /// /// /// See also F# Language Guide - Arrays. /// +[] +[] module Array3D = /// Creates an array whose elements are all initially the given value. @@ -159,9 +159,9 @@ module Array3D = +/// Contains operations for working with rank 4 arrays. [] [] -/// Contains operations for working with rank 4 arrays. module Array4D = /// Creates an array whose elements are all initially the given value @@ -272,4 +272,3 @@ module Array4D = /// [] val set: array:'T[,,,] -> index1:int -> index2:int -> index3:int -> index4:int -> value:'T -> unit - diff --git a/src/fsharp/FSharp.Core/async.fs b/src/fsharp/FSharp.Core/async.fs index 6afa26489de..6578233e762 100644 --- a/src/fsharp/FSharp.Core/async.fs +++ b/src/fsharp/FSharp.Core/async.fs @@ -233,9 +233,9 @@ namespace Microsoft.FSharp.Control // NOTE: this must be a tailcall cont res + /// Represents rarely changing components of an in-flight async computation [] [] - /// Represents rarely changing components of an in-flight async computation type AsyncActivationAux = { /// The active cancellation token token: CancellationToken @@ -249,9 +249,9 @@ namespace Microsoft.FSharp.Control /// Holds some commonly-allocated callbacks and a mutable location to use for a trampoline trampolineHolder: TrampolineHolder } + /// Represents context for an in-flight async computation [] [] - /// Represents context for an in-flight async computation type AsyncActivationContents<'T> = { /// The success continuation cont: cont<'T> @@ -305,8 +305,9 @@ namespace Microsoft.FSharp.Control contents.aux.ccont (OperationCanceledException (contents.aux.token)) /// Check for trampoline hijacking. + // // Note, this must make tailcalls, so may not be an instance member taking a byref argument, - /// nor call any members taking byref arguments. + // nor call any members taking byref arguments. static member inline HijackCheckThenCall (ctxt: AsyncActivation<'T>) cont arg = ctxt.aux.trampolineHolder.HijackCheckThenCall cont arg @@ -756,7 +757,7 @@ namespace Microsoft.FSharp.Control /// - Hijack check after 'entering' the implied try/finally and after MoveNext call /// - Do not apply 'GetEnumerator' with exception protection. However for an 'async' /// in an 'async { ... }' the exception protection will be provided by the enclosing - // Delay or Bind or similar construct. + /// Delay or Bind or similar construct. /// - Apply 'MoveNext' with exception protection /// - Apply 'Current' with exception protection diff --git a/src/fsharp/FSharp.Core/async.fsi b/src/fsharp/FSharp.Core/async.fsi index 75869a2e4ba..d127f6f6380 100644 --- a/src/fsharp/FSharp.Core/async.fsi +++ b/src/fsharp/FSharp.Core/async.fsi @@ -681,9 +681,9 @@ namespace Microsoft.FSharp.Control type AsyncReturn /// The F# compiler emits references to this type to implement F# async expressions. - [] /// /// Async Internals + [] type AsyncActivation<'T> = /// The F# compiler emits calls to this function to implement F# async expressions. @@ -732,10 +732,10 @@ namespace Microsoft.FSharp.Control | Error of ExceptionDispatchInfo | Canceled of OperationCanceledException - [] /// Entry points for generated code /// /// Async Internals + [] module AsyncPrimitives = /// The F# compiler emits calls to this function to implement F# async expressions. @@ -805,11 +805,11 @@ namespace Microsoft.FSharp.Control // Internals used by MailboxProcessor val internal CreateAsyncResultAsync : AsyncResult<'T> -> Async<'T> - [] - [] /// The type of the async operator, used to build workflows for asynchronous computations. /// /// Async Programming + [] + [] type AsyncBuilder = /// Creates an asynchronous computation that enumerates the sequence seq /// on demand and runs body for each element. @@ -989,10 +989,10 @@ namespace Microsoft.FSharp.Control /// A cancellation check is performed when the computation is executed. internal new : unit -> AsyncBuilder - [] /// A module of extension members providing asynchronous operations for some basic CLI types related to concurrency and I/O. /// /// Async Programming + [] module CommonExtensions = type System.IO.Stream with diff --git a/src/fsharp/FSharp.Core/eventmodule.fsi b/src/fsharp/FSharp.Core/eventmodule.fsi index 4e520b559f6..6dcd33f5d35 100644 --- a/src/fsharp/FSharp.Core/eventmodule.fsi +++ b/src/fsharp/FSharp.Core/eventmodule.fsi @@ -5,11 +5,11 @@ namespace Microsoft.FSharp.Control open Microsoft.FSharp.Core open Microsoft.FSharp.Control - [] - [] /// Contains operations for working with values of type . /// /// Events and Observables + [] + [] module Event = /// Fires the output event when either of the input events fire. @@ -73,11 +73,10 @@ namespace Microsoft.FSharp.Control [] val choose: chooser:('T -> 'U option) -> sourceEvent:IEvent<'Del,'T> -> IEvent<'U> - [] /// Returns a new event consisting of the results of applying the given accumulating function /// to successive values triggered on the input event. An item of internal state /// records the current value of the state parameter. The internal state is not locked during the - /// execution of the accumulation function, so care should be taken that the + /// execution of the accumulation function, so care should be taken that the /// input IEvent not triggered by multiple threads simultaneously. /// /// The function to update the state with each event value. @@ -85,6 +84,7 @@ namespace Microsoft.FSharp.Control /// The input event. /// /// An event that fires on the updated state values. + [] val scan: collector:('U -> 'T -> 'U) -> state:'U -> sourceEvent:IEvent<'Del,'T> -> IEvent<'U> /// Runs the given function each time the given event is triggered. diff --git a/src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi b/src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi index c1dea425552..c5503282e65 100644 --- a/src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi +++ b/src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi @@ -3,10 +3,10 @@ /// Pervasives: Additional bindings available at the top level namespace Microsoft.FSharp.Core -[] /// A set of extra operators and functions. This module is automatically opened in all F# code. /// /// Basic Operators +[] module ExtraTopLevelOperators = open System @@ -294,8 +294,8 @@ namespace Microsoft.FSharp.Core.CompilerServices /// Gets or sets the column for the location. member Column : int with get, set - [] /// Indicates that a code editor should hide all System.Object methods from the intellisense menus for instances of a provided type + [] type TypeProviderEditorHideMethodsAttribute = inherit System.Attribute diff --git a/src/fsharp/FSharp.Core/mailbox.fsi b/src/fsharp/FSharp.Core/mailbox.fsi index b864b99ad43..bb8ec31eeb8 100644 --- a/src/fsharp/FSharp.Core/mailbox.fsi +++ b/src/fsharp/FSharp.Core/mailbox.fsi @@ -7,10 +7,10 @@ open System.Threading open Microsoft.FSharp.Core open Microsoft.FSharp.Control -[] /// A handle to a capability to reply to a PostAndReply message. /// /// Agents +[] type AsyncReplyChannel<'Reply> = /// Sends a reply to a PostAndReply message. /// The value to send. diff --git a/src/fsharp/FSharp.Core/math/z.fsi b/src/fsharp/FSharp.Core/math/z.fsi index 463d57f3db0..a8c52f5703a 100644 --- a/src/fsharp/FSharp.Core/math/z.fsi +++ b/src/fsharp/FSharp.Core/math/z.fsi @@ -17,10 +17,10 @@ namespace Microsoft.FSharp.Core /// Basic Types type bigint = System.Numerics.BigInteger - [] /// Provides a default implementations of F# numeric literal syntax for literals of the form 'dddI' /// /// Language Primitives + [] module NumericLiterals = /// Provides a default implementations of F# numeric literal syntax for literals of the form 'dddI' diff --git a/src/fsharp/FSharp.Core/nativeptr.fsi b/src/fsharp/FSharp.Core/nativeptr.fsi index 0c13ec823a5..1482e148a82 100644 --- a/src/fsharp/FSharp.Core/nativeptr.fsi +++ b/src/fsharp/FSharp.Core/nativeptr.fsi @@ -5,8 +5,6 @@ namespace Microsoft.FSharp.NativeInterop open Microsoft.FSharp.Core open Microsoft.FSharp.Collections -[] -[] /// Contains operations on native pointers. Use of these operators may /// result in the generation of unverifiable code. /// @@ -15,6 +13,8 @@ open Microsoft.FSharp.Collections /// also F# External Functions in /// the F# Language Guide. /// +[] +[] module NativePtr = /// Returns a typed native pointer for a given machine address. @@ -225,3 +225,4 @@ module NativePtr = [] [] val inline copyBlock : destination: nativeptr<'T> -> source: nativeptr<'T> -> count: int -> unit + diff --git a/src/fsharp/FSharp.Core/observable.fsi b/src/fsharp/FSharp.Core/observable.fsi index 80c77039ee0..47356773294 100644 --- a/src/fsharp/FSharp.Core/observable.fsi +++ b/src/fsharp/FSharp.Core/observable.fsi @@ -5,12 +5,12 @@ namespace Microsoft.FSharp.Control open System open Microsoft.FSharp.Core -[] -[] /// Contains operations for working with first class event and other observable objects. /// /// Events and Observables -module Observable = +[] +[] +module Observable = /// Returns an observable for the merged observations from the sources. /// The returned object propagates success and error values arising diff --git a/src/fsharp/FSharp.Core/option.fsi b/src/fsharp/FSharp.Core/option.fsi index aa85e6414c6..da16307e667 100644 --- a/src/fsharp/FSharp.Core/option.fsi +++ b/src/fsharp/FSharp.Core/option.fsi @@ -7,10 +7,10 @@ open Microsoft.FSharp.Core open Microsoft.FSharp.Collections -[] /// Contains operations for working with options. /// /// Options +[] module Option = /// Returns true if the option is not None. /// The input option. diff --git a/src/fsharp/FSharp.Core/prim-types.fsi b/src/fsharp/FSharp.Core/prim-types.fsi index 1683853779c..24f68574e0a 100644 --- a/src/fsharp/FSharp.Core/prim-types.fsi +++ b/src/fsharp/FSharp.Core/prim-types.fsi @@ -66,10 +66,10 @@ namespace Microsoft.FSharp.Core /// Indicates that the compiled entity had private or internal representation in F# source code. | NonPublicRepresentation = 32 - [] /// Indicates one or more adjustments to the compiled representation of an F# type or member. /// /// Attributes + [] type CompilationRepresentationFlags = /// No special compilation representation. @@ -407,12 +407,12 @@ namespace Microsoft.FSharp.Core /// StructuralComparisonAttribute new : unit -> StructuralComparisonAttribute - [] - [] /// Indicates that a member on a computation builder type is a custom query operator, /// and indicates the name of that operator. /// /// Attributes + [] + [] type CustomOperationAttribute = inherit Attribute @@ -444,12 +444,12 @@ namespace Microsoft.FSharp.Core /// Indicates if the custom operation maintains the variable space of the query of computation expression through the use of a bind operation member MaintainsVariableSpaceUsingBind : bool with get,set - [] - [] /// Indicates that, when a custom operator is used in a computation expression, /// a parameter is automatically parameterized by the variable space of the computation expression /// /// Attributes + [] + [] type ProjectionParameterAttribute = /// Creates an instance of the attribute @@ -936,191 +936,191 @@ namespace Microsoft.FSharp.Core /// or an enclosing module opened. member Path: string - [] - /// The type of double-precision floating point numbers, annotated with a unit of measure. + /// The type of double-precision floating point numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type float<[] 'Measure> = float - [] - /// The type of single-precision floating point numbers, annotated with a unit of measure. + /// The type of single-precision floating point numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// /// Basic Types with Units of Measure + [] type float32<[] 'Measure> = float32 - [] /// The type of decimal numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type decimal<[] 'Measure> = decimal - [] /// The type of 32-bit signed integer numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type int<[] 'Measure> = int - [] /// The type of 8-bit signed integer numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type sbyte<[] 'Measure> = sbyte - [] /// The type of 16-bit signed integer numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type int16<[] 'Measure> = int16 - [] /// The type of 64-bit signed integer numbers, annotated with a unit of measure. The unit /// of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type int64<[] 'Measure> = int64 - [] - [] /// The type of machine-sized signed integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] + [] type nativeint<[] 'Measure> = nativeint - [] - [] /// The type of 32-bit unsigned integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] + [] type uint<[] 'Measure> = uint - - [] - [] + /// The type of 8-bit unsigned integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] + [] type byte<[] 'Measure> = byte - [] - [] - /// The type of 16-bit unsigned integer numbers, annotated with a unit of measure. + /// The type of 16-bit unsigned integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] + [] type uint16<[] 'Measure> = uint16 - [] - [] - /// The type of 64-bit unsigned integer numbers, annotated with a unit of measure. + /// The type of 64-bit unsigned integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] + [] type uint64<[] 'Measure> = uint64 - [] - [] - /// The type of machine-sized unsigned integer numbers, annotated with a unit of measure. + /// The type of machine-sized unsigned integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] + [] type unativeint<[] 'Measure> = unativeint - [] - /// The type of double-precision floating point numbers, annotated with a unit of measure. + /// The type of double-precision floating point numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type double<[] 'Measure> = float<'Measure> - [] - /// The type of single-precision floating point numbers, annotated with a unit of measure. + /// The type of single-precision floating point numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type single<[] 'Measure> = float32<'Measure> - [] - /// The type of 8-bit signed integer numbers, annotated with a unit of measure. + /// The type of 8-bit signed integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type int8<[] 'Measure> = sbyte<'Measure> - [] - /// The type of 32-bit signed integer numbers, annotated with a unit of measure. + /// The type of 32-bit signed integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type int32<[] 'Measure> = int<'Measure> - [] - /// The type of 8-bit unsigned integer numbers, annotated with a unit of measure. + /// The type of 8-bit unsigned integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type uint8<[] 'Measure> = byte<'Measure> - [] - /// The type of 32-bit unsigned integer numbers, annotated with a unit of measure. + /// The type of 32-bit unsigned integer numbers, annotated with a unit of measure. /// The unit of measure is erased in compiled code and when values of this type - /// are analyzed using reflection. The type is representationally equivalent to + /// are analyzed using reflection. The type is representationally equivalent to /// . /// /// Basic Types with Units of Measure + [] type uint32<[] 'Measure> = uint<'Measure> /// Represents a managed pointer in F# code. + /// ByRef and Pointer Types #if BUILDING_WITH_LKG || BUILD_FROM_SOURCE [] #else [] #endif - /// ByRef and Pointer Types type byref<'T, 'Kind> = (# "!0&" #) /// Represents a managed pointer in F# code. For F# 4.5+ this is considered equivalent to byref<'T, ByRefKinds.InOut> @@ -1128,12 +1128,12 @@ namespace Microsoft.FSharp.Core type byref<'T> = (# "!0&" #) /// Represents the types of byrefs in F# 4.5+ + /// ByRef and Pointer Types #if BUILDING_WITH_LKG || BUILD_FROM_SOURCE [] #else [] #endif - /// ByRef and Pointer Types module ByRefKinds = /// Represents a byref that can be written @@ -1316,8 +1316,8 @@ namespace Microsoft.FSharp.Core [] val FastGenericEqualityComparerFromTable<'T> : System.Collections.Generic.IEqualityComparer<'T> when 'T : equality - [] /// Make an F# comparer object for the given type + [] val FastGenericComparerFromTable<'T> : System.Collections.Generic.IComparer<'T> when 'T : comparison /// Hash a value according to its structure. This hash is not limited by an overall node count when hashing F# @@ -1408,52 +1408,52 @@ namespace Microsoft.FSharp.Core /// The sbyte with units-of-measure. val inline SByteWithMeasure : input: sbyte -> sbyte<'Measure> - [] /// Creates a nativeint value with units-of-measure /// /// The input nativeint. /// /// The nativeint with units-of-measure. + [] val inline IntPtrWithMeasure : input: nativeint -> nativeint<'Measure> - [] /// Creates a uint value with units-of-measure /// /// The input uint. /// /// The uint with units-of-measure. + [] val inline UInt32WithMeasure : input: uint -> uint<'Measure> - [] /// Creates a uint64 value with units-of-measure /// /// The input uint64. /// /// The uint64 with units-of-measure. + [] val inline UInt64WithMeasure : input: uint64 -> uint64<'Measure> - [] /// Creates a uint16 value with units-of-measure /// /// The input uint16. /// /// The uint16 with units-of-measure. + [] val inline UInt16WithMeasure : input: uint16 -> uint16<'Measure> - [] /// Creates a byte value with units-of-measure /// /// The input byte. /// /// The byte with units-of-measure. + [] val inline ByteWithMeasure : input: byte -> byte<'Measure> - [] /// Creates a unativeint value with units-of-measure /// /// The input unativeint. /// /// The unativeint with units-of-measure. + [] val inline UIntPtrWithMeasure : input: unativeint -> unativeint<'Measure> /// Parse an int32 according to the rules used by the overloaded 'int32' conversion operator when applied to strings @@ -2086,12 +2086,12 @@ namespace Microsoft.FSharp.Core /// The function result. static member InvokeFast : func: FSharpFunc<'T,('U -> 'V)> * arg1:'T * arg2:'U -> 'V - [] - [] /// Helper functions for converting F# first class function values to and from CLI representations /// of functions using delegates. /// Language Primitives - type FuncConvert = + [] + [] + type FuncConvert = /// Convert the given Action delegate object to an F# function value /// @@ -2416,8 +2416,8 @@ namespace Microsoft.FSharp.Core /// static member op_Implicit : value:'T -> 'T option - [] /// Get the value of a 'Some' option. A NullReferenceException is raised if the option is 'None'. + [] member Value : 'T /// Return 'true' if the option is a 'Some' value. @@ -3611,10 +3611,10 @@ namespace Microsoft.FSharp.Core [] val ( |KeyValue| ): keyValuePair:KeyValuePair<'Key,'Value> -> 'Key * 'Value - [] - [] /// Contains extension methods to allow the use of F# indexer notation with arrays. /// This module is automatically opened in all F# code. + [] + [] module ArrayExtensions = type ``[,,,]``<'T> with /// Get the index for the element offset elements away from the end of the collection. @@ -4534,22 +4534,22 @@ namespace Microsoft.FSharp.Core [] val inline defaultof<'T> : 'T - [] - /// Perform generic comparison on two values where the type of the values is not + /// Perform generic comparison on two values where the type of the values is not /// statically required to have the 'comparison' constraint. /// The result of the comparison. + [] val inline compare : 'T -> 'T -> int - [] - /// Perform generic equality on two values where the type of the values is not + /// Perform generic equality on two values where the type of the values is not /// statically required to satisfy the 'equality' constraint. /// The result of the comparison. + [] val inline equals : 'T -> 'T -> bool - [] - /// Perform generic hashing on a value where the type of the value is not + /// Perform generic hashing on a value where the type of the value is not /// statically required to satisfy the 'equality' constraint. /// The computed hash value. + [] val inline hash : 'T -> int /// A module of comparison and equality operators that are statically resolved, but which are not fully generic and do not make structural comparison. Opening this diff --git a/src/fsharp/FSharp.Core/printf.fs b/src/fsharp/FSharp.Core/printf.fs index 0dbdb801c88..9d4d69e6664 100644 --- a/src/fsharp/FSharp.Core/printf.fs +++ b/src/fsharp/FSharp.Core/printf.fs @@ -253,8 +253,8 @@ module internal PrintfImpl = i <- i + 1 buf.ToString() - [] /// Represents one step in the execution of a format string + [] type Step = | StepWithArg of prefix: string * conv: (obj -> string) | StepWithTypedArg of prefix: string * conv: (obj -> Type -> string) diff --git a/src/fsharp/FSharp.Core/quotations.fsi b/src/fsharp/FSharp.Core/quotations.fsi index 98d299d38f4..28f349f3578 100644 --- a/src/fsharp/FSharp.Core/quotations.fsi +++ b/src/fsharp/FSharp.Core/quotations.fsi @@ -409,9 +409,9 @@ type Expr = /// The expression being quoted. /// /// The resulting expression. - [] - /// + /// /// + [] static member Quote: inner:Expr -> Expr /// Builds an expression that represents a nested raw quotation literal @@ -685,8 +685,8 @@ and [] /// member Raw : Expr -[] /// Contains a set of primitive F# active patterns to analyze F# expression objects +[] module Patterns = /// An active pattern to recognize expressions that represent getting the address of a value @@ -1070,8 +1070,8 @@ module Patterns = [] val (|VarSet|_|) : input:Expr -> (Var * Expr) option -[] /// Contains a set of derived F# active patterns to analyze F# expression objects +[] module DerivedPatterns = /// An active pattern to recognize expressions that represent a (possibly curried or tupled) first class function value diff --git a/src/fsharp/FSharp.Core/reflect.fsi b/src/fsharp/FSharp.Core/reflect.fsi index 24cf082386b..fa71cc7e0a1 100644 --- a/src/fsharp/FSharp.Core/reflect.fsi +++ b/src/fsharp/FSharp.Core/reflect.fsi @@ -59,9 +59,9 @@ type UnionCaseInfo = /// member Tag: int -[] /// Contains operations associated with constructing and analyzing values associated with F# types /// such as records, unions and tuples. +[] type FSharpValue = /// Reads a field from a record value. @@ -374,8 +374,8 @@ type FSharpValue = /// static member MakeFunction: functionType:Type * implementation:(obj -> obj) -> obj -[] /// Contains operations associated with constructing and analyzing F# types such as records, unions and tuples +[] type FSharpType = /// Reads all the fields from a record value, in declaration order @@ -532,8 +532,8 @@ type FSharpType = /// static member GetFunctionElements : functionType:Type -> Type * Type -[] /// Defines further accessing additional information about F# types and F# values at runtime. +[] module FSharpReflectionExtensions = type FSharpValue with /// Creates an instance of a record type. diff --git a/src/fsharp/FSharp.Core/result.fsi b/src/fsharp/FSharp.Core/result.fsi index 956b6c80988..1753a39e2bc 100644 --- a/src/fsharp/FSharp.Core/result.fsi +++ b/src/fsharp/FSharp.Core/result.fsi @@ -4,10 +4,10 @@ namespace Microsoft.FSharp.Core open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators - [] /// Contains operations for working with values of type . /// /// Choices and Results + [] module Result = /// map f inp evaluates to match inp with Error e -> Error e | Ok x -> Ok (f x). diff --git a/src/fsharp/FSharp.Core/seq.fsi b/src/fsharp/FSharp.Core/seq.fsi index 7a948e91ac3..0812402517c 100644 --- a/src/fsharp/FSharp.Core/seq.fsi +++ b/src/fsharp/FSharp.Core/seq.fsi @@ -1162,9 +1162,6 @@ module Seq = [] val nth: index:int -> source:seq<'T> -> 'T - /// - /// - [] /// Views the given array as a sequence. /// /// The input array. @@ -1172,16 +1169,19 @@ module Seq = /// The result sequence. /// /// Thrown when the input sequence is null. + /// + /// + [] val ofArray: source:'T[] -> seq<'T> - /// - /// - [] /// Views the given list as a sequence. /// /// The input list. /// /// The result sequence. + /// + /// + [] val ofList: source:'T list -> seq<'T> /// Returns a sequence of each element in the input sequence and its predecessor, with the diff --git a/src/fsharp/FSharp.Core/seqcore.fsi b/src/fsharp/FSharp.Core/seqcore.fsi index 6e2f4d30834..ea34ce35ed5 100644 --- a/src/fsharp/FSharp.Core/seqcore.fsi +++ b/src/fsharp/FSharp.Core/seqcore.fsi @@ -53,8 +53,8 @@ namespace Microsoft.FSharp.Core.CompilerServices open Microsoft.FSharp.Core open Microsoft.FSharp.Collections - [] /// A group of functions used as part of the compiled representation of F# sequence expressions. + [] module RuntimeHelpers = [] @@ -111,8 +111,8 @@ namespace Microsoft.FSharp.Core.CompilerServices /// The initialized event. val CreateEvent: addHandler: ('Delegate -> unit) -> removeHandler: ('Delegate -> unit) -> createHandler: ((obj -> 'Args -> unit) -> 'Delegate) -> Microsoft.FSharp.Control.IEvent<'Delegate,'Args> - [] /// The F# compiler emits implementations of this type for compiled sequence expressions. + [] type GeneratedSequenceBase<'T> = /// The F# compiler emits implementations of this type for compiled sequence expressions. /// diff --git a/src/fsharp/FSharp.Core/set.fsi b/src/fsharp/FSharp.Core/set.fsi index 68506895666..03c48393912 100644 --- a/src/fsharp/FSharp.Core/set.fsi +++ b/src/fsharp/FSharp.Core/set.fsi @@ -148,10 +148,9 @@ open System.Collections.Generic open Microsoft.FSharp.Core open Microsoft.FSharp.Collections +/// Contains operations for working with values of type . [] [] - -/// Contains operations for working with values of type . module Set = /// The empty set for the type 'T. diff --git a/src/fsharp/FSharp.Core/string.fs b/src/fsharp/FSharp.Core/string.fs index 37e8fcd7d68..4ed8b4e9183 100644 --- a/src/fsharp/FSharp.Core/string.fs +++ b/src/fsharp/FSharp.Core/string.fs @@ -13,9 +13,9 @@ namespace Microsoft.FSharp.Core [] [] module String = - [] /// LOH threshold is calculated from Internal.Utilities.Library.LOH_SIZE_THRESHOLD_BYTES, /// and is equal to 80_000 / sizeof + [] let LOH_CHAR_THRESHOLD = 40_000 [] diff --git a/src/fsharp/FSharp.Core/tasks.fsi b/src/fsharp/FSharp.Core/tasks.fsi index ec2dea983b3..19102ff7661 100644 --- a/src/fsharp/FSharp.Core/tasks.fsi +++ b/src/fsharp/FSharp.Core/tasks.fsi @@ -12,12 +12,12 @@ namespace Microsoft.FSharp.Control open Microsoft.FSharp.Core.CompilerServices open Microsoft.FSharp.Collections - [] - [] - [] /// /// The extra data stored in ResumableStateMachine for tasks /// + [] + [] + [] type TaskStateMachineData<'T> = /// diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 911abb26323..6881f8d43f2 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -1472,7 +1472,7 @@ let AddIncrementalLocalAssemblyFragmentToIlxGenEnv (amap: ImportMap, isIncrement let GenILSourceMarker (g: TcGlobals) (m: range) = ILDebugPoint.Create(document=g.memoize_file m.FileIndex, line=m.StartLine, - /// NOTE: .NET && VS measure first column as column 1 + // NOTE: .NET && VS measure first column as column 1 column= m.StartColumn+1, endLine= m.EndLine, endColumn=m.EndColumn+1) @@ -5131,7 +5131,7 @@ and GenSequenceExpr GenWitnessArgsFromWitnessInfos cenv cgbuf eenvouter m cloWitnessInfos for fv in cloFreeVars do - /// State variables always get zero-initialized + // State variables always get zero-initialized if stateVarsSet.Contains fv then GenDefaultValue cenv cgbuf eenvouter (fv.Type, m) else diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index cd5f95eb116..1abbb388202 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -537,7 +537,7 @@ type InfoReader(g: TcGlobals, amap: Import.ImportMap) as this = // Remove any virtuals that are signature-equivalent to virtuals in subtypes, except for newslots // That is, keep if it's - /// (a) not virtual + // (a) not virtual // (b) is a new slot or // (c) not equivalent // We keep virtual finals around for error detection later on @@ -939,18 +939,18 @@ let TryDestStandardDelegateType (infoReader: InfoReader) m ad delTy = /// Indicates if an event info is associated with a delegate type that is a "standard" .NET delegate type /// with a sender parameter. // -/// In the F# design, we take advantage of the following idiom to simplify away the bogus "object" parameter of the -/// of the "Add" methods associated with events. If you want to access it you -/// can use AddHandler instead. +// In the F# design, we take advantage of the following idiom to simplify away the bogus "object" parameter of the +// of the "Add" methods associated with events. If you want to access it you +// can use AddHandler instead. -/// The .NET Framework guidelines indicate that the delegate type used for -/// an event should take two parameters, an "object source" parameter -/// indicating the source of the event, and an "e" parameter that -/// encapsulates any additional information about the event. The type of -/// the "e" parameter should derive from the EventArgs class. For events -/// that do not use any additional information, the .NET Framework has -/// already defined an appropriate delegate type: EventHandler. -/// (from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkEventsTutorial.asp) +// The .NET Framework guidelines indicate that the delegate type used for +// an event should take two parameters, an "object source" parameter +// indicating the source of the event, and an "e" parameter that +// encapsulates any additional information about the event. The type of +// the "e" parameter should derive from the EventArgs class. For events +// that do not use any additional information, the .NET Framework has +// already defined an appropriate delegate type: EventHandler. +// (from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkEventsTutorial.asp) let IsStandardEventInfo (infoReader: InfoReader) m ad (einfo: EventInfo) = let dty = einfo.GetDelegateType(infoReader.amap, m) match TryDestStandardDelegateType infoReader m ad dty with diff --git a/src/fsharp/InnerLambdasToTopLevelFuncs.fs b/src/fsharp/InnerLambdasToTopLevelFuncs.fs index 209900ce333..2388de90d9f 100644 --- a/src/fsharp/InnerLambdasToTopLevelFuncs.fs +++ b/src/fsharp/InnerLambdasToTopLevelFuncs.fs @@ -250,8 +250,8 @@ module Pass1_DetermineTLRAndArities = // pass2: determine reqdTypars(f) and envreq(f) - notes //------------------------------------------------------------------------- -/// What are the closing types/values for {f1, f2...} mutually defined? -/// +// What are the closing types/values for {f1, f2...} mutually defined? +// // Note: arity-met g-applications (g TLR) will translated as: // [[g @ tps ` args]] -> gHAT @ reqdTypars(g) tps ` env(g) args // so they require availability of closing types/values for g. @@ -1157,8 +1157,8 @@ module Pass4_RewriteAssembly = let pds, z = ExtractPreDecs z MakePreDecs m pds (mkTypeLambda m argtyvs (body, rty)), z - /// Lifting TLR out over constructs (disabled) - /// Lift minimally to ensure the defn is not lifted up and over defns on which it depends (disabled) + // Lifting TLR out over constructs (disabled) + // Lift minimally to ensure the defn is not lifted up and over defns on which it depends (disabled) | Expr.Match (spBind, exprm, dtree, targets, m, ty) -> let targets = Array.toList targets let dtree, z = TransDecisionTree penv z dtree diff --git a/src/fsharp/LexFilter.fs b/src/fsharp/LexFilter.fs index 6084c450f26..a9b8da1d06f 100644 --- a/src/fsharp/LexFilter.fs +++ b/src/fsharp/LexFilter.fs @@ -638,8 +638,11 @@ type LexFilterImpl (lightStatus: LightSyntaxStatus, compilingFsLib, lexer, lexbu setLexbufState state let lastTokenEnd = state.EndPos let token = lexer lexbuf - // Now we've got the token, remember the lexbuf state, associating it with the token - // and remembering it as the last observed lexbuf state for the wrapped lexer function. + + LexbufLocalXmlDocStore.AddGrabPoint(lexbuf) + + // Now we've got the token, remember the lexbuf state, associating it with the token + // and remembering it as the last observed lexbuf state for the wrapped lexer function. let tokenLexbufState = getLexbufState() savedLexbufState <- tokenLexbufState haveLexbufState <- true diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index 3367224af9d..8ae27687210 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -466,37 +466,42 @@ let MakeCalledArgs amap m (minfo: MethInfo) minst = NameOpt=nmOpt CalledArgumentType=typeOfCalledArg }) +/// /// Represents the syntactic matching between a caller of a method and the called method. /// /// The constructor takes all the information about the caller and called side of a method, match up named arguments, property setters etc., /// and returns a CalledMeth object for further analysis. +/// +/// +/// +/// +/// A function to help generate fresh type variables the property setters methods in generic classes +/// Range +/// The access domain of the place where the call is taking place +/// The method we're attempting to call +/// The 'called type arguments', i.e. the fresh generic instantiation of the method we're attempting to call +/// The 'caller type arguments', i.e. user-given generic instantiation of the method we're attempting to call +/// The property related to the method we're attempting to call, if any +/// The 'caller method arguments', i.e. a list of user-given parameter expressions, split between unnamed and named arguments +/// A function to help generate fresh type variables the property setters methods in generic classes +/// Do we allow the use of a param args method in its "expanded" form? +/// Do we allow the use of the transformation that converts out arguments as tuple returns? +/// Method parameters type CalledMeth<'T> (infoReader: InfoReader, nameEnv: NameResolutionEnv option, isCheckingAttributeCall, - /// A function to help generate fresh type variables the property setters methods in generic classes freshenMethInfo, - /// Range m, - /// The access domain of the place where the call is taking place ad, - /// The method we're attempting to call minfo: MethInfo, - /// The 'called type arguments', i.e. the fresh generic instantiation of the method we're attempting to call calledTyArgs, - /// The 'caller type arguments', i.e. user-given generic instantiation of the method we're attempting to call callerTyArgs: TType list, - /// The property related to the method we're attempting to call, if any pinfoOpt: PropInfo option, - /// The types of the actual object argument, if any callerObjArgTys: TType list, - /// The 'caller method arguments', i.e. a list of user-given parameter expressions, split between unnamed and named arguments callerArgs: CallerArgs<'T>, - /// Do we allow the use of a param args method in its "expanded" form? allowParamArgs: bool, - /// Do we allow the use of the transformation that converts out arguments as tuple returns? allowOutAndOptArgs: bool, - /// Method parameters tyargsOpt: TType option) = let g = infoReader.g diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index 9acba857687..421630da530 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -682,7 +682,7 @@ module DispatchSlotChecking = if not minfo.IsAbstract then yield GetInheritedMemberOverrideInfo g amap reqdTyRange CanImplementAnyClassHierarchySlot minfo ] - /// Check that no interface type is implied twice + // Check that no interface type is implied twice for j, _, _, impliedTys2 in reqdTyInfos do if i > j then for ty, dispatchSlots in dispatchSlotSet do diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 4785453d27c..d82b0655df7 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -135,8 +135,8 @@ let (|AbbrevOrAppTy|_|) (ty: TType) = | TType_app (tcref, _) -> Some tcref | _ -> None -[] /// Represents the item with which a named argument is associated. +[] type ArgumentContainer = /// The named argument is an argument of a method | Method of MethInfo @@ -151,8 +151,8 @@ let emptyTypeInst : TypeInst = [] type EnclosingTypeInst = TypeInst let emptyEnclosingTypeInst : EnclosingTypeInst = emptyTypeInst -[] /// Represents an item that results from name resolution +[] type Item = /// Represents the resolution of a name to an F# value or function. @@ -294,9 +294,9 @@ let valRefHash (vref: ValRef) = | ValueNone -> 0 | ValueSome v -> LanguagePrimitives.PhysicalHash v -[] /// Pairs an Item with a TyparInst showing how generic type variables of the item are instantiated at /// a particular usage point. +[] type ItemWithInst = { Item: Item TyparInst: TyparInst } @@ -353,8 +353,8 @@ type FullyQualifiedFlag = type UnqualifiedItems = LayeredMap -[] /// The environment of information used to resolve names +[] type NameResolutionEnv = { /// Display environment information for output eDisplayEnv: DisplayEnv @@ -830,12 +830,12 @@ type TypeNameResolutionFlag = | ResolveTypeNamesToCtors | ResolveTypeNamesToTypeRefs -[] -[] /// Represents information about the generic argument count of a type name when resolving it. /// /// In some situations we resolve "List" to any type definition with that name regardless of the number /// of generic arguments. In others, we know precisely how many generic arguments are needed. +[] +[] type TypeNameResolutionStaticArgsInfo = /// Indicates indefinite knowledge of type arguments | Indefinite @@ -856,8 +856,8 @@ type TypeNameResolutionStaticArgsInfo = if x.NumStaticArgs = 0 || TryDemangleGenericNameAndPos nm <> ValueNone then nm else nm + "`" + string x.NumStaticArgs -[] /// Represents information which guides name resolution of types. +[] type TypeNameResolutionInfo = | TypeNameResolutionInfo of TypeNameResolutionFlag * TypeNameResolutionStaticArgsInfo @@ -4907,7 +4907,7 @@ let rec GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m a | [] -> - /// Include all the entries in the eUnqualifiedItems table. + // Include all the entries in the eUnqualifiedItems table. for uitem in nenv.eUnqualifiedItems.Values do match uitem with | Item.UnqualifiedType _ -> () diff --git a/src/fsharp/NameResolution.fsi b/src/fsharp/NameResolution.fsi index ec2f3186af0..0b96de1fac1 100755 --- a/src/fsharp/NameResolution.fsi +++ b/src/fsharp/NameResolution.fsi @@ -30,8 +30,8 @@ type NameResolver = /// Get the active pattern elements defined in a module, if any. Cache in the slot in the module type. val ActivePatternElemsOfModuleOrNamespace: g: TcGlobals -> ModuleOrNamespaceRef -> NameMap -[] /// Represents the item with which a named argument is associated. +[] type ArgumentContainer = /// The named argument is an argument of a method | Method of MethInfo @@ -45,8 +45,8 @@ val (|AbbrevOrAppTy|_|): TType -> TyconRef option type EnclosingTypeInst = TypeInst -[] /// Represents an item that results from name resolution +[] type Item = /// Represents the resolution of a name to an F# value or function. | Value of ValRef @@ -138,9 +138,9 @@ type Item = /// This includes backticks, parens etc. member DisplayName: string -[] -/// Pairs an Item with a TyparInst showing how generic type variables of the item are instantiated at +/// Pairs an Item with a TyparInst showing how generic type variables of the item are instantiated at /// a particular usage point. +[] type ItemWithInst = { Item: Item TyparInst: TyparInst } @@ -383,8 +383,8 @@ type TcSymbolUseData = DisplayEnv: DisplayEnv Range: range } -[] /// Represents container for all name resolutions that were met so far when typechecking some particular file +[] type internal TcSymbolUses = /// Get all the uses of a particular item within the file @@ -608,4 +608,3 @@ val GetVisibleNamespacesAndModulesAtPoint: NameResolver -> NameResolutionEnv -> val IsItemResolvable: NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> string list -> Item -> bool val TrySelectExtensionMethInfoOfILExtMem: range -> ImportMap -> TType -> TyconRef * MethInfo * ExtensionMethodPriority -> MethInfo option - \ No newline at end of file diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index c051e137939..72266c6bf1f 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -1388,7 +1388,7 @@ let rec ExprHasEffect g expr = | Expr.Lambda _ | Expr.TyLambda _ | Expr.Const _ -> false - /// type applications do not have effects, with the exception of type functions + // type applications do not have effects, with the exception of type functions | Expr.App (f0, _, _, [], _) -> (IsTyFuncValRefExpr f0) || ExprHasEffect g f0 | Expr.Op (op, _, args, m) -> ExprsHaveEffect g args || OpHasEffect g m op | Expr.LetRec (binds, body, _, _) -> BindingsHaveEffect g binds || ExprHasEffect g body @@ -3383,9 +3383,9 @@ and OptimizeLambdas (vspec: Val option) cenv env topValInfo e ety = let arities = if isNil tps then arities else 1+arities let bsize = bodyinfo.TotalSize - /// Set the flag on the value indicating that direct calls can avoid a tailcall (which are expensive on .NET x86) - /// MightMakeCriticalTailcall is true whenever the body of the method may itself do a useful tailcall, e.g. has - /// an application in the last position. + // Set the flag on the value indicating that direct calls can avoid a tailcall (which are expensive on .NET x86) + // MightMakeCriticalTailcall is true whenever the body of the method may itself do a useful tailcall, e.g. has + // an application in the last position. match vspec with | Some v -> if not bodyinfo.MightMakeCriticalTailcall then diff --git a/src/fsharp/ParseAndCheckInputs.fs b/src/fsharp/ParseAndCheckInputs.fs index 7d9a952b39f..d6b690a8ad7 100644 --- a/src/fsharp/ParseAndCheckInputs.fs +++ b/src/fsharp/ParseAndCheckInputs.fs @@ -278,9 +278,11 @@ let ParseInput (lexer, errorLogger: ErrorLogger, lexbuf: UnicodeLexing.Lexbuf, d // Call the appropriate parser - for signature files or implementation files if FSharpImplFileSuffixes |> List.exists (FileSystemUtils.checkSuffix lower) then let impl = Parser.implementationFile lexer lexbuf + LexbufLocalXmlDocStore.ReportInvalidXmlDocPositions(lexbuf) PostParseModuleImpls (defaultNamespace, filename, isLastCompiland, impl) elif FSharpSigFileSuffixes |> List.exists (FileSystemUtils.checkSuffix lower) then let intfs = Parser.signatureFile lexer lexbuf + LexbufLocalXmlDocStore.ReportInvalidXmlDocPositions(lexbuf) PostParseModuleSpecs (defaultNamespace, filename, isLastCompiland, intfs) else if lexbuf.SupportsFeature LanguageFeature.MLCompatRevisions then diff --git a/src/fsharp/ParseAndCheckInputs.fsi b/src/fsharp/ParseAndCheckInputs.fsi index dce7ab03f95..d1074191899 100644 --- a/src/fsharp/ParseAndCheckInputs.fsi +++ b/src/fsharp/ParseAndCheckInputs.fsi @@ -56,8 +56,8 @@ val ParseInputFiles: TcConfig * Lexhelp.LexResourceManager * conditionalCompilat /// applying the InternalsVisibleTo in referenced assemblies and opening 'Checked' if requested. val GetInitialTcEnv: assemblyName: string * range * TcConfig * TcImports * TcGlobals -> TcEnv * OpenDeclaration list -[] /// Represents the incremental type checking state for a set of inputs +[] type TcState = member NiceNameGenerator: NiceNameGenerator diff --git a/src/fsharp/ParseHelpers.fs b/src/fsharp/ParseHelpers.fs index d6563d78ea2..d784e4d73ac 100644 --- a/src/fsharp/ParseHelpers.fs +++ b/src/fsharp/ParseHelpers.fs @@ -5,6 +5,7 @@ module FSharp.Compiler.ParseHelpers open FSharp.Compiler.AbstractIL open FSharp.Compiler.ErrorLogger open FSharp.Compiler.Features +open FSharp.Compiler.Syntax open FSharp.Compiler.SyntaxTreeOps open FSharp.Compiler.UnicodeLexing open FSharp.Compiler.Text @@ -91,31 +92,57 @@ module LexbufLocalXmlDocStore = // The key into the BufferLocalStore used to hold the current accumulated XmlDoc lines let private xmlDocKey = "XmlDoc" + let private getCollector (lexbuf: Lexbuf) = + match lexbuf.BufferLocalStore.TryGetValue xmlDocKey with + | true, collector -> collector + | _ -> + let collector = box (XmlDocCollector()) + lexbuf.BufferLocalStore.[xmlDocKey] <- collector + collector + + |> unbox + let ClearXmlDoc (lexbuf: Lexbuf) = lexbuf.BufferLocalStore.[xmlDocKey] <- box (XmlDocCollector()) /// Called from the lexer to save a single line of XML doc comment. let SaveXmlDocLine (lexbuf: Lexbuf, lineText, range: range) = - let collector = - match lexbuf.BufferLocalStore.TryGetValue xmlDocKey with - | true, collector -> collector - | _ -> - let collector = box (XmlDocCollector()) - lexbuf.BufferLocalStore.[xmlDocKey] <- collector - collector - let collector = unbox(collector) + let collector = getCollector lexbuf collector.AddXmlDocLine(lineText, range) + let AddGrabPoint (lexbuf: Lexbuf) = + let collector = getCollector lexbuf + let startPos = lexbuf.StartPos + collector.AddGrabPoint(mkPos startPos.Line startPos.Column) + + /// Allowed cases when there are comments after XmlDoc + /// + /// /// X xmlDoc + /// // comment + /// //// comment + /// (* multiline comment *) + /// let x = ... // X xmlDoc + /// + /// Remember the first position when a comment (//, (* *), ////) is encountered after the XmlDoc block + /// then add a grab point if a new XmlDoc block follows the comments + let AddGrabPointDelayed (lexbuf: Lexbuf) = + let collector = getCollector lexbuf + let startPos = lexbuf.StartPos + collector.AddGrabPointDelayed(mkPos startPos.Line startPos.Column) + /// Called from the parser each time we parse a construct that marks the end of an XML doc comment range, /// e.g. a 'type' declaration. The markerRange is the range of the keyword that delimits the construct. let GrabXmlDocBeforeMarker (lexbuf: Lexbuf, markerRange: range) = match lexbuf.BufferLocalStore.TryGetValue xmlDocKey with | true, collector -> let collector = unbox(collector) - PreXmlDoc.CreateFromGrabPoint(collector, markerRange.End) + PreXmlDoc.CreateFromGrabPoint(collector, markerRange.Start) | _ -> PreXmlDoc.Empty + let ReportInvalidXmlDocPositions (lexbuf: Lexbuf) = + let collector = getCollector lexbuf + collector.CheckInvalidXmlDocPositions() //------------------------------------------------------------------------ // Parsing/lexing: status of #if/#endif processing in lexing, used for continutations @@ -252,3 +279,12 @@ let ParseAssemblyCodeType s reportLibraryOnlyFeatures langVersion m = IL.PrimaryAssemblyILGlobals.typ_Object #endif +let grabXmlDocAtRangeStart(parseState: IParseState, optAttributes: SynAttributeList list, range: range) = + let grabPoint = + match optAttributes with + | [] -> range + | h :: _ -> h.Range + LexbufLocalXmlDocStore.GrabXmlDocBeforeMarker(parseState.LexBuffer, grabPoint) + +let grabXmlDoc(parseState: IParseState, optAttributes: SynAttributeList list, elemIdx) = + grabXmlDocAtRangeStart(parseState, optAttributes, rhs parseState elemIdx) diff --git a/src/fsharp/ParseHelpers.fsi b/src/fsharp/ParseHelpers.fsi index 0e28f8d193c..b97158e4b6f 100644 --- a/src/fsharp/ParseHelpers.fsi +++ b/src/fsharp/ParseHelpers.fsi @@ -3,6 +3,7 @@ module internal FSharp.Compiler.ParseHelpers open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.Syntax open FSharp.Compiler.Features open FSharp.Compiler.Text open FSharp.Compiler.Xml @@ -46,7 +47,13 @@ module LexbufLocalXmlDocStore = val SaveXmlDocLine: lexbuf:UnicodeLexing.Lexbuf * lineText:string * range:range -> unit val GrabXmlDocBeforeMarker: lexbuf:UnicodeLexing.Lexbuf * markerRange:range -> PreXmlDoc - + + val AddGrabPoint: lexbuf:UnicodeLexing.Lexbuf -> unit + + val AddGrabPointDelayed: lexbuf:UnicodeLexing.Lexbuf -> unit + + val ReportInvalidXmlDocPositions: lexbuf:UnicodeLexing.Lexbuf -> unit + type LexerIfdefStackEntry = | IfDefIf | IfDefElse @@ -111,4 +118,8 @@ and LexCont = LexerContinuation val ParseAssemblyCodeInstructions: s:string -> reportLibraryOnlyFeatures: bool -> langVersion: LanguageVersion -> m:range -> ILInstr[] +val grabXmlDocAtRangeStart: parseState: IParseState * optAttributes: SynAttributeList list * range: range -> PreXmlDoc + +val grabXmlDoc: parseState: IParseState * optAttributes: SynAttributeList list * elemIdx: int -> PreXmlDoc + val ParseAssemblyCodeType: s:string -> reportLibraryOnlyFeatures: bool -> langVersion: LanguageVersion -> m:range -> ILType diff --git a/src/fsharp/QueueList.fs b/src/fsharp/QueueList.fs index 49015631dfb..cb823d0bd87 100644 --- a/src/fsharp/QueueList.fs +++ b/src/fsharp/QueueList.fs @@ -44,7 +44,7 @@ type internal QueueList<'T>(firstElementsIn:'T list, lastElementsRevIn: 'T list, let lastElementsRevIn = List.rev newElements @ lastElementsRev QueueList(firstElements, lastElementsRevIn, numLastElementsIn + newLength) - /// This operation is O(n) anyway, so executing ToList() here is OK + // This operation is O(n) anyway, so executing ToList() here is OK interface IEnumerable<'T> with member x.GetEnumerator() : IEnumerator<'T> = (x.ToList() :> IEnumerable<_>).GetEnumerator() diff --git a/src/fsharp/ScriptClosure.fs b/src/fsharp/ScriptClosure.fs index dd06780ce3c..8bf4de50d9e 100644 --- a/src/fsharp/ScriptClosure.fs +++ b/src/fsharp/ScriptClosure.fs @@ -471,7 +471,7 @@ module ScriptPreprocessClosure = type LoadClosure with /// Analyze a script text and find the closure of its references. /// Used from FCS, when editing a script file. - // + /// /// A temporary TcConfig is created along the way, is why this routine takes so many arguments. We want to be sure to use exactly the /// same arguments as the rest of the application. static member ComputeClosureOfScriptText diff --git a/src/fsharp/ScriptClosure.fsi b/src/fsharp/ScriptClosure.fsi index 8831b0f49ab..29957edb3be 100644 --- a/src/fsharp/ScriptClosure.fsi +++ b/src/fsharp/ScriptClosure.fsi @@ -73,8 +73,8 @@ type LoadClosure = /// Analyze a script text and find the closure of its references. /// Used from FCS, when editing a script file. // - /// A temporary TcConfig is created along the way, is why this routine takes so many arguments. We want to be sure to use exactly the - /// same arguments as the rest of the application. + // A temporary TcConfig is created along the way, is why this routine takes so many arguments. We want to be sure to use exactly the + // same arguments as the rest of the application. static member ComputeClosureOfScriptText: legacyReferenceResolver: LegacyReferenceResolver * defaultFSharpBinariesDir: string * diff --git a/src/fsharp/SyntaxTreeOps.fs b/src/fsharp/SyntaxTreeOps.fs index 207a122ed9c..938fb418018 100644 --- a/src/fsharp/SyntaxTreeOps.fs +++ b/src/fsharp/SyntaxTreeOps.fs @@ -89,9 +89,9 @@ let rec IsControlFlowExpression e = | SynExpr.Typed (e, _, _) -> IsControlFlowExpression e | _ -> false -let mkSynAnonField (ty: SynType) = SynField([], false, None, ty, false, PreXmlDoc.Empty, None, ty.Range) +let mkSynAnonField (ty: SynType, xmlDoc) = SynField([], false, None, ty, false, xmlDoc, None, ty.Range) -let mkSynNamedField (ident, ty: SynType, m) = SynField([], false, Some ident, ty, false, PreXmlDoc.Empty, None, m) +let mkSynNamedField (ident, ty: SynType, xmlDoc, m) = SynField([], false, Some ident, ty, false, xmlDoc, None, m) let mkSynPatVar vis (id: Ident) = SynPat.Named (id, false, vis, id.idRange) diff --git a/src/fsharp/SyntaxTreeOps.fsi b/src/fsharp/SyntaxTreeOps.fsi index c4274fb9584..3183c9cb819 100644 --- a/src/fsharp/SyntaxTreeOps.fsi +++ b/src/fsharp/SyntaxTreeOps.fsi @@ -48,9 +48,9 @@ val (|SingleIdent|_|): inp:SynExpr -> Ident option /// This affects placement of sequence points val IsControlFlowExpression: e:SynExpr -> bool -val mkSynAnonField: ty:SynType -> SynField +val mkSynAnonField: ty:SynType * xmlDoc:PreXmlDoc -> SynField -val mkSynNamedField: ident:Ident * ty:SynType * m:range -> SynField +val mkSynNamedField: ident:Ident * ty:SynType * xmlDoc:PreXmlDoc * m:range -> SynField val mkSynPatVar: vis:SynAccess option -> id:Ident -> SynPat diff --git a/src/fsharp/TypedTree.fs b/src/fsharp/TypedTree.fs index cc4545ee69c..75b9073f9a9 100644 --- a/src/fsharp/TypedTree.fs +++ b/src/fsharp/TypedTree.fs @@ -67,8 +67,8 @@ type ValMutability = | Immutable | Mutable -[] /// Indicates if a type parameter is needed at runtime and may not be eliminated +[] type TyparDynamicReq = /// Indicates the type parameter is not needed at runtime and may be eliminated @@ -92,8 +92,8 @@ type ValBaseOrThisInfo = /// Indicates the 'this' value specified in a memberm e.g. 'x' in 'member x.M() = 1' | MemberThisVal -[] /// Flags on values +[] type ValFlags(flags: int64) = new (recValInfo, baseOrThis, isCompGen, inlineInfo, isMutable, isModuleOrMemberBinding, isExtensionMember, isIncrClassSpecialMember, isTyFunc, allowTypeInst, isGeneratedEventVal) = @@ -5259,22 +5259,22 @@ type CcuReference = string // ILAssemblyRef /// A relinkable handle to the contents of a compilation unit. Relinking is performed by mutation. // -/// A compilation unit is, more or less, the new material created in one -/// invocation of the compiler. Due to static linking assemblies may hold more -/// than one compilation unit (i.e. when two assemblies are merged into a compilation -/// the resulting assembly will contain 3 CUs). Compilation units are also created for referenced -/// .NET assemblies. -/// -/// References to items such as type constructors are via -/// cross-compilation-unit thunks, which directly reference the data structures that define -/// these modules. Thus, when saving out values to disk we only wish -/// to save out the "current" part of the term graph. When reading values -/// back in we "fixup" the links to previously referenced modules. -/// -/// All non-local accesses to the data structures are mediated -/// by ccu-thunks. Ultimately, a ccu-thunk is either a (named) element of -/// the data structure, or it is a delayed fixup, i.e. an invalid dangling -/// reference that has not had an appropriate fixup applied. +// A compilation unit is, more or less, the new material created in one +// invocation of the compiler. Due to static linking assemblies may hold more +// than one compilation unit (i.e. when two assemblies are merged into a compilation +// the resulting assembly will contain 3 CUs). Compilation units are also created for referenced +// .NET assemblies. +// +// References to items such as type constructors are via +// cross-compilation-unit thunks, which directly reference the data structures that define +// these modules. Thus, when saving out values to disk we only wish +// to save out the "current" part of the term graph. When reading values +// back in we "fixup" the links to previously referenced modules. +// +// All non-local accesses to the data structures are mediated +// by ccu-thunks. Ultimately, a ccu-thunk is either a (named) element of +// the data structure, or it is a delayed fixup, i.e. an invalid dangling +// reference that has not had an appropriate fixup applied. [] type CcuThunk = { diff --git a/src/fsharp/TypedTreeOps.fs b/src/fsharp/TypedTreeOps.fs index 4996150ed88..b93c31f7fe2 100644 --- a/src/fsharp/TypedTreeOps.fs +++ b/src/fsharp/TypedTreeOps.fs @@ -1976,7 +1976,7 @@ let unionFreeTypars s1 s2 = let emptyFreeTyvars = { FreeTycons = emptyFreeTycons - /// The summary of values used as trait solutions + // The summary of values used as trait solutions FreeTraitSolutions = emptyFreeLocals FreeTypars = emptyFreeTypars} diff --git a/src/fsharp/XmlDoc.fs b/src/fsharp/XmlDoc.fs index 3a30e6033c8..374d1c0eb54 100644 --- a/src/fsharp/XmlDoc.fs +++ b/src/fsharp/XmlDoc.fs @@ -3,6 +3,7 @@ namespace FSharp.Compiler.Xml open System +open System.Collections.Generic open System.IO open System.Xml open System.Xml.Linq @@ -11,7 +12,6 @@ open Internal.Utilities.Collections open FSharp.Compiler.ErrorLogger open FSharp.Compiler.IO open FSharp.Compiler.Text -open FSharp.Compiler.Text.Position open FSharp.Compiler.Text.Range open FSharp.Compiler.AbstractIL.IL @@ -146,44 +146,62 @@ and XmlDocStatics() = /// Used to collect XML documentation during lexing and parsing. type XmlDocCollector() = let mutable savedLines = ResizeArray() - let mutable savedGrabPoints = ResizeArray() - let posCompare p1 p2 = if posGeq p1 p2 then 1 else if posEq p1 p2 then 0 else -1 - let savedGrabPointsAsArray = - lazy (savedGrabPoints.ToArray() |> Array.sortWith posCompare) - - let savedLinesAsArray = - lazy (savedLines.ToArray() |> Array.sortWith (fun (_, p1) (_, p2) -> posCompare p1.End p2.End)) + let mutable savedGrabPoints = Dictionary() + let mutable currentGrabPointCommentsCount = 0 + let mutable delayedGrabPoint = ValueNone + let savedLinesAsArray = lazy (savedLines.ToArray()) let check() = // can't add more XmlDoc elements to XmlDocCollector after extracting first XmlDoc from the overall results assert (not savedLinesAsArray.IsValueCreated) - member x.AddGrabPoint pos = + member x.AddGrabPoint(pos: pos) = + check() + if currentGrabPointCommentsCount = 0 then () else + let xmlDocBlock = struct(savedLines.Count - currentGrabPointCommentsCount, savedLines.Count - 1, false) + savedGrabPoints.Add(pos, xmlDocBlock) + currentGrabPointCommentsCount <- 0 + delayedGrabPoint <- ValueNone + + member x.AddGrabPointDelayed(pos: pos) = check() - savedGrabPoints.Add pos + if currentGrabPointCommentsCount = 0 then () else + match delayedGrabPoint with + | ValueNone -> delayedGrabPoint <- ValueSome(pos) + | _ -> () member x.AddXmlDocLine(line, range) = check() + match delayedGrabPoint with + | ValueNone -> () + | ValueSome pos -> x.AddGrabPoint(pos) // Commit delayed grab point + savedLines.Add(line, range) + currentGrabPointCommentsCount <- currentGrabPointCommentsCount + 1 member x.LinesBefore grabPointPos = - try let lines = savedLinesAsArray.Force() - let grabPoints = savedGrabPointsAsArray.Force() - let firstLineIndexAfterGrabPoint = Array.findFirstIndexWhereTrue lines (fun (_, m) -> posGeq m.End grabPointPos) - let grabPointIndex = Array.findFirstIndexWhereTrue grabPoints (fun pos -> posGeq pos grabPointPos) - assert (posEq grabPoints.[grabPointIndex] grabPointPos) - let firstLineIndexAfterPrevGrabPoint = - if grabPointIndex = 0 then - 0 - else - let prevGrabPointPos = grabPoints.[grabPointIndex-1] - Array.findFirstIndexWhereTrue lines (fun (_, m) -> posGeq m.End prevGrabPointPos) + match savedGrabPoints.TryGetValue grabPointPos with + | true, struct(startIndex, endIndex, _) -> lines.[startIndex .. endIndex] + | false, _ -> [||] - let lines = lines.[firstLineIndexAfterPrevGrabPoint..firstLineIndexAfterGrabPoint-1] - lines - with e -> - [| |] + member x.SetXmlDocValidity(grabPointPos, isValid) = + match savedGrabPoints.TryGetValue grabPointPos with + | true, struct(startIndex, endIndex, _) -> + savedGrabPoints.[grabPointPos] <- struct(startIndex, endIndex, isValid) + | _ -> () + + member x.HasComments grabPointPos = + savedGrabPoints.TryGetValue grabPointPos |> fst + + member x.CheckInvalidXmlDocPositions() = + let lines = savedLinesAsArray.Force() + for startIndex, endIndex, isValid in savedGrabPoints.Values do + if isValid then () else + let _, startRange = lines.[startIndex] + let _, endRange = lines.[endIndex] + let range = unionRanges startRange endRange + informationalWarning (Error(FSComp.SR.invalidXmlDocPosition(), range)) /// Represents the XmlDoc fragments as collected from the lexer during parsing type PreXmlDoc = @@ -209,8 +227,20 @@ type PreXmlDoc = doc.Check(paramNamesOpt) doc + member x.IsEmpty = + match x with + | PreXmlDirect (lines, _) -> lines |> Array.forall String.IsNullOrWhiteSpace + | PreXmlMerge(a, b) -> a.IsEmpty && b.IsEmpty + | PreXmlDocEmpty -> true + | PreXmlDoc (pos, collector) -> not (collector.HasComments pos) + + member x.MarkAsInvalid() = + match x with + | PreXmlDoc (pos, collector) -> collector.SetXmlDocValidity(pos, false) + | _ -> () + static member CreateFromGrabPoint(collector: XmlDocCollector, grabPointPos) = - collector.AddGrabPoint grabPointPos + collector.SetXmlDocValidity(grabPointPos, true) PreXmlDoc(grabPointPos, collector) static member Empty = PreXmlDocEmpty diff --git a/src/fsharp/XmlDoc.fsi b/src/fsharp/XmlDoc.fsi index e451312f4a5..00faec7ddbe 100644 --- a/src/fsharp/XmlDoc.fsi +++ b/src/fsharp/XmlDoc.fsi @@ -41,10 +41,16 @@ type internal XmlDocCollector = member AddGrabPoint: pos: pos -> unit + member AddGrabPointDelayed: pos: pos -> unit + member AddXmlDocLine: line:string * range:range -> unit member LinesBefore: grabPointPos: pos -> (string * range) [] - + + member HasComments: grabPointPos: pos -> bool + + member CheckInvalidXmlDocPositions: unit -> unit + /// Represents the XmlDoc fragments as collected from the lexer during parsing [] type public PreXmlDoc = @@ -57,6 +63,10 @@ type public PreXmlDoc = member ToXmlDoc: check:bool * paramNamesOpt:string list option -> XmlDoc + member IsEmpty: bool + + member internal MarkAsInvalid: unit -> unit + static member Empty: PreXmlDoc [] diff --git a/src/fsharp/XmlDocFileWriter.fs b/src/fsharp/XmlDocFileWriter.fs index 60ec69d07ac..26fa5b01327 100644 --- a/src/fsharp/XmlDocFileWriter.fs +++ b/src/fsharp/XmlDocFileWriter.fs @@ -23,8 +23,15 @@ module XmlDocWriter = if (hasDoc tc.XmlDoc) then tc.XmlDocSig <- XmlDocSigOfTycon [ptext; tc.CompiledName] for vref in tc.MembersOfFSharpTyconSorted do doValSig ptext vref.Deref + for uc in tc.UnionCasesArray do - if (hasDoc uc.XmlDoc) then uc.XmlDocSig <- XmlDocSigOfUnionCase [ptext; tc.CompiledName; uc.Id.idText] + if (hasDoc uc.XmlDoc) then + uc.XmlDocSig <- XmlDocSigOfUnionCase [ptext; tc.CompiledName; uc.Id.idText] + for field in uc.RecdFieldsArray do + if (hasDoc field.XmlDoc) then + // union case fields are exposed as properties + field.XmlDocSig <- XmlDocSigOfProperty [ptext; tc.CompiledName; uc.Id.idText; field.Id.idText] + for rf in tc.AllFieldsArray do if (hasDoc rf.XmlDoc) then rf.XmlDocSig <- @@ -68,9 +75,12 @@ module XmlDocWriter = let doc = xmlDoc.GetXmlText() members <- (id, doc) :: members let doVal (v: Val) = addMember v.XmlDocSig v.XmlDoc - let doUnionCase (uc: UnionCase) = addMember uc.XmlDocSig uc.XmlDoc let doField (rf: RecdField) = addMember rf.XmlDocSig rf.XmlDoc - let doTycon (tc: Tycon) = + let doUnionCase (uc: UnionCase) = + addMember uc.XmlDocSig uc.XmlDoc + for field in uc.RecdFieldsArray do + addMember field.XmlDocSig field.XmlDoc + let doTycon (tc: Tycon) = addMember tc.XmlDocSig tc.XmlDoc for vref in tc.MembersOfFSharpTyconSorted do doVal vref.Deref diff --git a/src/fsharp/absil/illib.fs b/src/fsharp/absil/illib.fs index 2cd1f328f82..26e99a0ce6f 100644 --- a/src/fsharp/absil/illib.fs +++ b/src/fsharp/absil/illib.fs @@ -100,8 +100,8 @@ module internal PervasiveAutoOpens = cancellationToken) task.Result -[] /// An efficient lazy for inline storage in a class type. Results in fewer thunks. +[] type InlineDelayInit<'T when 'T : not struct> = new (f: unit -> 'T) = {store = Unchecked.defaultof<'T>; func = Func<_>(f) } val mutable store : 'T @@ -504,8 +504,8 @@ module ResizeArray = // rounding down here is good because it ensures we don't go over let maxArrayItemCount = LOH_SIZE_THRESHOLD_BYTES / itemSizeBytes - /// chunk the provided input into arrays that are smaller than the LOH limit - /// in order to prevent long-term storage of those values + // chunk the provided input into arrays that are smaller than the LOH limit + // in order to prevent long-term storage of those values chunkBySize maxArrayItemCount f inp module ValueOptionInternal = diff --git a/src/fsharp/absil/ilread.fs b/src/fsharp/absil/ilread.fs index 6e497b1ccc6..1b8e55dcc23 100644 --- a/src/fsharp/absil/ilread.fs +++ b/src/fsharp/absil/ilread.fs @@ -193,7 +193,7 @@ type WeakByteFile(fileName: string, chunk: (int * int) option) = member _.FileName = fileName - /// Get the bytes for the file + // Get the bytes for the file interface BinaryFile with override this.GetView() = @@ -3874,7 +3874,7 @@ type ILModuleReader = abstract ILModuleDef: ILModuleDef abstract ILAssemblyRefs: ILAssemblyRef list - /// ILModuleReader objects only need to be explicitly disposed if memory mapping is used, i.e. reduceMemoryUsage = false + // ILModuleReader objects only need to be explicitly disposed if memory mapping is used, i.e. reduceMemoryUsage = false inherit IDisposable [] diff --git a/src/fsharp/absil/ilread.fsi b/src/fsharp/absil/ilread.fsi index a9cc50ad0c1..09c1a1bca91 100644 --- a/src/fsharp/absil/ilread.fsi +++ b/src/fsharp/absil/ilread.fsi @@ -65,7 +65,7 @@ type public ILModuleReader = abstract ILModuleDef: ILModuleDef abstract ILAssemblyRefs: ILAssemblyRef list - /// ILModuleReader objects only need to be explicitly disposed if memory mapping is used, i.e. reduceMemoryUsage = false + // ILModuleReader objects only need to be explicitly disposed if memory mapping is used, i.e. reduceMemoryUsage = false inherit System.IDisposable diff --git a/src/fsharp/absil/ilwrite.fs b/src/fsharp/absil/ilwrite.fs index e63d543677b..7ddd68e404c 100644 --- a/src/fsharp/absil/ilwrite.fs +++ b/src/fsharp/absil/ilwrite.fs @@ -4330,7 +4330,7 @@ and writePdb (dumpDebugInfo, showTimes, portablePDB, embeddedPDB, pdbfile, outfi end reportTime showTimes "Finalize PDB" - /// Sign the binary. No further changes to binary allowed past this point! + // Sign the binary. No further changes to binary allowed past this point! match signer with | None -> () | Some s -> diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index ee962657ad1..730f582d29d 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -234,9 +234,9 @@ type EvaluationEventArgs(fsivalue : FsiValue option, symbolUse : FSharpSymbolUse member x.Symbol = symbolUse.Symbol member x.ImplementationDeclaration = decl -[] /// User-configurable information that changes how F# Interactive operates, stored in the 'fsi' object /// and accessible via the programming model +[] type FsiEvaluationSessionHostConfig () = let evaluationEvent = Event() /// Called by the evaluation session to ask the host for parameters to format text for output @@ -940,7 +940,7 @@ type internal FsiConsoleInput(fsi: FsiEvaluationSessionHostConfig, fsiOptions: F /// When using a key-reading console this holds the first line after it is read let mutable firstLine = None - /// Peek on the standard input so that the user can type into it from a console window. + // Peek on the standard input so that the user can type into it from a console window. do if fsiOptions.Interact then if fsiOptions.PeekAheadOnConsoleToPermitTyping then (Thread(fun () -> @@ -1416,7 +1416,7 @@ type internal FsiDynamicCompiler let infoReader = InfoReader(istate.tcGlobals, istate.tcImports.GetImportMap()) valuePrinter.InvokeExprPrinter (istate.tcState.TcEnvFromImpls.DisplayEnv, infoReader, istate.emEnv, istate.ilxGenerator, vref) - /// Clear the value held in the previous "it" binding, if any, as long as it has never been referenced. + // Clear the value held in the previous "it" binding, if any, as long as it has never been referenced. match prevIt with | Some prevVal when not prevVal.Deref.HasBeenReferenced -> istate.ilxGenerator.ClearGeneratedValue (valuePrinter.GetEvaluationContext istate.emEnv, prevVal.Deref) diff --git a/src/fsharp/fsi/fsi.fsi b/src/fsharp/fsi/fsi.fsi index 63f8d980c71..30c11444556 100644 --- a/src/fsharp/fsi/fsi.fsi +++ b/src/fsharp/fsi/fsi.fsi @@ -9,8 +9,8 @@ open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.Diagnostics open FSharp.Compiler.Symbols -[] /// Represents an evaluated F# value +[] type FsiValue = /// The value, as an object @@ -22,8 +22,8 @@ type FsiValue = /// The type of the value, from the point of view of the F# type system member FSharpType: FSharpType -[] /// Represents an evaluated F# value that is bound to an identifier +[] type FsiBoundValue = /// The identifier of the value @@ -307,8 +307,8 @@ module Settings = /// Schedule a restart for the event loop. abstract ScheduleRestart: unit -> unit - [] /// Operations supported by the currently executing F# Interactive session. + [] type InteractiveSettings = /// Get or set the floating point format used in the output of the interactive session. member FloatingPointFormat: string with get,set diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index 3c60e70ddbd..a1f2b836e2d 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -98,8 +98,8 @@ let GetSuperTypeOfType g amap m ty = /// Make a type for System.Collections.Generic.IList let mkSystemCollectionsGenericIListTy (g: TcGlobals) ty = TType_app(g.tcref_System_Collections_Generic_IList, [ty]) -[] /// Indicates whether we can skip interface types that lie outside the reference set +[] type SkipUnrefInterfaces = Yes | No /// Collect the set of immediate declared interface types for an F# type, but do not @@ -600,8 +600,8 @@ type ReflectedArgInfo = //------------------------------------------------------------------------- // ParamNameAndType, ParamData -[] /// Partial information about a parameter returned for use by the Language Service +[] type ParamNameAndType = | ParamNameAndType of Ident option * TType @@ -610,8 +610,8 @@ type ParamNameAndType = static member Instantiate inst p = let (ParamNameAndType(nm, ty)) = p in ParamNameAndType(nm, instType inst ty) static member InstantiateCurried inst paramTypes = paramTypes |> List.mapSquared (ParamNameAndType.Instantiate inst) -[] /// Full information about a parameter returned for use by the type checker and language service. +[] type ParamData = ParamData of isParamArray: bool * diff --git a/src/fsharp/lex.fsl b/src/fsharp/lex.fsl index f726fcafbd8..ee25919853d 100644 --- a/src/fsharp/lex.fsl +++ b/src/fsharp/lex.fsl @@ -679,6 +679,7 @@ rule token args skip = parse | "////" op_char* { // 4+ slash are 1-line comments, online 3 slash are XmlDoc let m = lexbuf.LexemeRange + LexbufLocalXmlDocStore.AddGrabPointDelayed(lexbuf) if not skip then LINE_COMMENT (LexCont.SingleLineComment(args.ifdefStack, args.stringNest, 1, m)) else singleLineComment (None,1,m,args) skip lexbuf } @@ -693,6 +694,7 @@ rule token args skip = parse | "//" op_char* { // Need to read all operator symbols too, otherwise it might be parsed by a rule below let m = lexbuf.LexemeRange + LexbufLocalXmlDocStore.AddGrabPointDelayed(lexbuf) if not skip then LINE_COMMENT (LexCont.SingleLineComment(args.ifdefStack, args.stringNest, 1, m)) else singleLineComment (None,1,m,args) skip lexbuf } @@ -1459,6 +1461,7 @@ and comment cargs skip = parse | "(*)" { let n, m, args = cargs + LexbufLocalXmlDocStore.AddGrabPoint(lexbuf) if not skip then COMMENT (LexCont.Comment(args.ifdefStack, args.stringNest, n, m)) else comment cargs skip lexbuf } @@ -1479,6 +1482,7 @@ and comment cargs skip = parse if not skip then COMMENT (LexCont.Comment(args.ifdefStack, args.stringNest, n-1, m)) else comment (n-1,m,args) skip lexbuf else + LexbufLocalXmlDocStore.AddGrabPointDelayed(lexbuf) if not skip then COMMENT (LexCont.Token(args.ifdefStack, args.stringNest)) else token args skip lexbuf } diff --git a/src/fsharp/pars.fsy b/src/fsharp/pars.fsy index d4dd38e53d2..169dcab0970 100644 --- a/src/fsharp/pars.fsy +++ b/src/fsharp/pars.fsy @@ -182,9 +182,6 @@ let checkForMultipleAugmentations m a1 a2 = if not (isNil a1) && not (isNil a2) then raiseParseErrorAt m (FSComp.SR.parsOnlyOneWithAugmentationAllowed()) a1 @ a2 -let grabXmlDoc(parseState:IParseState, elemIdx) = - LexbufLocalXmlDocStore.GrabXmlDocBeforeMarker(parseState.LexBuffer, rhs parseState elemIdx) - let rangeOfLongIdent(lid:LongIdent) = System.Diagnostics.Debug.Assert(not lid.IsEmpty, "the parser should never produce a long-id that is the empty list") (lid.Head.idRange, lid) ||> unionRangeWithListBy (fun id -> id.idRange) @@ -678,13 +675,13 @@ moduleIntro: | moduleKeyword opt_attributes opt_access opt_rec path { if not (isNil $2) then parseState.LexBuffer.CheckLanguageFeatureErrorRecover LanguageFeature.AttributesToRightOfModuleKeyword <| rhs parseState 4 - $4, $5.Lid, grabXmlDoc(parseState, 1), $3, $2 } + $4, $5.Lid, $3, $2 } /* The start of a namespace declaration */ namespaceIntro: | NAMESPACE opt_rec path - { $2, $3.Lid, grabXmlDoc(parseState, 1) } + { $2, $3.Lid, grabXmlDoc(parseState, [], 1) } /* The contents of a signature file */ @@ -728,11 +725,12 @@ fileModuleSpec: let m2 = rhs parseState 3 let mDeclsAndAttrs = (List.map (fun (a: SynAttributeList) -> a.Range) $1) @ (List.map (fun (d: SynModuleSigDecl) -> d.Range) $4) let m = (m2, mDeclsAndAttrs) ||> unionRangeWithListBy id - let isRec, path2, xml, vis, attribs2 = $3 + let isRec, path2, vis, attribs2 = $3 + let xmlDoc = grabXmlDoc(parseState, $1, 1) (fun (isRec2, path, _) -> if not (isNil path) then errorR(Error(FSComp.SR.parsNamespaceOrModuleNotBoth(), m2)) let lid = path@path2 - ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, (isRec || isRec2), SynModuleOrNamespaceKind.NamedModule, $4, xml, $1 @ attribs2, vis, m))) } + ParsedSigFileFragment.NamedModule(SynModuleOrNamespaceSig(lid, (isRec || isRec2), SynModuleOrNamespaceKind.NamedModule, $4, xmlDoc, $1 @ attribs2, vis, m))) } | moduleSpfnsPossiblyEmptyBlock { let m = (rhs parseState 1) @@ -793,7 +791,7 @@ moduleSpfn: | opt_attributes opt_declVisibility moduleIntro colonOrEquals namedModuleAbbrevBlock { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) - let isRec, path, xml, vis, attribs2 = $3 + let isRec, path, vis, attribs2 = $3 if isRec then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsInvalidUseOfRec()) if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName()) if not (isNil $1) then raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreAttributesOnModuleAbbreviation()) @@ -803,34 +801,33 @@ moduleSpfn: | _ -> SynModuleSigDecl.ModuleAbbrev(List.head path, $5, rhs2 parseState 1 5) } | opt_attributes opt_declVisibility moduleIntro colonOrEquals moduleSpecBlock - { let isRec, path, xml, vis, attribs2 = $3 + { let isRec, path, vis, attribs2 = $3 + let xmlDoc = grabXmlDoc(parseState, $1, 1) if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleDefnMustBeSimpleName()) if isRec then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsInvalidUseOfRec()) - let info = SynComponentInfo($1 @ attribs2, None, [], path, xml, false, vis, rhs parseState 3) + let info = SynComponentInfo($1 @ attribs2, None, [], path, xmlDoc, false, vis, rhs parseState 3) if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) let m = (rhs2 parseState 1 4, $5) ||> unionRangeWithListBy (fun (d: SynModuleSigDecl) -> d.Range) SynModuleSigDecl.NestedModule(info, isRec, $5, m) } - | opt_attributes opt_declVisibility typeKeyword tyconSpfnList - { if Option.isSome $2 then - errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) - - match $4 with - | [] -> raiseParseErrorAt (rhs2 parseState 3 4) (FSComp.SR.parsUnexpectedEmptyModuleDefn ()) - | SynTypeDefnSig (SynComponentInfo (cas, a, cs, b, c, d, d2, d3), e, f, g) :: tail -> - let attrs = $1 @ cas - let mTc = - let keywordM = rhs parseState 3 - (keywordM, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) |> unionRanges g - let tc = (SynTypeDefnSig(SynComponentInfo(attrs, a, cs, b, c, d, d2, d3), e, f, mTc)) - let m = (mTc, tail) ||> unionRangeWithListBy (fun (a: SynTypeDefnSig) -> a.Range) - - SynModuleSigDecl.Types (tc :: tail, m) } + | opt_attributes opt_declVisibility typeKeyword tyconSpfn tyconSpfnList + { if Option.isSome $2 then errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) + let (SynTypeDefnSig (SynComponentInfo (cas, a, cs, b, _xmlDoc, d, d2, d3), e, f, g)) = $4 + _xmlDoc.MarkAsInvalid() + let attrs = $1 @ cas + let mTc = + let keywordM = rhs parseState 3 + (keywordM, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) |> unionRanges g + let xmlDoc = grabXmlDoc(parseState, $1, 1) + let tc = (SynTypeDefnSig(SynComponentInfo(attrs, a, cs, b, xmlDoc, d, d2, d3), e, f, mTc)) + let m = (mTc, $5) ||> unionRangeWithListBy (fun (a: SynTypeDefnSig) -> a.Range) + SynModuleSigDecl.Types (tc :: $5, m) } | opt_attributes opt_declVisibility exconSpfn { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) - let (SynExceptionSig(SynExceptionDefnRepr(cas, a, b, c, d, d2), e, f)) = $3 - let ec = SynExceptionSig(SynExceptionDefnRepr($1@cas, a, b, c, d, d2), e, f) + let (SynExceptionSig(SynExceptionDefnRepr(cas, a, b, c, d, d2), e, f)) = $3 + let xmlDoc = grabXmlDoc(parseState, $1, 1) + let ec = SynExceptionSig(SynExceptionDefnRepr($1@cas, a, b, xmlDoc, d, d2), e, f) SynModuleSigDecl.Exception(ec, rhs parseState 3) } | openDecl @@ -839,7 +836,7 @@ moduleSpfn: valSpfn: | opt_attributes opt_declVisibility VAL opt_attributes opt_inline opt_mutable opt_access nameop opt_explicitValTyparDecls COLON topTypeWithTypeConstraints optLiteralValueSpfn { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) - let attr1, attr2, isInline, isMutable, vis2, id, doc, explicitValTyparDecls, (ty, arity), konst = ($1), ($4), ($5), ($6), ($7), ($8), grabXmlDoc(parseState, 3), ($9), ($11), ($12) + let attr1, attr2, isInline, isMutable, vis2, id, doc, explicitValTyparDecls, (ty, arity), konst = ($1), ($4), ($5), ($6), ($7), ($8), grabXmlDoc(parseState, $1, 1), ($9), ($11), ($12) if not (isNil attr2) then errorR(Deprecated(FSComp.SR.parsAttributesMustComeBeforeVal(), rhs parseState 4)) let m = rhs2 parseState 1 11 let valSpfn = SynValSig((attr1@attr2), id, explicitValTyparDecls, ty, arity, isInline, isMutable, doc, vis2, konst, m) @@ -875,11 +872,17 @@ moduleSpecBlock: tyconSpfnList: - | tyconSpfn AND tyconSpfnList - { $1 :: $3 } - - | tyconSpfn - { [$1] } + | AND tyconSpfn tyconSpfnList + { let xmlDoc = grabXmlDoc(parseState, [], 1) + let tyconSpfn = + if xmlDoc.IsEmpty then $2 else + let (SynTypeDefnSig(SynComponentInfo (a, typars, c, lid, _xmlDoc, fixity, vis, rangeOfLid), typeRepr, members, range)) = $2 + _xmlDoc.MarkAsInvalid() + SynTypeDefnSig(SynComponentInfo (a, typars, c, lid, xmlDoc, fixity, vis, rangeOfLid), typeRepr, members, range) + tyconSpfn :: $3 } + + | + { [] } /* A type definition in a signature */ @@ -1006,7 +1009,7 @@ classSpfnMembersAtLeastOne: classMemberSpfn: | opt_attributes opt_declVisibility memberSpecFlags opt_inline opt_access nameop opt_explicitValTyparDecls COLON topTypeWithTypeConstraints classMemberSpfnGetSet optLiteralValueSpfn { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) - let isInline, doc, vis2, id, explicitValTyparDecls, (ty, arity), optLiteralValue = $4, grabXmlDoc(parseState, 3), $5, $6, $7, $9, $11 + let isInline, doc, vis2, id, explicitValTyparDecls, (ty, arity), optLiteralValue = $4, grabXmlDoc(parseState, $1, 1), $5, $6, $7, $9, $11 let getSetRangeOpt, getSet = $10 let getSetAdjuster arity = match arity, getSet with SynValInfo([], _), SynMemberKind.Member -> SynMemberKind.PropertyGet | _ -> getSet let wholeRange = @@ -1030,7 +1033,7 @@ classMemberSpfn: | opt_attributes opt_declVisibility VAL fieldDecl { let wholeRange = rhs2 parseState 1 4 if Option.isSome $2 then errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) - let fld = $4 $1 false wholeRange + let fld = $4 $1 false wholeRange SynMemberSig.ValField (fld, wholeRange) } | opt_attributes opt_declVisibility STATIC VAL fieldDecl @@ -1043,7 +1046,7 @@ classMemberSpfn: SynMemberSig.NestedType($5, rhs2 parseState 1 5) } | opt_attributes opt_declVisibility NEW COLON topTypeWithTypeConstraints - { let vis, doc, (ty, valSynInfo) = $2, grabXmlDoc(parseState, 3), $5 + { let vis, doc, (ty, valSynInfo) = $2, grabXmlDoc(parseState, $1, 1), $5 let m = unionRanges (rhs parseState 1) ty.Range let isInline = false let valSpfn = SynValSig ($1, mkSynId (rhs parseState 3) "new", noInferredTypars, ty, valSynInfo, isInline, false, doc, vis, None, m) @@ -1165,11 +1168,12 @@ fileModuleImpl: let m2 = rhs parseState 3 let mDeclsAndAttrs = (List.map (fun (a: SynAttributeList) -> a.Range) $1) @ (List.map (fun (d: SynModuleDecl) -> d.Range) $4) let m = (m2, mDeclsAndAttrs) ||> unionRangeWithListBy id - let isRec2, path2, xml, vis, attribs2 = $3 + let isRec2, path2, vis, attribs2 = $3 + let xmlDoc = grabXmlDoc(parseState, $1, 1) (fun (isRec, path, _) -> if not (isNil path) then errorR(Error(FSComp.SR.parsNamespaceOrModuleNotBoth(), m2)) let lid = path@path2 - ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, (isRec || isRec2), SynModuleOrNamespaceKind.NamedModule, $4, xml, $1@attribs2, vis, m))) } + ParsedImplFileFragment.NamedModule(SynModuleOrNamespace(lid, (isRec || isRec2), SynModuleOrNamespaceKind.NamedModule, $4, xmlDoc, $1@attribs2, vis, m))) } | moduleDefnsOrExprPossiblyEmptyOrBlock { let m = (rhs parseState 1) @@ -1293,10 +1297,12 @@ moduleDefn: /* 'type' definitions */ | opt_attributes opt_declVisibility typeKeyword tyconDefn tyconDefnList { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) - let (SynTypeDefn(SynComponentInfo(cas, a, cs, b, c, d, d2, d3), e, f, g, h)) = $4 + let xmlDoc = grabXmlDoc(parseState, $1, 1) + let (SynTypeDefn(SynComponentInfo(cas, a, cs, b, _xmlDoc, d, d2, d3), e, f, g, h)) = $4 + _xmlDoc.MarkAsInvalid() let attrs = $1@cas let mTc = (h, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) - let tc = (SynTypeDefn(SynComponentInfo(attrs, a, cs, b, c, d, d2, d3), e, f, g, mTc)) + let tc = (SynTypeDefn(SynComponentInfo(attrs, a, cs, b, xmlDoc, d, d2, d3), e, f, g, mTc)) let types = tc :: $5 [ SynModuleDecl.Types(types, (rhs parseState 3, types) ||> unionRangeWithListBy (fun t -> t.Range) ) ] } @@ -1305,13 +1311,15 @@ moduleDefn: { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) let (SynExceptionDefn(SynExceptionDefnRepr(cas, a, b, c, d, d2), e, f)) = $3 let f = (f, $1) ||> unionRangeWithListBy (fun a -> a.Range) - let ec = (SynExceptionDefn(SynExceptionDefnRepr($1@cas, a, b, c, d, d2), e, f)) + let xmlDoc = grabXmlDoc(parseState, $1, 1) + let ec = (SynExceptionDefn(SynExceptionDefnRepr($1@cas, a, b, xmlDoc, d, d2), e, f)) [ SynModuleDecl.Exception(ec, f) ] } /* 'module' definitions */ | opt_attributes opt_declVisibility moduleIntro EQUALS namedModuleDefnBlock { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) - let attribs, (isRec, path, xml, vis, attribs2) = $1, $3 + let attribs, (isRec, path, vis, attribs2) = $1, $3 + let xmlDoc = grabXmlDoc(parseState, $1, 1) match $5 with | Choice1Of2 eqn -> if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) @@ -1325,7 +1333,7 @@ moduleDefn: [ SynModuleDecl.ModuleAbbrev(List.head path, eqn, (rhs parseState 3, eqn) ||> unionRangeWithListBy (fun id -> id.idRange) ) ] | Choice2Of2 def -> if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName()) - let info = SynComponentInfo(attribs @ attribs2, None, [], path, xml, false, vis, rhs parseState 3) + let info = SynComponentInfo(attribs @ attribs2, None, [], path, xmlDoc, false, vis, rhs parseState 3) [ SynModuleDecl.NestedModule(info, isRec, def, false, (rhs2 parseState 1 4, def) ||> unionRangeWithListBy (fun d -> d.Range) ) ] } /* unattached custom attributes */ @@ -1510,13 +1518,20 @@ memberFlags: /* The name of a type in a signature or implementation, possibly with type parameters and constraints */ typeNameInfo: | opt_attributes tyconNameAndTyparDecls opt_typeConstraints - { let typars, lid, fixity, vis, xmlDoc = $2 + { let typars, lid, fixity, vis = $2 + let xmlDoc = grabXmlDoc(parseState, $1, 1) SynComponentInfo ($1, typars, $3, lid, xmlDoc, fixity, vis, rangeOfLid lid) } /* Part of a set of type definitions */ tyconDefnList: | AND tyconDefn tyconDefnList - { $2 :: $3 } + { let xmlDoc = grabXmlDoc(parseState, [], 1) + let tyconDefn = + if xmlDoc.IsEmpty then $2 else + let (SynTypeDefn(SynComponentInfo (a, typars, c, lid, _xmlDoc, fixity, vis, rangeOfLid), typeRepr, members, implicitConstructor, range)) = $2 + _xmlDoc.MarkAsInvalid() + SynTypeDefn(SynComponentInfo (a, typars, c, lid, xmlDoc, fixity, vis, rangeOfLid), typeRepr, members, implicitConstructor, range) + tyconDefn :: $3 } | { [] } @@ -1546,9 +1561,9 @@ tyconDefn: { let vis, spats, az = $3, $5, $6 let nameRange = rhs parseState 1 let (tcDefRepr, members) = $8 nameRange - let (SynComponentInfo(_, _, _, lid, _, _, _, _)) = $1 + let (SynComponentInfo(_, _, _, lid, _, _, _, _)) = $1 // Gets the XML doc comments prior to the implicit constructor - let xmlDoc = grabXmlDoc(parseState, 5) + let xmlDoc = grabXmlDoc(parseState, $2, 2) let memberCtorPattern = SynMemberDefn.ImplicitCtor (vis, $2, spats, az, xmlDoc, rangeOfLid lid) let tcDefRepr = match tcDefRepr with @@ -1720,9 +1735,10 @@ memberCore: let optReturnType = $3 let bindingBuilder, mBindLhs = $2 (fun vis memFlagsBuilder attrs rangeStart -> + let xmlDoc = grabXmlDocAtRangeStart(parseState, attrs, rangeStart) let memberFlags = Some (memFlagsBuilder SynMemberKind.Member) let mWholeBindLhs = (mBindLhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) - let binding = bindingBuilder (vis, $1, false, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, optReturnType, $5, mRhs, [], attrs, memberFlags) + let binding = (bindingBuilder xmlDoc) (vis, $1, false, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, optReturnType, $5, mRhs, [], attrs, memberFlags) let memberRange = unionRanges rangeStart mRhs [ SynMemberDefn.Member (binding, memberRange) ]) } @@ -1735,6 +1751,7 @@ memberCore: (fun visNoLongerUsed memFlagsBuilder attrs rangeStart -> let mutable hasGet = false let mutable hasSet = false + let xmlDoc = grabXmlDocAtRangeStart(parseState, attrs, rangeStart) // Iterate over 1 or 2 'get'/'set' entries $4 |> List.choose (fun (optInline, optAttrs, (bindingBuilder, mBindLhs), optReturnType, expr, exprm) -> @@ -1747,8 +1764,8 @@ memberCore: { attrList with Attributes = attrList.Attributes |> List.map (fun a -> { a with AppliesToGetterAndSetter = true } ) }) let attrs = attrs @ optAttrs - - let binding = bindingBuilder (visNoLongerUsed, optInline, isMutable, mBindLhs, DebugPointAtBinding.NoneAtInvisible, optReturnType, expr, exprm, [], attrs, Some (memFlagsBuilder SynMemberKind.Member)) + + let binding = (bindingBuilder xmlDoc) (visNoLongerUsed, optInline, isMutable, mBindLhs, DebugPointAtBinding.NoneAtInvisible, optReturnType, expr, exprm, [], attrs, Some (memFlagsBuilder SynMemberKind.Member)) let (SynBinding (vis, _, isInline, _, attrs, doc, valSynData, pv, _, _, mBindLhs, spBind)) = binding let memberKind = let getset = @@ -1797,7 +1814,7 @@ memberCore: | _ -> optReturnType // REDO with the correct member kind - let binding = bindingBuilder(vis, isInline, isMutable, mBindLhs, DebugPointAtBinding.NoneAtInvisible, optReturnType, expr, exprm, [], attrs, Some(memFlagsBuilder memberKind)) + let binding = (bindingBuilder PreXmlDoc.Empty) (vis, isInline, isMutable, mBindLhs, DebugPointAtBinding.NoneAtInvisible, optReturnType, expr, exprm, [], attrs, Some(memFlagsBuilder memberKind)) let (SynBinding (vis, _, isInline, _, attrs, doc, valSynData, pv, rhsRetInfo, rhsExpr, mBindLhs, spBind)) = binding let mWholeBindLhs = (mBindLhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) @@ -1857,7 +1874,7 @@ memberCore: let bindingPatAdjusted, xmlDocAdjusted = - let bindingOuter = propertyNameBindingBuilder(vis, optInline, isMutable, mWholeBindLhs, spBind, optReturnType, expr, exprm, [], attrs, Some(memFlagsBuilder SynMemberKind.Member)) + let bindingOuter = (propertyNameBindingBuilder xmlDoc) (vis, optInline, isMutable, mWholeBindLhs, spBind, optReturnType, expr, exprm, [], attrs, Some(memFlagsBuilder SynMemberKind.Member)) let (SynBinding (_, _, _, _, _, doc2, _, bindingPatOuter, _, _, _, _)) = bindingOuter @@ -1948,7 +1965,7 @@ classDefnMember: | opt_attributes opt_declVisibility abstractMemberFlags opt_inline nameop opt_explicitValTyparDecls COLON topTypeWithTypeConstraints classMemberSpfnGetSet opt_ODECLEND { let ty, arity = $8 - let isInline, doc, id, explicitValTyparDecls = $4, grabXmlDoc(parseState, 3), $5, $6 + let isInline, doc, id, explicitValTyparDecls = $4, grabXmlDoc(parseState, $1, 1), $5, $6 let getSetRangeOpt, getSet = $9 let getSetAdjuster arity = match arity, getSet with SynValInfo([], _), SynMemberKind.Member -> SynMemberKind.PropertyGet | _ -> getSet let wholeRange = @@ -1964,7 +1981,7 @@ classDefnMember: { if not (isNil $1) then errorR(Error(FSComp.SR.parsAttributesIllegalOnInherit(), rhs parseState 1)) if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityIllegalOnInherit(), rhs parseState 1)) [ $3 ] } - + | opt_attributes opt_declVisibility valDefnDecl opt_ODECLEND { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) let rangeStart = rhs parseState 1 @@ -1991,7 +2008,7 @@ classDefnMember: let declPat = SynPat.LongIdent (LongIdentWithDots([mkSynId (rhs parseState 3) "new"], []), None, Some noInferredTypars, SynArgPats.Pats [$4], vis, rhs parseState 3) // Check that 'SynPatForConstructorDecl' matches this correctly assert (match declPat with SynPatForConstructorDecl _ -> true | _ -> false) - [ SynMemberDefn.Member(SynBinding (None, SynBindingKind.Normal, false, false, $1, grabXmlDoc(parseState, 3), valSynData, declPat, None, expr, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible), m) ] } + [ SynMemberDefn.Member(SynBinding (None, SynBindingKind.Normal, false, false, $1, grabXmlDoc(parseState, $1, 1), valSynData, declPat, None, expr, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible), m) ] } | opt_attributes opt_declVisibility STATIC typeKeyword tyconDefn { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(), rhs parseState 2)) @@ -2002,24 +2019,24 @@ classDefnMember: valDefnDecl: | VAL opt_mutable opt_access ident COLON typ { let mRhs = rhs2 parseState 4 6 - let doc = grabXmlDoc(parseState, 4) let mValDecl = rhs2 parseState 1 6 - (fun rangeStart attribs isStatic -> + (fun rangeStart attribs isStatic -> + let xmlDoc = grabXmlDocAtRangeStart(parseState, attribs, rangeStart) let mValDecl = unionRanges rangeStart mValDecl - let fld = SynField(attribs, isStatic, Some $4, $6, $2, doc, $3, mRhs) + let fld = SynField(attribs, isStatic, Some $4, $6, $2, xmlDoc, $3, mRhs) [ SynMemberDefn.ValField(fld, mValDecl) ]) } /* An auto-property definition in an object type definition */ autoPropsDefnDecl: | VAL opt_mutable opt_access ident opt_typ EQUALS typedSequentialExprBlock classMemberSpfnGetSet - { let doc = grabXmlDoc(parseState, 5) - let mGetSetOpt, getSet = $8 + { let mGetSetOpt, getSet = $8 if $2 then errorR (Error (FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet (), rhs parseState 3)) (fun attribs isStatic flags rangeStart -> + let xmlDoc = grabXmlDocAtRangeStart(parseState, attribs, rangeStart) let memberRange = unionRanges rangeStart $7.Range - [ SynMemberDefn.AutoProperty(attribs, isStatic, $4, $5, getSet, flags, doc, $3, $7, mGetSetOpt, memberRange) ]) } + [ SynMemberDefn.AutoProperty(attribs, isStatic, $4, $5, getSet, flags, xmlDoc, $3, $7, mGetSetOpt, memberRange) ]) } /* An optional type on an auto-property definition */ @@ -2282,13 +2299,13 @@ interfaceMember: tyconNameAndTyparDecls: | opt_access path - { None, $2.Lid, false, $1, grabXmlDoc(parseState, 2) } + { None, $2.Lid, false, $1 } | opt_access prefixTyparDecls path - { Some $2, $3.Lid, false, $1, grabXmlDoc(parseState, 2) } + { Some $2, $3.Lid, false, $1 } | opt_access path postfixTyparDecls - { Some $3, $2.Lid, true, $1, grabXmlDoc(parseState, 2) } + { Some $3, $2.Lid, true, $1 } prefixTyparDecls: | typar @@ -2424,7 +2441,7 @@ unionTypeRepr: barAndgrabXmlDoc : | BAR - { grabXmlDoc(parseState, 1) } + { grabXmlDoc(parseState, [], 1) } attrUnionCaseDecls: | attrUnionCaseDecl barAndgrabXmlDoc attrUnionCaseDecls @@ -2474,20 +2491,20 @@ unionCaseName: firstUnionCaseDeclOfMany: | ident opt_OBLOCKSEP - { Choice2Of2 (SynUnionCase ( [], $1, SynUnionCaseKind.Fields [], PreXmlDoc.Empty, None, rhs parseState 1)) } + { Choice2Of2 (SynUnionCase ( [], $1, SynUnionCaseKind.Fields [], grabXmlDoc(parseState, [], 1), None, rhs parseState 1)) } | ident EQUALS constant opt_OBLOCKSEP - { Choice1Of2 (SynEnumCase ([], $1, fst $3, snd $3, PreXmlDoc.Empty, rhs2 parseState 1 3)) } + { Choice1Of2 (SynEnumCase ([], $1, fst $3, snd $3, grabXmlDoc(parseState, [], 1), rhs2 parseState 1 3)) } | firstUnionCaseDecl opt_OBLOCKSEP { $1 } firstUnionCaseDecl: | ident OF unionCaseRepr - { Choice2Of2 (SynUnionCase ( [], $1, SynUnionCaseKind.Fields $3, PreXmlDoc.Empty, None, rhs2 parseState 1 3)) } + { Choice2Of2 (SynUnionCase ( [], $1, SynUnionCaseKind.Fields $3, grabXmlDoc(parseState, [], 1), None, rhs2 parseState 1 3)) } | ident EQUALS constant opt_OBLOCKSEP - { Choice1Of2 (SynEnumCase ([], $1, fst $3, snd $3, PreXmlDoc.Empty, rhs2 parseState 1 3)) } + { Choice1Of2 (SynEnumCase ([], $1, fst $3, snd $3, grabXmlDoc(parseState, [], 1), rhs2 parseState 1 3)) } unionCaseReprElements: | unionCaseReprElement STAR unionCaseReprElements @@ -2498,11 +2515,13 @@ unionCaseReprElements: unionCaseReprElement: | ident COLON appType - { let wholeRange = rhs2 parseState 1 3 - mkSynNamedField($1, $3, wholeRange) } + { let xmlDoc = grabXmlDoc(parseState, [], 1) + let wholeRange = rhs2 parseState 1 3 + mkSynNamedField ($1, $3, xmlDoc, wholeRange) } | appType - { mkSynAnonField $1 } + { let xmlDoc = grabXmlDoc(parseState, [], 1) + mkSynAnonField ($1, xmlDoc) } unionCaseRepr: | braceFieldDeclList @@ -2532,23 +2551,19 @@ recdFieldDecl: /* Part of a field or val declaration in a record type or object type */ fieldDecl: | opt_mutable opt_access ident COLON typ - { let xmlDoc = grabXmlDoc (parseState, 3) - fun attrs stat wholeRange -> SynField(attrs, stat, Some $3, $5, $1, xmlDoc, $2, wholeRange) } + { fun attrs stat wholeRange -> + let xmlDoc = grabXmlDocAtRangeStart(parseState, attrs, wholeRange) + SynField(attrs, stat, Some $3, $5, $1, xmlDoc, $2, wholeRange) } /* An exception definition */ exconDefn: | exconCore opt_classDefn { SynExceptionDefn($1, $2, ($1.Range, $2) ||> unionRangeWithListBy (fun cd -> cd.Range) ) } - -/* Part of an exception definition */ -exceptionAndGrabDoc: - | EXCEPTION - { grabXmlDoc(parseState, 1) } /* Part of an exception definition */ exconCore: - | exceptionAndGrabDoc opt_attributes opt_access exconIntro exconRepr - { SynExceptionDefnRepr($2, $4, $5, $1, $3, (match $5 with None -> rhs2 parseState 1 4 | Some p -> unionRanges (rangeOfLongIdent p) (rhs2 parseState 1 4))) } + | EXCEPTION opt_attributes opt_access exconIntro exconRepr + { SynExceptionDefnRepr($2, $4, $5, PreXmlDoc.Empty, $3, (match $5 with None -> rhs2 parseState 1 4 | Some p -> unionRanges (rangeOfLongIdent p) (rhs2 parseState 1 4))) } /* Part of an exception definition */ exconIntro: @@ -2587,9 +2602,10 @@ defnBindings: // The first binding swallows any attributes prior to the 'let' BindingSetPreAttrs(mLetKwd, isRec, isUse, - (fun attrs vis -> + (fun attrs vis -> + let xmlDoc = grabXmlDoc(parseState, attrs, 1) // apply the builder - let binds = localBindingsBuilder attrs vis mLetKwd + let binds = localBindingsBuilder xmlDoc attrs vis mLetKwd if not isRec && not (isNilOrSingleton binds) then reportParseErrorAt mLetKwd (FSComp.SR.parsLetAndForNonRecBindings()) [], binds), @@ -2629,7 +2645,8 @@ hardwhiteLetBindings: // the first binding swallow any attributes prior to the 'let' BindingSetPreAttrs(mLetKwd, isRec, isUse, (fun attrs vis -> - let binds = localBindingsBuilder attrs vis mLetKwd + let xmlDoc = grabXmlDoc(parseState, attrs, 1) + let binds = localBindingsBuilder xmlDoc attrs vis mLetKwd if not isRec && not (isNilOrSingleton binds) then reportParseErrorAt mLetKwd (FSComp.SR.parsLetAndForNonRecBindings()) [], binds), @@ -2680,8 +2697,7 @@ hardwhiteDefnBindingsTerminator: /* An 'extern' DllImport function definition in C-style syntax */ cPrototype: | EXTERN cRetType opt_access ident opt_HIGH_PRECEDENCE_APP LPAREN cArgs rparen - { let rty, vis, nm, args = $2, $3, $4, $7 - let xmlDoc = grabXmlDoc(parseState, 1) + { let rty, vis, nm, args = $2, $3, $4, $7 let nmm = rhs parseState 3 let argsm = rhs parseState 6 let mBindLhs = lhs parseState @@ -2692,9 +2708,10 @@ cPrototype: SynExpr.Ident (ident("failwith", rhs parseState 6)), SynExpr.Const (SynConst.String("extern was not given a DllImport attribute", SynStringKind.Regular, rhs parseState 8), rhs parseState 8), mRhs) - (fun attrs _ -> + (fun attrs _ -> let bindingId = SynPat.LongIdent (LongIdentWithDots([nm], []), None, Some noInferredTypars, SynArgPats.Pats [SynPat.Tuple(false, args, argsm)], vis, nmm) let mWholeBindLhs = (mBindLhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) + let xmlDoc = grabXmlDoc(parseState, attrs, 1) let binding = mkSynBinding (xmlDoc, bindingId) (vis, false, false, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, Some rty, rhsExpr, mRhs, [], attrs, None) @@ -2771,16 +2788,19 @@ localBindings: match moreLocalBindingsLastRange with | None -> localBindingRange | Some m -> m - Some lastRange, (fun attrs vis mLetKwd -> attrLocalBindingBuilder attrs vis mLetKwd true :: moreBindings) + Some lastRange, (fun xmlDoc attrs vis mLetKwd -> attrLocalBindingBuilder xmlDoc attrs vis mLetKwd true :: moreBindings) | None -> - moreLocalBindingsLastRange, (fun _attrs _vis _letm -> moreBindings) } + moreLocalBindingsLastRange, (fun _xmlDoc _attrs _vis _letm -> moreBindings) } moreLocalBindings: | AND attr_localBinding moreLocalBindings { let mLetKwd = rhs parseState 1 (match $2 with - | Some (localBindingRange, attrLocalBindingBuilder) -> (attrLocalBindingBuilder [] None mLetKwd false, localBindingRange) :: $3 + | Some (localBindingRange, attrLocalBindingBuilder) -> + let xmlDoc = grabXmlDoc(parseState, [], 1) + let xmlDoc = if xmlDoc.IsEmpty then grabXmlDoc(parseState, [], 2) else xmlDoc + (attrLocalBindingBuilder xmlDoc [] None mLetKwd false, localBindingRange) :: $3 | None -> $3) } | %prec prec_no_more_attr_bindings @@ -2792,7 +2812,7 @@ attr_localBinding: | opt_attributes localBinding { let attrs2 = $1 let localBindingRange, localBindingBuilder = $2 - let attrLocalBindingBuilder = (fun attrs vis mLetKwd _ -> localBindingBuilder (attrs@attrs2) vis mLetKwd) + let attrLocalBindingBuilder = (fun xmlDoc attrs vis mLetKwd _ -> localBindingBuilder xmlDoc (attrs@attrs2) vis mLetKwd) Some(localBindingRange, attrLocalBindingBuilder) } | error @@ -2809,24 +2829,24 @@ localBinding: let bindingBuilder, mBindLhs = $3 let localBindingRange = unionRanges (rhs2 parseState 1 5) mRhs let localBindingBuilder = - (fun attrs vis mLetKwd -> + (fun xmlDoc attrs vis mLetKwd -> let mWhole = (unionRanges mLetKwd mRhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) let spBind = if IsControlFlowExpression expr then DebugPointAtBinding.NoneAtLet else DebugPointAtBinding.Yes mWhole let mWholeBindLhs = (mBindLhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range) - bindingBuilder (vis, $1, $2, mWholeBindLhs, spBind, optReturnType, expr, mRhs, opts, attrs, None)) + (bindingBuilder xmlDoc) (vis, $1, $2, mWholeBindLhs, spBind, optReturnType, expr, mRhs, opts, attrs, None)) localBindingRange, localBindingBuilder } | opt_inline opt_mutable bindingPattern opt_topReturnTypeWithTypeConstraints EQUALS error { let mWhole = rhs2 parseState 1 5 let mRhs = rhs parseState 5 let optReturnType = $4 - let bindingBuilder, mBindLhs = $3 + let bindingBuilder, mBindLhs = $3 let localBindingBuilder = - (fun attrs vis mLetKwd -> + (fun xmlDoc attrs vis mLetKwd -> let spBind = DebugPointAtBinding.Yes (unionRanges mLetKwd mRhs) let eqm = rhs parseState 5 let zeroWidthAtEnd = eqm.EndRange - bindingBuilder (vis, $1, $2, mBindLhs, spBind, optReturnType, arbExpr("localBinding1", zeroWidthAtEnd), mRhs, [], attrs, None)) + (bindingBuilder xmlDoc) (vis, $1, $2, mBindLhs, spBind, optReturnType, arbExpr("localBinding1", zeroWidthAtEnd), mRhs, [], attrs, None)) mWhole, localBindingBuilder } | opt_inline opt_mutable bindingPattern opt_topReturnTypeWithTypeConstraints recover @@ -2836,9 +2856,9 @@ localBinding: let mRhs = mWhole.EndRange // zero-width range at end of last good token let bindingBuilder, mBindLhs = $3 let localBindingBuilder = - (fun attrs vis mLetKwd -> + (fun xmlDoc attrs vis mLetKwd -> let spBind = DebugPointAtBinding.Yes (unionRanges mLetKwd mRhs) - bindingBuilder (vis, $1, $2, mBindLhs, spBind, optReturnType, arbExpr("localBinding2", mRhs), mRhs, [], attrs, None)) + (bindingBuilder xmlDoc) (vis, $1, $2, mBindLhs, spBind, optReturnType, arbExpr("localBinding2", mRhs), mRhs, [], attrs, None)) mWhole, localBindingBuilder } @@ -2990,13 +3010,7 @@ constant: bindingPattern: | headBindingPattern - - { // Adds a grab point at the start of the binding, so as not to include XML doc comments on the arguments - let xmlDoc = LexbufLocalXmlDocStore.GrabXmlDocBeforeMarker(parseState.LexBuffer, (lhs parseState).StartRange) - // Adds grab point at the end of the binding head, so subsequent types don't erroneously include argument doc comemnts - grabXmlDoc(parseState, 1) |> ignore - - mkSynBinding (xmlDoc, $1), rhs parseState 1 } + { (fun (xmlDoc: PreXmlDoc) -> mkSynBinding (xmlDoc, $1)), rhs parseState 1 } // Subset of patterns allowed to be used in implicit ctors. // For a better error recovery we could replace these rules with the actual SynPat parsing @@ -4738,12 +4752,12 @@ objExprBindings: | WITH localBindings { let mWithKwd = (rhs parseState 1) let _localBindingsLastRange, localBindingsBuilder = $2 - localBindingsBuilder [] None mWithKwd } + localBindingsBuilder PreXmlDoc.Empty [] None mWithKwd } | OWITH localBindings OEND { let mWithKwd = (rhs parseState 1) let _localBindingsLastRange, localBindingsBuilder = $2 - localBindingsBuilder [] None mWithKwd } + localBindingsBuilder PreXmlDoc.Empty [] None mWithKwd } | WITH objectImplementationBlock opt_declEnd { $2 |> diff --git a/src/fsharp/service/FSharpCheckerResults.fs b/src/fsharp/service/FSharpCheckerResults.fs index ca208b7201b..c3fd629bd63 100644 --- a/src/fsharp/service/FSharpCheckerResults.fs +++ b/src/fsharp/service/FSharpCheckerResults.fs @@ -1917,10 +1917,10 @@ type FSharpProjectContext(thisCcu: CcuThunk, assemblies: FSharpAssembly list, ad member _.AccessibilityRights = FSharpAccessibilityRights(thisCcu, ad) -[] /// A live object of this type keeps the background corresponding background builder (and type providers) alive (through reference-counting). // // Note: objects returned by the methods of this type do not require the corresponding background builder to be alive. +[] type FSharpCheckFileResults (filename: string, errors: FSharpDiagnostic[], diff --git a/src/fsharp/service/FSharpParseFileResults.fsi b/src/fsharp/service/FSharpParseFileResults.fsi index 9d3378a7b9a..e5048aa4700 100644 --- a/src/fsharp/service/FSharpParseFileResults.fsi +++ b/src/fsharp/service/FSharpParseFileResults.fsi @@ -7,8 +7,8 @@ open FSharp.Compiler.EditorServices open FSharp.Compiler.Syntax open FSharp.Compiler.Text -[] /// Represents the results of parsing an F# file and a set of analysis operations based on the parse tree alone. +[] type public FSharpParseFileResults = /// The syntax tree resulting from the parse diff --git a/src/fsharp/service/IncrementalBuild.fs b/src/fsharp/service/IncrementalBuild.fs index 8909575da24..ebb94f18398 100644 --- a/src/fsharp/service/IncrementalBuild.fs +++ b/src/fsharp/service/IncrementalBuild.fs @@ -535,7 +535,7 @@ type BoundModel private (tcConfig: TcConfig, let tcInfoExtras = { - /// Only keep the typed interface files when doing a "full" build for fsc.exe, otherwise just throw them away + // Only keep the typed interface files when doing a "full" build for fsc.exe, otherwise just throw them away latestImplFile = if keepAssemblyContents then implFile else None tcResolutions = (if keepAllBackgroundResolutions then sink.GetResolutions() else TcResolutions.Empty) tcSymbolUses = (if keepAllBackgroundSymbolUses then sink.GetSymbolUses() else TcSymbolUses.Empty) @@ -668,7 +668,7 @@ module Utilities = | _ -> None /// The implementation of the information needed by TcImports in CompileOps.fs for an F# assembly reference. -// +/// /// Constructs the build data (IRawFSharpAssemblyData) representing the assembly when used /// as a cross-assembly reference. Note the assembly has not been generated on disk, so this is /// a virtualized view of the assembly contents as computed by background checking. diff --git a/src/fsharp/service/ServiceDeclarationLists.fs b/src/fsharp/service/ServiceDeclarationLists.fs index 3ea07d55545..a077a1fe444 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fs +++ b/src/fsharp/service/ServiceDeclarationLists.fs @@ -456,8 +456,8 @@ module DeclarationListHelpers = (fun () -> FormatItemDescriptionToToolTipElement isDecl infoReader ad m denv item) (fun err -> ToolTipElement.CompositionError err) +/// Represents one parameter for one method (or other item) in a group. [] -/// Represents one parameter for one method (or other item) in a group. type MethodGroupItemParameter(name: string, canonicalTypeTextForSorting: string, display: TaggedText[], isOptional: bool) = /// The name of the parameter. diff --git a/src/fsharp/service/ServiceDeclarationLists.fsi b/src/fsharp/service/ServiceDeclarationLists.fsi index d8a302cef94..508e7297529 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fsi +++ b/src/fsharp/service/ServiceDeclarationLists.fsi @@ -88,11 +88,11 @@ type internal CompletionItem = } member Item: Item -[] /// Represents a declaration in F# source code, with information attached ready for display by an editor. /// Returned by GetDeclarations. // -// Note: this type holds a weak reference to compiler resources. +// Note: this type holds a weak reference to compiler resources. +[] type public DeclarationListItem = /// Get the text to display in the declaration list for the declaration. member Name: string @@ -123,11 +123,11 @@ type public DeclarationListItem = member NamespaceToOpen: string option -[] /// Represents a set of declarations in F# source code, with information attached ready for display by an editor. /// Returned by GetDeclarations. // -// Note: this type holds a weak reference to compiler resources. +// Note: this type holds a weak reference to compiler resources. +[] type public DeclarationListInfo = member Items: DeclarationListItem[] diff --git a/src/fsharp/service/service.fsi b/src/fsharp/service/service.fsi index 97b6f9f7983..018fca15317 100644 --- a/src/fsharp/service/service.fsi +++ b/src/fsharp/service/service.fsi @@ -15,8 +15,8 @@ open FSharp.Compiler.Syntax open FSharp.Compiler.Text open FSharp.Compiler.Tokenization -[] /// Used to parse and check F# source code. +[] type public FSharpChecker = /// /// Create an instance of an FSharpChecker. diff --git a/src/fsharp/utils/ResizeArray.fsi b/src/fsharp/utils/ResizeArray.fsi index cdc216aaab9..400f38e4b4c 100644 --- a/src/fsharp/utils/ResizeArray.fsi +++ b/src/fsharp/utils/ResizeArray.fsi @@ -2,8 +2,8 @@ namespace Internal.Utilities -[] /// Generic operations on the type System.Collections.Generic.List, which is called ResizeArray in the F# libraries. +[] module internal ResizeArray = /// Return the length of the collection. You can also use property arr.Length. diff --git a/src/fsharp/utils/prim-lexing.fsi b/src/fsharp/utils/prim-lexing.fsi index 23ad8cbefa6..24577606320 100644 --- a/src/fsharp/utils/prim-lexing.fsi +++ b/src/fsharp/utils/prim-lexing.fsi @@ -95,10 +95,10 @@ type internal Position = static member FirstLine: fileIdx:int -> Position -[] /// Input buffers consumed by lexers generated by fslex.exe. /// The type must be generic to match the code generated by FsLex and FsYacc (if you would like to /// fix this, please submit a PR to the FsLexYacc repository allowing for optional emit of a non-generic type reference). +[] type internal LexBuffer<'Char> = /// The start position for the lexeme. member StartPos: Position with get,set diff --git a/src/fsharp/utils/prim-parsing.fs b/src/fsharp/utils/prim-parsing.fs index 444113f939b..c7214456a2a 100644 --- a/src/fsharp/utils/prim-parsing.fs +++ b/src/fsharp/utils/prim-parsing.fs @@ -34,8 +34,8 @@ type internal IParseState(ruleStartPoss:Position[], ruleEndPoss:Position[], lhsP member p.RaiseError() = raise RecoverableParseError -[] /// This context is passed to the error reporter when a syntax error occurs +[] type internal ParseErrorContext<'tok> (//lexbuf: LexBuffer<_>, stateStack:int list, diff --git a/src/fsharp/utils/prim-parsing.fsi b/src/fsharp/utils/prim-parsing.fsi index c4d5475273e..e34181709e8 100644 --- a/src/fsharp/utils/prim-parsing.fsi +++ b/src/fsharp/utils/prim-parsing.fsi @@ -37,8 +37,8 @@ type internal IParseState = member LexBuffer : LexBuffer -[] /// The context provided when a parse error occurs. +[] type internal ParseErrorContext<'tok> = /// The stack of state indexes active at the parse error . member StateStack : int list diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf index abaa63bc021..dab3bc8e9ca 100644 --- a/src/fsharp/xlf/FSComp.txt.cs.xlf +++ b/src/fsharp/xlf/FSComp.txt.cs.xlf @@ -307,6 +307,11 @@ Atribut InlineIfLambda se nachází v signatuře, ale ne v implementaci. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. Klíčové slovo, které specifikuje konstantní literál jako argument parametru typu v poskytovatelích typů diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf index 88583fec151..beed088d92e 100644 --- a/src/fsharp/xlf/FSComp.txt.de.xlf +++ b/src/fsharp/xlf/FSComp.txt.de.xlf @@ -307,6 +307,11 @@ Das Attribut "InlineIfLambda" ist in der Signatur vorhanden, jedoch nicht in der Implementierung. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. Schlüsselwort, um ein konstantes Literal als Typparameterargument in Typanbietern anzugeben. diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index ed44397fe0f..304a1f16765 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -307,6 +307,11 @@ El atributo "InlineIfLambda" está presente en la firma, pero no en la implementación. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. Palabra clave para especificar un literal de constante como argumento de parámetro de tipo en los proveedores de tipo. diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf index 2168a116c88..37178a70b92 100644 --- a/src/fsharp/xlf/FSComp.txt.fr.xlf +++ b/src/fsharp/xlf/FSComp.txt.fr.xlf @@ -307,6 +307,11 @@ L’attribut « InlineIfLambda » est présent dans la signature, mais pas dans l’implémentation. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. Mot clé permettant de spécifier une constante littérale en tant qu'argument de paramètre de type dans les fournisseurs de types. diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf index efe83d5e100..d60d27f3de5 100644 --- a/src/fsharp/xlf/FSComp.txt.it.xlf +++ b/src/fsharp/xlf/FSComp.txt.it.xlf @@ -307,6 +307,11 @@ L'attributo 'InlineIfLambda' è presente nella firma, ma non nell'implementazione. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. Parola chiave per specificare un valore letterale di costante come argomento del parametro di tipo in Provider di tipi. diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf index f0700683139..c3f1c2a4d94 100644 --- a/src/fsharp/xlf/FSComp.txt.ja.xlf +++ b/src/fsharp/xlf/FSComp.txt.ja.xlf @@ -307,6 +307,11 @@ 'InlineIfLambda' 属性はシグネチャに存在しますが、実装はありません。 + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. 定数リテラルを型プロバイダーの型パラメーター引数として指定するキーワード。 diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf index 4785f3dd3f1..36d281e1ead 100644 --- a/src/fsharp/xlf/FSComp.txt.ko.xlf +++ b/src/fsharp/xlf/FSComp.txt.ko.xlf @@ -307,6 +307,11 @@ 'InlineIfLambda' 특성이 서명에 있지만 구현에는 없습니다. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. 상수 리터럴을 형식 공급자의 형식 매개 변수 인수로 지정하는 키워드입니다. diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf index 5b2074d0bea..8adc3ea0c27 100644 --- a/src/fsharp/xlf/FSComp.txt.pl.xlf +++ b/src/fsharp/xlf/FSComp.txt.pl.xlf @@ -307,6 +307,11 @@ Atrybut "InlineIfLambda" jest obecny w sygnaturze, ale nie w implementacji. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. Słowo kluczowe na potrzeby określania literału stałej jako argumentu parametru typu w przypadku dostawców typów. diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf index 40820727c14..ee53d283957 100644 --- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf +++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf @@ -307,6 +307,11 @@ O atributo 'InlineIfLambda' está presente na assinatura, mas não na implementação. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. Palavra-chave para especificar um literal constante como um argumento de parâmetro de tipo nos Provedores de Tipo. diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf index d17847bea59..65ba11e54f4 100644 --- a/src/fsharp/xlf/FSComp.txt.ru.xlf +++ b/src/fsharp/xlf/FSComp.txt.ru.xlf @@ -307,6 +307,11 @@ Атрибут "InlineIfLambda" присутствует в сигнатуре, но отсутствует в реализации. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. Ключевое слово для указания константного литерала в качестве аргумента параметра типа в поставщиках типов. diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf index e4ff88cd5e0..513f682a09a 100644 --- a/src/fsharp/xlf/FSComp.txt.tr.xlf +++ b/src/fsharp/xlf/FSComp.txt.tr.xlf @@ -307,6 +307,11 @@ 'InlineIfLambda' özniteliği imzada var ama uygulamada yok. + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. Tür Sağlayıcılarında tür parametresi bağımsız değişkeni olarak sabit değişmez değeri belirtmek için anahtar sözcük. diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf index 4d79bd47456..e3a2cad3d51 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf @@ -307,6 +307,11 @@ "InlineIfLambda" 属性存在于签名中,但实现中不存在。 + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. 用于将常量文本指定为类型提供程序中的类型形参实参的关键字。 diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf index 713c545b21e..65f546fe9a6 100644 --- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf @@ -307,6 +307,11 @@ 'InlineIfLambda' 屬性存在於簽章中,但不存在於實作中。 + + XML comment is not placed on a valid language element. + XML comment is not placed on a valid language element. + + Keyword to specify a constant literal as a type parameter argument in Type Providers. 用於在型別提供者中,將常數常值指定為型別參數引數的關鍵字。 diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj index 9253158c2f1..cbf7e669c2c 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -72,6 +72,9 @@ ParserTests.fs + + XmlDocTests.fs + Program.fs diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected index cc80f90ae3a..353a3ec6dc1 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected @@ -10474,6 +10474,8 @@ FSharp.Compiler.Xml.PreXmlDoc FSharp.Compiler.Xml.PreXmlDoc: Boolean Equals(FSharp.Compiler.Xml.PreXmlDoc) FSharp.Compiler.Xml.PreXmlDoc: Boolean Equals(System.Object) FSharp.Compiler.Xml.PreXmlDoc: Boolean Equals(System.Object, System.Collections.IEqualityComparer) +FSharp.Compiler.Xml.PreXmlDoc: Boolean IsEmpty +FSharp.Compiler.Xml.PreXmlDoc: Boolean get_IsEmpty() FSharp.Compiler.Xml.PreXmlDoc: FSharp.Compiler.Xml.PreXmlDoc Create(System.String[], FSharp.Compiler.Text.Range) FSharp.Compiler.Xml.PreXmlDoc: FSharp.Compiler.Xml.PreXmlDoc Empty FSharp.Compiler.Xml.PreXmlDoc: FSharp.Compiler.Xml.PreXmlDoc Merge(FSharp.Compiler.Xml.PreXmlDoc, FSharp.Compiler.Xml.PreXmlDoc) diff --git a/tests/fsharp/typecheck/sigs/neg25.fs b/tests/fsharp/typecheck/sigs/neg25.fs index 87b1d5c81df..f12074effb6 100644 --- a/tests/fsharp/typecheck/sigs/neg25.fs +++ b/tests/fsharp/typecheck/sigs/neg25.fs @@ -67,7 +67,7 @@ module NegativeTestsActualRepro1 = override this.MaximumStrength = 9u // Stub - type TestVariableLevelEnumeratorFactory (levels: seq) = /// THis should give an error + type TestVariableLevelEnumeratorFactory (levels: seq) = // THis should give an error inherit TestCaseEnumeratorFactoryCommonImplementation () let node = TestVariableNode levels diff --git a/tests/fsharp/typecheck/sigs/neg66.fsx b/tests/fsharp/typecheck/sigs/neg66.fsx index 5d4dc729639..fc1ef247684 100644 --- a/tests/fsharp/typecheck/sigs/neg66.fsx +++ b/tests/fsharp/typecheck/sigs/neg66.fsx @@ -125,7 +125,7 @@ type Simulator() = let ay = (dy / d) * g / obj.Mass ax,ay - /// Find all the gravitational objects in the system except the given object + // Find all the gravitational objects in the system except the given object let FindObjects(obj) = [ for paintObject in paintObjects do match paintObject with diff --git a/tests/fsharp/typecheck/sigs/neg67.fsx b/tests/fsharp/typecheck/sigs/neg67.fsx index caab46acada..bda04dcdcb1 100644 --- a/tests/fsharp/typecheck/sigs/neg67.fsx +++ b/tests/fsharp/typecheck/sigs/neg67.fsx @@ -125,7 +125,7 @@ type Simulator() = let ay = (dy / d) * g / obj.Mass ax,ay - /// Find all the gravitational objects in the system except the given object + // Find all the gravitational objects in the system except the given object let FindObjects(obj) = [ for paintObject in paintObjects do match paintObject with diff --git a/tests/fsharp/typecheck/sigs/neg69.fsx b/tests/fsharp/typecheck/sigs/neg69.fsx index 9e0c51770cf..cc0cf21086c 100644 --- a/tests/fsharp/typecheck/sigs/neg69.fsx +++ b/tests/fsharp/typecheck/sigs/neg69.fsx @@ -125,7 +125,7 @@ type Simulator() = let ay = (dy / d) * g / obj.Mass ax,ay - /// Find all the gravitational objects in the system except the given object + // Find all the gravitational objects in the system except the given object let FindObjects(obj) = [ for paintObject in paintObjects do match paintObject with diff --git a/tests/fsharp/typecheck/sigs/neg71.bsl b/tests/fsharp/typecheck/sigs/neg71.bsl index dd572143c38..c41a93b8bcf 100644 --- a/tests/fsharp/typecheck/sigs/neg71.bsl +++ b/tests/fsharp/typecheck/sigs/neg71.bsl @@ -4,3 +4,5 @@ neg71.fsx(110,43,110,44): parse error FS0010: Unexpected symbol ')' in expressio neg71.fsx(166,24,168,1): parse error FS0010: Incomplete structured construct at or before this point in member definition. Expected incomplete structured construct at or before this point, 'end' or other token. neg71.fsx(230,1,230,13): parse error FS0010: Unexpected identifier in member definition + +neg71.fsx(128,5,128,81): parse info FS3520: XML comment is not placed on a valid language element. diff --git a/tests/fsharp/typecheck/sigs/neg71.vsbsl b/tests/fsharp/typecheck/sigs/neg71.vsbsl index 87e679bcc92..bbdad6e76ff 100644 --- a/tests/fsharp/typecheck/sigs/neg71.vsbsl +++ b/tests/fsharp/typecheck/sigs/neg71.vsbsl @@ -5,12 +5,16 @@ neg71.fsx(166,24,168,1): parse error FS0010: Incomplete structured construct at neg71.fsx(230,1,230,13): parse error FS0010: Unexpected identifier in member definition +neg71.fsx(128,5,128,81): parse info FS3520: XML comment is not placed on a valid language element. + neg71.fsx(110,43,110,44): parse error FS0010: Unexpected symbol ')' in expression. Expected incomplete structured construct at or before this point or other token. neg71.fsx(166,24,168,1): parse error FS0010: Incomplete structured construct at or before this point in member definition. Expected incomplete structured construct at or before this point, 'end' or other token. neg71.fsx(230,1,230,13): parse error FS0010: Unexpected identifier in member definition +neg71.fsx(128,5,128,81): parse info FS3520: XML comment is not placed on a valid language element. + neg71.fsx(168,1,168,28): typecheck error FS0960: 'let' and 'do' bindings must come before member and interface definitions in type definitions neg71.fsx(168,9,168,18): typecheck error FS0039: The value or constructor 'Simulator' is not defined. diff --git a/tests/service/Common.fs b/tests/service/Common.fs index e1465f90041..c18d5bed917 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -380,6 +380,9 @@ let getParseResultsOfSignatureFile (source: string) = let getParseAndCheckResults (source: string) = parseAndCheckScript("/home/user/Test.fsx", source) +let getParseAndCheckResultsOfSignatureFile (source: string) = + parseAndCheckScript("/home/user/Test.fsi", source) + let getParseAndCheckResultsPreview (source: string) = parseAndCheckScriptPreview("/home/user/Test.fsx", source) diff --git a/tests/service/Symbols.fs b/tests/service/Symbols.fs index 85df60c7af4..788170c65a4 100644 --- a/tests/service/Symbols.fs +++ b/tests/service/Symbols.fs @@ -7,6 +7,7 @@ module Tests.Service.Symbols #endif +open System open FSharp.Compiler.Service.Tests.Common open FSharp.Compiler.Symbols open FSharp.Compiler.Syntax @@ -1583,3 +1584,42 @@ else (* some long comment here *) if c then assertRange (4, 34) (4, 36) mIf2 | _ -> Assert.Fail "Could not get valid AST" + + +module UnionCaseComments = + [] + let ``Union Case fields can have comments`` () = + let ast = """ +type Foo = +/// docs for Thing +| Thing of + /// docs for first + first: string * + /// docs for anon field + bool +""" + |> getParseResults + + match ast with + | ParsedInput.ImplFile(ParsedImplFileInput(modules = [ + SynModuleOrNamespace.SynModuleOrNamespace(decls = [ + SynModuleDecl.Types ([ + SynTypeDefn.SynTypeDefn (typeRepr = SynTypeDefnRepr.Simple (simpleRepr = SynTypeDefnSimpleRepr.Union(unionCases = [ + SynUnionCase.SynUnionCase (caseType = SynUnionCaseKind.Fields [ + SynField.SynField(xmlDoc = firstXml) + SynField.SynField(xmlDoc = anonXml) + ]) + ]))) + ], _) + ]) + ])) -> + let firstDocs = firstXml.ToXmlDoc(false, None).GetXmlText() + let anonDocs = anonXml.ToXmlDoc(false, None).GetXmlText() + + let nl = Environment.NewLine + + Assert.AreEqual($"{nl} docs for first{nl}", firstDocs) + Assert.AreEqual($"{nl} docs for anon field{nl}", anonDocs) + + | _ -> + failwith "Could not find SynExpr.Do" diff --git a/tests/service/XmlDocTests.fs b/tests/service/XmlDocTests.fs new file mode 100644 index 00000000000..b07ffacaf2e --- /dev/null +++ b/tests/service/XmlDocTests.fs @@ -0,0 +1,740 @@ +#if INTERACTIVE +#r "../../artifacts/bin/fcs/net461/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net461/nunit.framework.dll" +#load "FsUnit.fs" +#load "Common.fs" +#else +module Tests.XmlDoc +#endif + +open FSharp.Compiler.CodeAnalysis +open FSharp.Compiler.Service.Tests.Common +open FSharp.Compiler.Symbols +open FSharp.Test.Compiler +open FsUnit +open NUnit.Framework + +let getFieldXml symbolName fieldName checkResults = + let field = + match findSymbolByName symbolName checkResults with + | :? FSharpEntity as e -> e.FSharpFields |> Seq.find(fun x -> x.DisplayName = fieldName) + | :? FSharpUnionCase as c -> c.Fields |> Seq.find(fun x -> x.DisplayName = fieldName) + | _ -> failwith "Unexpected symbol" + field.XmlDoc + +let compareXml docs xmlDoc = + match xmlDoc with + | FSharpXmlDoc.FromXmlText t -> t.UnprocessedLines |> shouldEqual docs + | _ -> failwith "wrong XmlDoc kind" + +let checkXml symbolName docs checkResults = + let symbol = findSymbolByName symbolName checkResults + let xmlDoc = + match symbol with + | :? FSharpMemberOrFunctionOrValue as v -> v.XmlDoc + | :? FSharpEntity as t -> t.XmlDoc + | :? FSharpUnionCase as u -> u.XmlDoc + | _ -> failwith $"unexpected symbol type {symbol.GetType()}" + compareXml docs xmlDoc + +let checkXmls data checkResults = + for symbolName, docs in data do checkXml symbolName docs checkResults + +let checkSignatureAndImplementation code checkResultsAction parseResultsAction = + let checkCode getResultsFunc = + let parseResults, checkResults = getResultsFunc code + checkResultsAction checkResults + parseResultsAction parseResults + + checkCode getParseAndCheckResults + checkCode getParseAndCheckResultsOfSignatureFile + +let checkParsingErrors expected (parseResults: FSharpParseFileResults) = + parseResults.Diagnostics |> Array.map (fun x -> + let range = x.Range + Error x.ErrorNumber, Line range.StartLine, Col range.StartColumn, Line range.EndLine, Col range.EndColumn, x.Message) + + |> shouldEqual expected + +[] +let ``comments after xml-doc``(): unit = + checkSignatureAndImplementation """ +module Test + +// b +///A +// b +//// b +(* + b *) +type A = class end +""" + (checkXml "A" [|"A"|]) + (checkParsingErrors [||]) + +[] +let ``separated by expression``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +///A +() +///B +type A +""" + checkResults + |> checkXml "A" [|"B"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 2, Col 0, Line 2, Col 4, "XML comment is not placed on a valid language element."|] + +[] +let ``separated by // comment``(): unit = + checkSignatureAndImplementation """ +module Test + +///A +// Simple comment delimiter +///B +type A = class end +""" + (checkXml "A" [|"B"|]) + (checkParsingErrors [|Error 3520, Line 4, Col 0, Line 4, Col 4, "XML comment is not placed on a valid language element."|]) + +[] +let ``separated by //// comment``(): unit = + checkSignatureAndImplementation """ +module Test + +///A +//// Comment delimiter +///B +type A = class end +""" + (checkXml "A" [|"B"|]) + (checkParsingErrors [|Error 3520, Line 4, Col 0, Line 4, Col 4, "XML comment is not placed on a valid language element."|]) + +[] +let ``separated by multiline comment``(): unit = + checkSignatureAndImplementation """ +module Test + +///A +(* Multiline comment +delimiter *) +///B +type A = class end +""" + (checkXml "A" [|"B"|]) + (checkParsingErrors [|Error 3520, Line 4, Col 0, Line 4, Col 4, "XML comment is not placed on a valid language element."|]) + +[] +let ``separated by (*)``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +///A +(*) +///B +type A = class end +""" + checkResults + |> checkXml "A" [|"B"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 2, Col 0, Line 2, Col 4, "XML comment is not placed on a valid language element."|] + +[] +let ``types 01 - xml doc allowed positions``(): unit = + checkSignatureAndImplementation """ +module Test + +///A1 +///A2 +type + ///A3 + internal + ///A4 + A +""" + (checkXml "A" [|"A1"; "A2"|]) + (checkParsingErrors [| + Error 3520, Line 7, Col 4, Line 7, Col 9, "XML comment is not placed on a valid language element." + Error 3520, Line 9, Col 13, Line 9, Col 18, "XML comment is not placed on a valid language element." + |]) + +[] +let ``types 02 - xml doc before 'and'``(): unit = + checkSignatureAndImplementation """ +module Test + +type A = class end +///B1 +///B2 +and B = class end +""" + (checkXml "B" [|"B1"; "B2"|]) + (checkParsingErrors [||]) + +[] +let ``types 03 - xml doc after 'and'``(): unit = + checkSignatureAndImplementation """ +module Test + +type A = class end +and ///B1 + ///B2 + [] + ///B3 + B = class end +""" + (checkXml "B" [|"B1"; "B2"|]) + (checkParsingErrors [|Error 3520, Line 8, Col 4, Line 8, Col 9, "XML comment is not placed on a valid language element."|]) + +[] +let ``types 04 - xml doc before/after 'and'``(): unit = + checkSignatureAndImplementation """ +module Test + +type A = class end +///B1 +and ///B2 + B = class end +""" + (checkXml "B" [|"B1"|]) + (checkParsingErrors [|Error 3520, Line 6, Col 4, Line 6, Col 9, "XML comment is not placed on a valid language element."|]) + +[] +let ``types 05 - attributes after 'type'``(): unit = + checkSignatureAndImplementation """ +module Test + +///A1 +type ///A2 + [] A = class end +""" + (checkXml "A" [|"A1"|]) + (checkParsingErrors [|Error 3520, Line 5, Col 5, Line 5, Col 10, "XML comment is not placed on a valid language element."|]) + +[] +let ``types 06 - xml doc after attribute``(): unit = + checkSignatureAndImplementation """ +module Test + +[] +///A +type A = class end +""" + (checkXml "A" [||]) + (checkParsingErrors [|Error 3520, Line 5, Col 0, Line 5, Col 4, "XML comment is not placed on a valid language element."|]) + +[] +let ``let bindings 01 - allowed positions``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +///f1 +let ///f2 + rec ///f3 + inline ///f4 + private f x = f x +""" + checkResults + |> checkXml "f" [|"f1"|] + + parseResults + |> checkParsingErrors [| + Error 3520, Line 3, Col 4, Line 3, Col 9, "XML comment is not placed on a valid language element." + Error 3520, Line 4, Col 8, Line 4, Col 13, "XML comment is not placed on a valid language element." + Error 3520, Line 5, Col 15, Line 5, Col 20, "XML comment is not placed on a valid language element." + |] + +[] +let ``let bindings 02``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +///X1 +///X2 +[] +///X3 +let x = 3 +""" + checkResults + |> checkXml "x" [|"X1"; "X2"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 5, Col 0, Line 5, Col 5, "XML comment is not placed on a valid language element."|] + +[] +let ``let bindings 03 - 'let in'``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +///X1 +///X2 +[] +///X3 +let x = 3 in + +///Y1 +///Y2 +[] +///Y3 +let y = x +""" + checkResults + |> checkXmls [ + "x", [|"X1"; "X2"|] + "y", [|"Y1"; "Y2"|] + ] + + parseResults + |> checkParsingErrors [| + Error 3520, Line 5, Col 0, Line 5, Col 5, "XML comment is not placed on a valid language element." + Error 3520, Line 11, Col 0, Line 11, Col 5, "XML comment is not placed on a valid language element." + |] + +[] +let ``let bindings 03 - 'let in' with attributes after 'let'``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +let ///X + [] x = 3 in print x +""" + checkResults + |> checkXml "x" [||] + + parseResults + |> checkParsingErrors [|Error 3520, Line 2, Col 4, Line 2, Col 8, "XML comment is not placed on a valid language element."|] + +[] +let ``let bindings 04 - local binding``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +let _ = + ///X1 + ///X2 + let x = () + () +""" + checkResults + |> checkXml "x" [|"X1"; "X2"|] + + parseResults + |> checkParsingErrors [||] + +[] +let ``let bindings 05 - use``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +let _ = + ///X1 + ///X2 + use x = () + () +""" + checkResults + |> checkXml "x" [|"X1"; "X2"|] + + parseResults + |> checkParsingErrors [||] + +[] +let ``let bindings 06 - xml doc after attribute``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +[] +///X +let x = 5 +""" + checkResults + |> checkXml "x" [||] + + parseResults + |> checkParsingErrors [|Error 3520, Line 3, Col 0, Line 3, Col 4, "XML comment is not placed on a valid language element."|] + +[] +let ``let bindings 07 - attribute after 'let'``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +///X1 +let ///X2 + [] x = 5 +""" + checkResults + |> checkXml "x" [|"X1"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 3, Col 4, Line 3, Col 9, "XML comment is not placed on a valid language element."|] + +[] +let ``let bindings 08 - xml doc before 'and'``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +let rec f x = g x +///G1 +///G2 +and g x = f x +""" + checkResults + |> checkXml "g" [|"G1"; "G2"|] + + parseResults + |> checkParsingErrors [||] + +[] +let ``let bindings 09 - xml doc after 'and'``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +let rec f x = g x +and ///G1 + ///G2 + [] + ///G3 + g x = f x +""" + checkResults + |> checkXml "g" [|"G1"; "G2"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 6, Col 4, Line 6, Col 9, "XML comment is not placed on a valid language element."|] + +[] +let ``let bindings 10 - xml doc before/after 'and'``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +let rec f x = g x +///G1 +and ///G2 + g x = f x +""" + checkResults + |> checkXml "g" [|"G1"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 4, Col 4, Line 4, Col 9, "XML comment is not placed on a valid language element."|] + +[] +let ``let bindings 11 - in type``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +type A() = + ///data + let data = 5 +""" + checkResults + |> checkXml "data" [|"data"|] + + parseResults + |> checkParsingErrors [||] + +[] +let ``type members 01 - allowed positions``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +type A = + ///B1 + member + ///B2 + private x.B(): unit = () +""" + checkResults + |> checkXml "B" [|"B1"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 5, Col 11, Line 5, Col 16, "XML comment is not placed on a valid language element."|] + +[] +let ``type members 02``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +type A = + member x.A() = ///B1 + () + + ///B2 + ///B3 + [] + ///B4 + member x.B() = () +""" + checkResults + |> checkXml "B" [|"B2"; "B3"|] + + parseResults + |> checkParsingErrors [| + Error 3520, Line 3, Col 19, Line 3, Col 24, "XML comment is not placed on a valid language element." + Error 3520, Line 9, Col 4, Line 9, Col 9, "XML comment is not placed on a valid language element." + |] + +[] +let ``type members 03 - abstract``(): unit = + checkSignatureAndImplementation """ +module Test + +type A = + ///M1 + ///M2 + [] + ///M3 + abstract member M: unit +""" + (checkXml "get_M" [|"M1"; "M2"|]) + (checkParsingErrors [|Error 3520, Line 8, Col 4, Line 8, Col 9, "XML comment is not placed on a valid language element."|]) + +[] +let ``type members 04 - property accessors``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +type B = + ///A1 + ///A2 + member ///A3 + x.A + ///GET + with get (): unit = 5 + ///SET + and set (_: int) = () + + member x.C = x.set_A(4) +""" + checkResults + |> checkXmls [ + "get_A", [|"A1"; "A2"|] + "set_A", [|"A1"; "A2"|] + ] + + parseResults + |> checkParsingErrors [| + Error 3520, Line 5, Col 11, Line 5, Col 16, "XML comment is not placed on a valid language element." + Error 3520, Line 7, Col 16, Line 7, Col 22, "XML comment is not placed on a valid language element." + Error 3520, Line 9, Col 16, Line 9, Col 22, "XML comment is not placed on a valid language element." + |] + +[] +let ``type members 05 - auto-property``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +type A() = + ///B1 + ///B2 + [] + ///B3 + member val B = 1 with get, set +""" + checkResults + |> checkXml "get_B" [|"B1"; "B2"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 6, Col 4, Line 6, Col 9, "XML comment is not placed on a valid language element."|] + +[] +let ``type members 06 - implicit ctor``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +type A ///CTOR1 + ///CTOR2 + [] + ///CTOR3 + () = class end +""" + checkResults + |> checkXmls [ + "A", [||] + ".ctor", [|"CTOR1"; "CTOR2"|] + ] + + parseResults + |> checkParsingErrors [|Error 3520, Line 5, Col 7, Line 5, Col 15, "XML comment is not placed on a valid language element."|] + +[] +let ``record``(): unit = + checkSignatureAndImplementation """ +module Test + +type A = + { + ///B1 + ///B2 + [] + ///B3 + B: int + } +""" + (getFieldXml "A" "B" >> + compareXml [|"B1"; "B2"|]) + (checkParsingErrors [|Error 3520, Line 9, Col 8, Line 9, Col 13, "XML comment is not placed on a valid language element."|]) + +[] +let ``module 01``(): unit = + checkSignatureAndImplementation """ +///M1 +///M2 +[] +///M3 +module + ///M4 + rec M +""" + (checkXml "M" [|"M1"; "M2"|]) + (checkParsingErrors [| + Error 3520, Line 5, Col 0, Line 5, Col 5, "XML comment is not placed on a valid language element." + Error 3520, Line 7, Col 7, Line 7, Col 12, "XML comment is not placed on a valid language element." + |]) + +[] +let ``module 02 - attributes after 'module'``(): unit = + checkSignatureAndImplementation """ +///M1 +module ///M2 + [] + rec M +""" + (checkXml "M" [|"M1"|]) + (checkParsingErrors [| + Error 3350, Line 5, Col 7, Line 5, Col 10, "Feature 'attributes to the right of the 'module' keyword' is not available in F# 5.0. Please use language version 'preview' or greater." + Error 3520, Line 3, Col 7, Line 3, Col 12, "XML comment is not placed on a valid language element." + |]) + +[] +let ``union cases 01 - without bar``(): unit = + checkSignatureAndImplementation """ +module Test + +type A = + ///One1 + ///One2 + One + ///Two1 + ///Two2 + | Two +""" + (checkXmls [ + "One", [|"One1"; "One2"|] + "Two", [|"Two1"; "Two2"|] + ]) + (checkParsingErrors [||]) + +[] +let ``union cases 02``(): unit = + checkSignatureAndImplementation """ +module Test + +type A = + ///One1 + ///One2 + | [] + ///One3 + One + ///Two1 + ///Two2 + | [] + ///Two3 + Two +""" + (checkXmls [ + "One", [|"One1"; "One2"|] + "Two", [|"Two1"; "Two2"|] + ]) + (checkParsingErrors [| + Error 3520, Line 8, Col 6, Line 8, Col 13, "XML comment is not placed on a valid language element." + Error 3520, Line 13, Col 6, Line 13, Col 13, "XML comment is not placed on a valid language element." + |]) + +[] +let ``union cases 03 - union case fields``(): unit = + checkSignatureAndImplementation """ +module Test + +type Foo = +| Thing of + ///A1 + ///A2 + a: string * + ///B1 + ///B2 + bool +""" + (fun checkResults -> + getFieldXml "Thing" "a" checkResults + |> compareXml [|"A1"; "A2"|] + + getFieldXml "Thing" "Item2" checkResults + |> compareXml [|"B1"; "B2"|]) + + (checkParsingErrors [||]) + +[] +let ``extern``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +///E1 +///E2 +[] +///E3 +extern void E() +""" + checkResults + |> checkXml "E" [|"E1"; "E2"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 5, Col 0, Line 5, Col 5, "XML comment is not placed on a valid language element."|] + +[] +let ``exception 01 - allowed positions``(): unit = + checkSignatureAndImplementation """ +module Test + +///E1 +///E2 +[] +///E3 +exception ///E4 + E of string +""" + (checkXml "E" [|"E1"; "E2"|]) + (checkParsingErrors [| + Error 3520, Line 7, Col 0, Line 7, Col 5, "XML comment is not placed on a valid language element." + Error 3520, Line 8, Col 10, Line 8, Col 15, "XML comment is not placed on a valid language element." + |]) + +[] +let ``exception 02 - attribute after 'exception'``(): unit = + checkSignatureAndImplementation """ +module Test + +exception ///E + [] + E of string +""" + (checkXml "E" [||]) + (checkParsingErrors [|Error 3520, Line 4, Col 10, Line 4, Col 14, "XML comment is not placed on a valid language element."|]) + +[] +let ``val 01 - type``(): unit = + checkSignatureAndImplementation """ +module Test + +type A = + ///B1 + ///B2 + [] + ///B3 + ///B4 + val mutable private B: int +""" + (getFieldXml "A" "B" >> + compareXml [|"B1"; "B2"|]) + (checkParsingErrors [|Error 3520, Line 8, Col 4, Line 9, Col 9, "XML comment is not placed on a valid language element."|]) + +[] +let ``val 02 - struct``(): unit = + let parseResults, checkResults = getParseAndCheckResults """ +type Point = + struct + ///X1 + ///X2 + [] + ///X3 + val x: float + end +""" + checkResults + |> getFieldXml "Point" "x" + |> compareXml [|"X1"; "X2"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 7, Col 8, Line 7, Col 13, "XML comment is not placed on a valid language element."|] + +[] +let ``val 03 - module``(): unit = + let parseResults, checkResults = getParseAndCheckResultsOfSignatureFile """ +module Test + +///A1 +///A2 +[] +///A3 +val a: int +""" + checkResults + |> checkXml "a" [|"A1"; "A2"|] + + parseResults + |> checkParsingErrors [|Error 3520, Line 7, Col 0, Line 7, Col 5, "XML comment is not placed on a valid language element."|]