Skip to content

Conversation

@DedSec256
Copy link
Contributor

@DedSec256 DedSec256 commented Dec 11, 2025

This API allows the IDE to differentiate compiler errors from warnings. Useful, for example, for suggesting actions like adding a #nowarn directive.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/10.0.200.md

Copy link
Contributor

@Martin521 Martin521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes a lot of sense.
The whole diagnostics logging area is so over-complicated. I welcome every step to simplify it.

Copy link
Member

@auduchinok auduchinok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

@DedSec256 DedSec256 marked this pull request as ready for review December 15, 2025 16:54
@DedSec256 DedSec256 requested a review from a team as a code owner December 15, 2025 16:54
| FSharpDiagnosticSeverity.Hidden -> []
| adjustedSeverity ->

let diagnostic = { diagnostic with Severity = adjustedSeverity }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DedSec256 :

Without reading the implementation, I had problems imagining what default meant in the context of F.C.S public API.

Did you consider other names?
OriginalSeverity or UnadjustedSeverity perhaps?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current naming makes sense. Maybe an XmlDoc would be sufficient? We could then leave the current name. If not, I'd vote for OriginalSeverity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PhasedDiagnostic is not part of the public API, so I would keep it here as is.
See my comment below for the public API.

Copy link
Contributor Author

@DedSec256 DedSec256 Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, in Roslyn it is also known as 'DefaultSeverity'

https://github.com/dotnet/roslyn/blob/6c4a46a31302167b425d5e0a31ea83c9a9aa1d09/src/Compilers/Core/Portable/Diagnostic/Diagnostic.cs#L322

However, as for me, the documentation for this is even less informative than in this PR

| FSharpDiagnosticSeverity.Hidden -> []
| adjustedSeverity ->

let diagnostic = { diagnostic with Severity = adjustedSeverity }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PhasedDiagnostic is not part of the public API, so I would keep it here as is.
See my comment below for the public API.

member Severity: FSharpDiagnosticSeverity

/// Gets the default severity, does not take into account diagnostics options
member DefaultSeverity: FSharpDiagnosticSeverity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the original severity should be publicly accessible. It is an implementation detail. The adjusted severity is the specified output of the compiler (after applying the different flags and directives) and should be the only visible one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default severity levels (whether semantic treats a diagnostic as an error or a warning) for compiler diagnostics are publicly available and not determined by any special internal logic. In practice, they are also unlikely to change.
The FSharpDiagnostic API is used not only during compilation but also by the editor services. Therefore, it provides valuable information that enhances the user experience in the IDE — for example, the ExtendedData property, which allows the IDE to access additional diagnostic details for implementing quick fixes. And it would be nice to know not only how to display diagnostics, but also how significant they are: #nowarn can disable warnings promoted to errors, unlike real errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

4 participants