Code previews in diagnostics
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
**Is your feature request related to a problem? Please describe.**
F#'s diagnostics are currently single-line brief descriptions with a span and a file id.

This is quite tedious, especially if you're actively working with the dotnet CLI through a terminal. It doesn't really give you an insight on *where* the issue occurs and forces the developer into spawning an editor and finding the location manually.
**Describe the solution you'd like**
The output containing a preview into the source code, with additional metadata and information pointed across spans. Even in simple cases, this is already quite an improvement. But in more complex cases, it can be particularly helpful.
Consider a hypothetical diagnostic such as this (Image : zesterer/ariadne, diagnostic library in Rust)

But this also inherently supports and encourages better, more supporting diagnostics into the compiler.
(Image : Rustc suggesting the proper keyword to use)

**Additional Context**
I would be most glad to implement this into the F# compiler. Bringing my (relatively small, but not insignificant) experience working around with Rustc's diagnostics and working with Ariadne into the F# compiler. =)
Contributor guide
Research direction
Start by reviewing how the F# compiler currently formats diagnostics and how the dotnet CLI presents them. Compare the requested source previews, span metadata, and supporting diagnostic suggestions with the examples in the issue. Done means compiler diagnostics provide useful source context without requiring the developer to open an editor.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100