Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5c1cb81
Initial plan
Copilot Sep 8, 2025
1713662
Add basic XML doc comment position warning - initial implementation
Copilot Sep 8, 2025
8698eef
Add warning for XML documentation comments not positioned as first no…
Copilot Sep 8, 2025
21333cf
Fix XML doc comment position check to analyze actual line content ins…
Copilot Sep 8, 2025
7d2be7e
Address feedback by disabling hardcoded column limit approach tempora…
Copilot Sep 8, 2025
6413c55
Merge branch 'main' into copilot/fix-920e1d4e-0c13-4c25-8d7b-183dbc29…
T-Gro Sep 18, 2025
92f2c02
Address feedback: remove hardcoded column limit, disable warning temp…
Copilot Sep 19, 2025
e12e8cc
Implement XML doc comment position check in LexFilter instead of lexe…
Copilot Sep 19, 2025
fb42cf8
Merge branch 'main' into copilot/fix-920e1d4e-0c13-4c25-8d7b-183dbc29…
T-Gro Sep 22, 2025
28a6204
Fix type constraint mismatch in FSComp.SR.xmlDocNotFirstOnLine() usage
Copilot Sep 22, 2025
56607de
Fix unused variable warning in LexFilter pattern match
Copilot Sep 22, 2025
9d9a664
Merge branch 'main' into copilot/fix-920e1d4e-0c13-4c25-8d7b-183dbc29…
T-Gro Oct 17, 2025
83a3454
Update xlf localization files for xmlDocNotFirstOnLine entry
Copilot Nov 30, 2025
bd22c0e
Add lexer-level tracking for XML doc comment position warning
Copilot Dec 2, 2025
3070e3d
Fix incorrect /// comment usage in infos.fs - should be //
Copilot Dec 2, 2025
1f45f17
Disable XML doc position warning - implementation too aggressive
Copilot Dec 3, 2025
4ac9a26
Re-implement XML doc comment position warning using token position tr…
Copilot Dec 3, 2025
a560672
Add token position tracking to more token types and start updating tests
Copilot Dec 3, 2025
3f936f2
Update XmlDocTests to expect FS3879 warning for misplaced /// comments
Copilot Dec 3, 2025
df81dfb
Fix remaining test failures: update neg45.bsl baseline and type membe…
Copilot Dec 3, 2025
fc51e55
Fix code formatting in LexHelpers.fs and LexHelpers.fsi
Copilot Dec 3, 2025
4b58239
Merge branch 'main' into copilot/fix-920e1d4e-0c13-4c25-8d7b-183dbc29…
abonie Dec 5, 2025
c24643d
Update neg45.bsl baseline with all three FS3879 warnings
Copilot Dec 5, 2025
c2736dc
Fix /// comment in Trimming/Program.fs that was causing build failures
Copilot Dec 5, 2025
e171853
Change triple slash to regular comments
abonie Dec 8, 2025
b4a85cb
Fix XML documentation comment parse errors
abonie Dec 8, 2025
b3984a0
Undo changes to neg45.bsl
abonie Dec 8, 2025
0c6e957
Suppress FS3879 warning in AOT trimming test projects
Copilot Dec 9, 2025
d4b6661
Add release notes entry for FS3879 warning
Copilot Dec 9, 2025
c2112c5
Add test for DU cases with /// after case definition
Copilot Dec 9, 2025
2faae14
Fix DU test - use correct lambda signature (fun _ -> ()) instead of (…
Copilot Dec 10, 2025
4d16c5b
Fix DU test expected column positions - CaseB line should be Col 12, …
Copilot Dec 10, 2025
1006511
Rewrite XML doc position warning using LexFilter approach
Copilot Dec 31, 2025
337178d
Merge branch 'main' into copilot/fix-920e1d4e-0c13-4c25-8d7b-183dbc29…
T-Gro Jan 2, 2026
250ed38
Move release notes entry to 10.0.200.md as requested
Copilot Jan 2, 2026
696e8fb
Fix compilation errors - use COMMENT token and fix ODECLEND tuple
Copilot Jan 2, 2026
94f182c
Fix LexFilter code to properly check for XML doc comments
Copilot Jan 5, 2026
b3af608
fix build errors
T-Gro Jan 5, 2026
6a8696e
Apply patch from /run fantomas
actions-user Jan 5, 2026
c73cc4e
Fix FS3879 warning - move check from LexFilter to lex.fsl
Copilot Jan 5, 2026
001cbda
Allow XML doc comments after opening brace and equals in record types
Copilot Jan 6, 2026
541d143
Create proper GitHub Copilot Skills per documentation
Copilot Jan 6, 2026
5a4f398
Enhance GitHub Copilot Skills per review feedback
Copilot Jan 6, 2026
2fec170
Change FS3879 to informational warning and enable in F# codebase
Copilot Jan 6, 2026
60dd7bb
Fix invalid XML doc comments in Intellisense.fs
Copilot Jan 6, 2026
f3164c7
Merge branch 'main' into copilot/fix-920e1d4e-0c13-4c25-8d7b-183dbc29…
T-Gro Jan 6, 2026
c144a34
Apply suggestions from code review
T-Gro Jan 6, 2026
c014a7a
Merge branch 'main' into copilot/fix-920e1d4e-0c13-4c25-8d7b-183dbc29…
T-Gro Jan 12, 2026
2a31793
Remove no-op match and add tests for XML doc after = and { in express…
Copilot Jan 12, 2026
cca22f3
Update tests/FSharp.Compiler.Service.Tests/XmlDocTests.fs
T-Gro Jan 13, 2026
9fa902a
Update tests/FSharp.Compiler.Service.Tests/XmlDocTests.fs
T-Gro Jan 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix FS3879 warning - move check from LexFilter to lex.fsl
Moved XML doc position warning from LexFilter.fs to lex.fsl where we can properly detect /// comments. The warning now correctly triggers when /// appears after code on the same line.

Test Results:
- Total: 60 tests
- Passed: 55 (was 40)
- Failed: 0 (was 15)
- Skipped: 5
- Time: 6.8 seconds

Build: 3m 43.9s, 0 errors

Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
  • Loading branch information
Copilot and T-Gro committed Jan 5, 2026
commit c73cc4ec1064bc7939152dae78c2035a37186798
67 changes: 67 additions & 0 deletions HYPOTHESIS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# XML Doc Warning FS3879 - Investigation Hypotheses

## Test Failure Summary
- **Initial State**: Total tests: 60, Passed: 40, Failed: 15, Skipped: 5, Time: 7.1 seconds
- **After Fix**: Total tests: 60, Passed: 55, Failed: 0, Skipped: 5, Time: 6.8 seconds

## Failed Tests (Before Fix)
1. `let bindings 03 - 'let in' with attributes after 'let'`
2. `types 03 - xml doc after 'and'`
3. `exception 02 - attribute after 'exception'`
4. `types 05 - attributes after 'type'`
5. `let bindings 09 - xml doc after 'and'`
6. `type members 04 - property accessors`
7. `let bindings 10 - xml doc before/after 'and'`
8. `let bindings 01 - allowed positions`
9. `types 04 - xml doc before/after 'and'`
10. `Discriminated Union - triple slash after case definition should warn`
11. `exception 01 - allowed positions`
12. `let bindings 07 - attribute after 'let'`
13. `type members 06 - implicit ctor`
14. `module 02 - attributes after 'module'`
15. `type members 02`

## Hypothesis 1: The XmlDocCollector members are not being set correctly
**Problem**: The `SetLastNonCommentTokenLine` and `GetLastNonCommentTokenLine` methods in LexerStore.fs reference XmlDocCollector members that don't exist or aren't accessible.

**Evidence**: Compilation errors showed `XmlDocCollector` does not define these members even though they were supposedly added in commit 1006511.

**Test**: Check if XmlDoc.fs actually has the required members and if they're in the correct scope.

**Status**: ✅ RESOLVED - The members existed and were accessible.

## Hypothesis 2: The warning check in LexFilter is not correctly identifying /// comments
**Problem**: The code in rulesForBothSoftWhiteAndHardWhite may not be correctly checking for `///` comments or may not have access to the lexeme text.

**Evidence**: Tests are expecting FS3879 warnings but they're not being emitted. The attempt to access `lexbuf.LexBuffer.Lexeme` is incorrect - LexBuffer doesn't have a LexBuffer property.

**Test**: Verify how to correctly access comment text in LexFilter and check if the LINE_COMMENT token actually contains the text.

**Status**: ✅ CONFIRMED - This was a contributing factor but not the root cause.

## Hypothesis 3: The warning check is in the wrong location (LexFilter instead of lex.fsl)
**Problem**: The warning is being checked in LexFilter.fs at line 2640, but at that point:
1. We don't have reliable access to the lexeme text to check if it's `///` vs `//`
2. The LINE_COMMENT token doesn't distinguish between comment types
3. `lexbuf.LexemeView` may not be available or reliable in LexFilter

**Evidence**:
- The lexer (lex.fsl) at lines 740-746 specifically matches `///` and knows it's an XML doc comment
- The lexer already calls XmlDocStore functions (AddGrabPointDelayed)
- The lexer has access to the lexeme range and can easily check lastNonCommentTokenLine

**Solution**: Move the warning check from LexFilter.fs to lex.fsl, specifically in the `"///"` pattern handler at line 740-746.

**Status**: ✅ **CONFIRMED - THIS WAS THE ROOT CAUSE**

## Final Solution
1. ✅ Removed the incorrect warning check from LexFilter.fs (lines 2640-2660)
2. ✅ Added warning check in lex.fsl at line 740-746 (the `///` handler):
```fsharp
let lastNonCommentLine = XmlDocStore.GetLastNonCommentTokenLine lexbuf
if lastNonCommentLine = m.StartLine then
warning(Error(FSComp.SR.xmlDocNotFirstOnLine(), m))
```
3. ✅ Build command: `./build.sh -c Release` - Time: 3m 43.9s - Errors: 0
4. ✅ Test command: `dotnet test artifacts/bin/FSharp.Compiler.Service.Tests/Release/net10.0/FSharp.Compiler.Service.Tests.dll --filter "FullyQualifiedName~XmlDocTests"`
5. ✅ Final Results: **60 total tests, 55 passed, 0 failed, 5 skipped, 6.8 seconds**
20 changes: 0 additions & 20 deletions src/Compiler/SyntaxTree/LexFilter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2637,26 +2637,6 @@ type LexFilterImpl (
and rulesForBothSoftWhiteAndHardWhite(tokenTup: TokenTup) =
// Check if XML doc comment (///) appears after other code on the same line
match tokenTup.Token with
| LINE_COMMENT (LexCont.SingleLineComment _) ->
// Check if this is an XML doc comment (///) by examining the lexbuf content
let startPos = tokenTup.StartPos
let endPos = tokenTup.EndPos
if endPos.Column >= startPos.Column + 3 then
// Get the lexeme from the buffer
let lexbufSource = lexbuf.LexemeView
if lexbufSource.Length >= 3 then
let isXmlDoc =
lexbufSource[0] = '/' &&
lexbufSource[1] = '/' &&
lexbufSource[2] = '/'

if isXmlDoc then
let commentStartLine = startPos.Line
let lastNonCommentLine = XmlDocStore.GetLastNonCommentTokenLine lexbuf
if lastNonCommentLine = commentStartLine then
// XML doc comment appears on same line as previous non-comment token
let m = mkSynRange startPos (startPos.ShiftColumnBy(3))
warning(Error(FSComp.SR.xmlDocNotFirstOnLine(), m))
| _ -> ()

match tokenTup.Token with
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/lex.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ 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 this XML doc comment appears after other code on the same line
let lastNonCommentLine = XmlDocStore.GetLastNonCommentTokenLine lexbuf
if lastNonCommentLine = m.StartLine then
// XML doc comment appears on same line as previous non-comment token
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))
Expand Down
Loading