diff --git a/src/Compiler/Checking/infos.fs b/src/Compiler/Checking/infos.fs index 58f973e928a..753253be4e6 100644 --- a/src/Compiler/Checking/infos.fs +++ b/src/Compiler/Checking/infos.fs @@ -1516,7 +1516,7 @@ type ILFieldInfo = match x with | ILFieldInfo(tinfo, _) -> tinfo.TypeInstOfRawMetadata #if !NO_TYPEPROVIDERS - | ProvidedField _ -> [] /// GENERIC TYPE PROVIDERS + | ProvidedField _ -> [] // GENERIC TYPE PROVIDERS #endif /// Get the name of the field diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 512e9b4dca7..16701252d0b 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1813,4 +1813,5 @@ featureAllowLetOrUseBangTypeAnnotationWithoutParens,"Allow let! and use! type an 3876,lexWarnDirectivesMustMatch,"There is another %s for this warning already in line %d." 3877,lexLineDirectiveMappingIsNotUnique,"The file '%s' was also pointed to in a line directive in '%s'. Proper warn directive application may not be possible." 3878,tcAttributeIsNotValidForUnionCaseWithFields,"This attribute is not valid for use on union cases with fields." +3879,xmlDocNotFirstOnLine,"XML documentation comments should be the first non-whitespace text on a line." featureReturnFromFinal,"Support for ReturnFromFinal/YieldFromFinal in computation expressions to enable tailcall optimization when available on the builder." diff --git a/src/Compiler/SyntaxTree/LexHelpers.fs b/src/Compiler/SyntaxTree/LexHelpers.fs index 9e390178c18..ea00a616b30 100644 --- a/src/Compiler/SyntaxTree/LexHelpers.fs +++ b/src/Compiler/SyntaxTree/LexHelpers.fs @@ -62,6 +62,10 @@ type LexArgs = mutable indentationSyntaxStatus: IndentationAwareSyntaxStatus mutable stringNest: LexerInterpolatedStringNesting mutable interpolationDelimiterLength: int + /// Tracks the line number of the last non-whitespace, non-comment token + mutable lastTokenEndLine: int + /// Tracks the end column of the last non-whitespace, non-comment token + mutable lastTokenEndColumn: int } /// possible results of lexing a long Unicode escape sequence in a string literal, e.g. "\U0001F47D", @@ -84,6 +88,8 @@ let mkLexargs stringNest = [] pathMap = pathMap interpolationDelimiterLength = 0 + lastTokenEndLine = 0 + lastTokenEndColumn = 0 } /// Register the lexbuf and call the given function @@ -444,9 +450,16 @@ module Keywords = if IsCompilerGeneratedName s then warning (Error(FSComp.SR.lexhlpIdentifiersContainingAtSymbolReserved (), lexbuf.LexemeRange)) + // Track token position for XML doc comment checking + args.lastTokenEndLine <- lexbuf.EndPos.Line + args.lastTokenEndColumn <- lexbuf.EndPos.Column args.resourceManager.InternIdentifierToken s let KeywordOrIdentifierToken args (lexbuf: Lexbuf) s = + // Track token position for XML doc comment checking + args.lastTokenEndLine <- lexbuf.EndPos.Line + args.lastTokenEndColumn <- lexbuf.EndPos.Column + match keywordTable.TryGetValue s with | true, v -> match v with diff --git a/src/Compiler/SyntaxTree/LexHelpers.fsi b/src/Compiler/SyntaxTree/LexHelpers.fsi index 2fe067d244a..6627b1ebf4a 100644 --- a/src/Compiler/SyntaxTree/LexHelpers.fsi +++ b/src/Compiler/SyntaxTree/LexHelpers.fsi @@ -29,15 +29,21 @@ type LexResourceManager = /// The context applicable to all lexing functions (tokens, strings etc.) type LexArgs = - { conditionalDefines: string list - resourceManager: LexResourceManager - diagnosticsLogger: DiagnosticsLogger - applyLineDirectives: bool - pathMap: PathMap - mutable ifdefStack: LexerIfdefStack - mutable indentationSyntaxStatus: IndentationAwareSyntaxStatus - mutable stringNest: LexerInterpolatedStringNesting - mutable interpolationDelimiterLength: int } + { + conditionalDefines: string list + resourceManager: LexResourceManager + diagnosticsLogger: DiagnosticsLogger + applyLineDirectives: bool + pathMap: PathMap + mutable ifdefStack: LexerIfdefStack + mutable indentationSyntaxStatus: IndentationAwareSyntaxStatus + mutable stringNest: LexerInterpolatedStringNesting + mutable interpolationDelimiterLength: int + /// Tracks the line number of the last non-whitespace, non-comment token + mutable lastTokenEndLine: int + /// Tracks the end column of the last non-whitespace, non-comment token + mutable lastTokenEndColumn: int + } type LongUnicodeLexResult = | SurrogatePair of uint16 * uint16 diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index 1f905bc049a..51077a0669b 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -54,6 +54,12 @@ let fail args (lexbuf:UnicodeLexing.Lexbuf) msg dflt = args.diagnosticsLogger.ErrorR(Error(msg,m)) dflt +/// Update tracking of the last token position for XML doc comment position checking +let updateLastTokenPos (args: LexArgs) (lexbuf: UnicodeLexing.Lexbuf) = + let endPos = lexbuf.EndPos + args.lastTokenEndLine <- endPos.Line + args.lastTokenEndColumn <- endPos.Column + //-------------------------- // Integer parsing @@ -412,6 +418,7 @@ rule token (args: LexArgs) (skip: bool) = parse | int { let s = removeUnderscores (lexeme lexbuf) // Allow to parse as min_int. Allowed only because we parse '-' as an operator. + updateLastTokenPos args lexbuf if Ranges.isInt32BadMax s then INT32(Int32.MinValue, true (* 'true' = 'bad'*) ) else let n = try int32 s with _ -> fail args lexbuf (FSComp.SR.lexOutsideThirtyTwoBitSigned()) 0 @@ -422,6 +429,7 @@ rule token (args: LexArgs) (skip: bool) = parse | int32 { let s = removeUnderscores (lexemeTrimRight lexbuf 1) // Allow to parse as min_int. Allowed only because we parse '-' as an operator. + updateLastTokenPos args lexbuf if Ranges.isInt32BadMax s then INT32(Int32.MinValue, true (* 'true' = 'bad'*) ) else let n = try int32 s with _ -> fail args lexbuf (FSComp.SR.lexOutsideThirtyTwoBitSigned()) 0 @@ -484,10 +492,12 @@ rule token (args: LexArgs) (skip: bool) = parse } | ieee64 - { IEEE64 (try float(lexeme lexbuf) with _ -> fail args lexbuf (FSComp.SR.lexInvalidFloat()) 0.0) } + { updateLastTokenPos args lexbuf + IEEE64 (try float(lexeme lexbuf) with _ -> fail args lexbuf (FSComp.SR.lexInvalidFloat()) 0.0) } | decimal - { try + { updateLastTokenPos args lexbuf + try let s = removeUnderscores (lexemeTrimRight lexbuf 1) // This implements a range check for decimal literals let d = System.Decimal.Parse(s,System.Globalization.NumberStyles.AllowExponent ||| System.Globalization.NumberStyles.Number,System.Globalization.CultureInfo.InvariantCulture) @@ -740,6 +750,10 @@ rule token (args: LexArgs) (skip: bool) = parse | "///" op_char* { // Match exactly 3 slash, 4+ slash caught by preceding rule let m = lexbuf.LexemeRange + // Check if there was a token on this line before this /// comment + // If lastTokenEndLine matches the current line, there's code before the comment + if args.lastTokenEndLine = m.StartLine then + warning (Error(FSComp.SR.xmlDocNotFirstOnLine(), m)) let doc = lexemeTrimLeft lexbuf 3 let sb = (new StringBuilder(100)).Append(doc) if not skip then LINE_COMMENT (LexCont.SingleLineComment(args.ifdefStack, args.stringNest, 1, m)) @@ -852,7 +866,7 @@ rule token (args: LexArgs) (skip: bool) = parse | '(' { LPAREN } - | ')' { RPAREN } + | ')' { updateLastTokenPos args lexbuf; RPAREN } | '*' { STAR } @@ -910,13 +924,13 @@ rule token (args: LexArgs) (skip: bool) = parse | "[<" { LBRACK_LESS } - | "]" { RBRACK } + | "]" { updateLastTokenPos args lexbuf; RBRACK } - | "|]" { BAR_RBRACK } + | "|]" { updateLastTokenPos args lexbuf; BAR_RBRACK } - | "|}" { BAR_RBRACE } + | "|}" { updateLastTokenPos args lexbuf; BAR_RBRACE } - | ">]" { GREATER_RBRACK } + | ">]" { updateLastTokenPos args lexbuf; GREATER_RBRACK } | "{" { @@ -966,10 +980,12 @@ rule token (args: LexArgs) (skip: bool) = parse // will be reported w.r.t. the first '{' args.stringNest <- (counter - 1, style, d, altR, m) :: rest let cont = LexCont.Token(args.ifdefStack, args.stringNest) + updateLastTokenPos args lexbuf RBRACE cont | _ -> let cont = LexCont.Token(args.ifdefStack, args.stringNest) + updateLastTokenPos args lexbuf RBRACE cont } diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 244be90e142..9ddd2fed1a2 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -2037,6 +2037,11 @@ Tento komentář XML není platný: chybí atribut name pro parametr nebo odkaz na parametr + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' Tento komentář XML není platný: nepřeložený křížový odkaz {0} diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index d1b1782d093..c57c10614f5 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -2037,6 +2037,11 @@ Dieser XML-Kommentar ist ungültig: Attribut "name" für Parameter oder Parameterverweis fehlt. + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' Dieser XML-Kommentar ist ungültig: nicht aufgelöster Querverweis "{0}". diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index cd311cc7fc5..15b9db05ec1 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -2037,6 +2037,11 @@ El comentario XML no es válido: falta el atributo "name" para el parámetro o la referencia de parámetro + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' El comentario XML no es válido: la referencia cruzada "{0}" no se ha resuelto diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index e05e9ecdf6c..028a942abd4 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -2037,6 +2037,11 @@ Ce commentaire XML est non valide : attribut 'name' manquant pour le paramètre ou la référence de paramètre + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' Ce commentaire XML est non valide : référence croisée non résolue '{0}' diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index a25fd816046..51c0e773cce 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -2037,6 +2037,11 @@ Questo commento XML non è valido: manca l'attributo 'name' per il parametro o il riferimento a parametro + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' Questo commento XML non è valido: il riferimento incrociato '{0}' non è stato risolto diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 87b7d40df1e..23ac619d8eb 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -2037,6 +2037,11 @@ この XML コメントは無効です: パラメーターまたはパラメーター参照に 'name' 属性がありません + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' この XML コメントは無効です: 相互参照 '{0}' が未解決です diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index f2fe6e20f97..2b329be44e3 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -2037,6 +2037,11 @@ 이 XML 주석이 잘못됨: 매개 변수 또는 매개 변수 참조에 'name' 특성이 없음 + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' 이 XML 주석이 잘못됨: 확인되지 않은 상호 참조 '{0}' diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 23a194ff258..d70411255f7 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -2037,6 +2037,11 @@ Ten komentarz XML jest nieprawidłowy: brak atrybutu „name” dla parametru lub odwołania parametru + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' Ten komentarz XML jest nieprawidłowy: nierozpoznany odsyłacz „{0}” diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 503fc0f073f..608b56e9d3c 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -2037,6 +2037,11 @@ Este comentário XML é inválido: atributo 'name' ausente para parâmetro ou referência de parâmetro + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' Este comentário XML é inválido: referência cruzada não resolvida '{0}' diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 7013fb0bc83..1e778b36445 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -2037,6 +2037,11 @@ Недопустимый XML-комментарий: отсутствует атрибут "name" для параметра или ссылки на параметр + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' Недопустимый XML-комментарий: неразрешенная перекрестная ссылка "{0}" diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index 49d2a295b45..1caee47ce9b 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -2037,6 +2037,11 @@ Bu XML açıklaması geçersiz: Parametre veya parametre başvurusu için 'name' özniteliği eksik + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' Bu XML açıklaması geçersiz: '{0}' çapraz başvurusu çözümlenmemiş diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index 3fc65eebc96..62e016388f7 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -2037,6 +2037,11 @@ 此 XML 注释无效: 参数或参数引用缺少 "name" 属性 + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' 此 XML 注释无效: 交叉引用“{0}”无法解析 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index 07fea0efd23..7256c4709a6 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -2037,6 +2037,11 @@ 此 XML 註解無效: 參數或參數參考沒有 'name' 屬性 + + XML documentation comments should be the first non-whitespace text on a line. + XML documentation comments should be the first non-whitespace text on a line. + + This XML comment is invalid: unresolved cross-reference '{0}' 此 XML 註解無效: 未解析的交互參照 '{0}' diff --git a/tests/AheadOfTime/Trimming/Program.fs b/tests/AheadOfTime/Trimming/Program.fs index f67c31a0013..6f5e806b099 100644 --- a/tests/AheadOfTime/Trimming/Program.fs +++ b/tests/AheadOfTime/Trimming/Program.fs @@ -8262,7 +8262,7 @@ let func7000()= test "test7935" (lazy(sprintf "%+0G" -10.0M)) "-10" test "test7936" (lazy(sprintf "%+05G" -10.0M)) "-0010"// "00-10" test "test7937" (lazy(sprintf "%+01G" -10.0M)) "-10" - test "test7938" (lazy(sprintf "%+0*G" 7 -10.0M)) "-000010"/// "0000-10" + test "test7938" (lazy(sprintf "%+0*G" 7 -10.0M)) "-000010"// "0000-10" test "test7939" (lazy(sprintf "%+0.5G" -10.0M)) "-10" test "test7940" (lazy(sprintf "%+0.*G" 4 -10.0M)) "-10" test "test7941" (lazy(sprintf "%+0*.*G" 5 4 -10.0M)) "-0010"// "00-10" diff --git a/tests/FSharp.Compiler.Service.Tests/XmlDocTests.fs b/tests/FSharp.Compiler.Service.Tests/XmlDocTests.fs index 01c7b3b0775..a5b5220860b 100644 --- a/tests/FSharp.Compiler.Service.Tests/XmlDocTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/XmlDocTests.fs @@ -404,7 +404,10 @@ and ///B1 (checkXml "B" [|"B1"; "B2"|]) (fun parseResults -> parseResults |> - checkParsingErrors [|Information 3520, Line 8, Col 4, Line 8, Col 9, "XML comment is not placed on a valid language element."|] + checkParsingErrors [| + Warning 3879, Line 5, Col 4, Line 5, Col 7, "XML documentation comments should be the first non-whitespace text on a line." + Information 3520, Line 8, Col 4, Line 8, Col 9, "XML comment is not placed on a valid language element." + |] match parseResults.ParseTree with | Types(range, [_; TypeRange(typeRange2, synComponentRange2)]) @@ -428,7 +431,10 @@ and ///B2 (checkXml "B" [|"B1"|]) (fun parseResults -> parseResults |> - checkParsingErrors [|Information 3520, Line 6, Col 4, Line 6, Col 9, "XML comment is not placed on a valid language element."|] + checkParsingErrors [| + Warning 3879, Line 6, Col 4, Line 6, Col 7, "XML documentation comments should be the first non-whitespace text on a line." + Information 3520, Line 6, Col 4, Line 6, Col 9, "XML comment is not placed on a valid language element." + |] match parseResults.ParseTree with | Types(range, [_; TypeRange(typeRange2, synComponentRange2)]) @@ -451,7 +457,10 @@ type ///A2 (checkXml "A" [|"A1"|]) (fun parseResults -> parseResults |> - checkParsingErrors [|Information 3520, Line 5, Col 5, Line 5, Col 10, "XML comment is not placed on a valid language element."|] + checkParsingErrors [| + Warning 3879, Line 5, Col 5, Line 5, Col 8, "XML documentation comments should be the first non-whitespace text on a line." + Information 3520, Line 5, Col 5, Line 5, Col 10, "XML comment is not placed on a valid language element." + |] match parseResults.ParseTree with | Types(range, [TypeRange(typeRange, synComponentRange)]) @@ -523,6 +532,9 @@ let ///f2 parseResults |> checkParsingErrors [| + Warning 3879, Line 3, Col 4, Line 3, Col 7, "XML documentation comments should be the first non-whitespace text on a line." + Warning 3879, Line 4, Col 8, Line 4, Col 11, "XML documentation comments should be the first non-whitespace text on a line." + Warning 3879, Line 5, Col 15, Line 5, Col 18, "XML documentation comments should be the first non-whitespace text on a line." Information 3520, Line 3, Col 4, Line 3, Col 9, "XML comment is not placed on a valid language element." Information 3520, Line 4, Col 8, Line 4, Col 13, "XML comment is not placed on a valid language element." Information 3520, Line 5, Col 15, Line 5, Col 20, "XML comment is not placed on a valid language element." @@ -604,7 +616,10 @@ let ///X |> checkXml "x" [||] parseResults - |> checkParsingErrors [|Information 3520, Line 2, Col 4, Line 2, Col 8, "XML comment is not placed on a valid language element."|] + |> checkParsingErrors [| + Warning 3879, Line 2, Col 4, Line 2, Col 7, "XML documentation comments should be the first non-whitespace text on a line." + Information 3520, Line 2, Col 4, Line 2, Col 8, "XML comment is not placed on a valid language element." + |] match parseResults.ParseTree with | LetBindings(range, [binding]) -> @@ -688,7 +703,10 @@ let ///X2 |> checkXml "x" [|"X1"|] parseResults - |> checkParsingErrors [|Information 3520, Line 3, Col 4, Line 3, Col 9, "XML comment is not placed on a valid language element."|] + |> checkParsingErrors [| + Warning 3879, Line 3, Col 4, Line 3, Col 7, "XML documentation comments should be the first non-whitespace text on a line." + Information 3520, Line 3, Col 4, Line 3, Col 9, "XML comment is not placed on a valid language element." + |] match parseResults.ParseTree with | LetBindings(range, [binding]) -> @@ -733,7 +751,10 @@ and ///G1 |> checkXml "g" [|"G1"; "G2"|] parseResults - |> checkParsingErrors [|Information 3520, Line 6, Col 4, Line 6, Col 9, "XML comment is not placed on a valid language element."|] + |> checkParsingErrors [| + Warning 3879, Line 3, Col 4, Line 3, Col 7, "XML documentation comments should be the first non-whitespace text on a line." + Information 3520, Line 6, Col 4, Line 6, Col 9, "XML comment is not placed on a valid language element." + |] match parseResults.ParseTree with | LetBindings(range, [binding1; binding2]) -> @@ -755,7 +776,10 @@ and ///G2 |> checkXml "g" [|"G1"|] parseResults - |> checkParsingErrors [|Information 3520, Line 4, Col 4, Line 4, Col 9, "XML comment is not placed on a valid language element."|] + |> checkParsingErrors [| + Warning 3879, Line 4, Col 4, Line 4, Col 7, "XML documentation comments should be the first non-whitespace text on a line." + Information 3520, Line 4, Col 4, Line 4, Col 9, "XML comment is not placed on a valid language element." + |] match parseResults.ParseTree with | LetBindings(range, [binding1; binding2]) -> @@ -823,6 +847,7 @@ type A = parseResults |> checkParsingErrors [| + Warning 3879, Line 3, Col 19, Line 3, Col 22, "XML documentation comments should be the first non-whitespace text on a line." Information 3520, Line 3, Col 19, Line 3, Col 24, "XML comment is not placed on a valid language element." Information 3520, Line 9, Col 4, Line 9, Col 9, "XML comment is not placed on a valid language element." |] @@ -883,6 +908,7 @@ type B = parseResults |> checkParsingErrors [| + Warning 3879, Line 5, Col 11, Line 5, Col 14, "XML documentation comments should be the first non-whitespace text on a line." Information 3520, Line 5, Col 11, Line 5, Col 16, "XML comment is not placed on a valid language element." Information 3520, Line 7, Col 16, Line 7, Col 22, "XML comment is not placed on a valid language element." Information 3520, Line 9, Col 16, Line 9, Col 22, "XML comment is not placed on a valid language element." @@ -935,7 +961,10 @@ type A ///CTOR1 ] parseResults - |> checkParsingErrors [|Information 3520, Line 5, Col 7, Line 5, Col 15, "XML comment is not placed on a valid language element."|] + |> checkParsingErrors [| + Warning 3879, Line 2, Col 7, Line 2, Col 10, "XML documentation comments should be the first non-whitespace text on a line." + Information 3520, Line 5, Col 7, Line 5, Col 15, "XML comment is not placed on a valid language element." + |] match parseResults.ParseTree with | Members([SynMemberDefn.ImplicitCtor(range = range)]) -> @@ -1051,6 +1080,7 @@ module ///M2 (fun parseResults -> parseResults |> checkParsingErrors [| + Warning 3879, Line 3, Col 7, Line 3, Col 10, "XML documentation comments should be the first non-whitespace text on a line." Information 3520, Line 3, Col 7, Line 3, Col 12, "XML comment is not placed on a valid language element." |] @@ -1225,6 +1255,7 @@ exception ///E4 (fun parseResults -> parseResults |> checkParsingErrors [| + Warning 3879, Line 8, Col 10, Line 8, Col 13, "XML documentation comments should be the first non-whitespace text on a line." Information 3520, Line 7, Col 0, Line 7, Col 5, "XML comment is not placed on a valid language element." Information 3520, Line 8, Col 10, Line 8, Col 15, "XML comment is not placed on a valid language element." |] @@ -1247,7 +1278,10 @@ exception ///E (checkXml "E" [||]) (fun parseResults -> parseResults |> - checkParsingErrors [|Information 3520, Line 4, Col 10, Line 4, Col 14, "XML comment is not placed on a valid language element."|] + checkParsingErrors [| + Warning 3879, Line 4, Col 10, Line 4, Col 13, "XML documentation comments should be the first non-whitespace text on a line." + Information 3520, Line 4, Col 10, Line 4, Col 14, "XML comment is not placed on a valid language element." + |] match parseResults.ParseTree with | Exception(exnRange, exnDefnRange, exnDefnReprRange) -> diff --git a/tests/fsharp/typecheck/sigs/neg45.bsl b/tests/fsharp/typecheck/sigs/neg45.bsl index 3ec59a417f6..91a99e6f2ad 100644 --- a/tests/fsharp/typecheck/sigs/neg45.bsl +++ b/tests/fsharp/typecheck/sigs/neg45.bsl @@ -1,3 +1,8 @@ +neg45.fs(89,42,89,45): parse error FS3879: XML documentation comments should be the first non-whitespace text on a line. + +neg45.fs(97,55,97,58): parse error FS3879: XML documentation comments should be the first non-whitespace text on a line. + +neg45.fs(102,30,102,33): parse error FS3879: XML documentation comments should be the first non-whitespace text on a line. neg45.fs(12,5,12,11): typecheck error FS0685: The generic function 'Foo' must be given explicit type argument(s)