-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diagnostics: Clearer information style #17488
Diagnostics: Clearer information style #17488
Conversation
|
@dotnet-policy-service agree |
* Add file content to message. * Use more symbols and line breaks to separate messages.
94272d6
to
4c79188
Compare
@DedSec256 had a bunch of changes made to diagnostics context some time ago, maybe he has a couple of thoughts and ideas. In general - we want to kept few things in mind:
In conclusion - thanks for that, we do want to make diagnostics prettier and add more context to them, but I think we want a more systematic approach. |
Wanted to expand of one of the points - a separate diagnostic style - it will certainly help to not change 100s of tests which match directly on the output, and will allow us to test things separately and make sure we didn't accidentally break anything in the process. |
@muqiuhan thanks for your first PR - welcome to the F# world 😎 We'll indeed need to discuss this one in a broader context since diags are a very complex topic. Meanwhile, if you are interested in it, feel free to address any of these problems we've already agreed on, some of them are great to get hands dirty here and we'll be happy to guide you and help you with them :) |
Thanks for the tip! I will try to participate in solving these problems ^_^ |
If you would like to, I can make this change in your branch (maybe later this week), to demonstrate what I mean. |
I understand what you mean, you expressed it very clearly, it's a great idea! like this: /// Represents the style being used to format errors
[<RequireQualifiedAccess>]
type DiagnosticStyle =
| Default
| Rich
... Then add it elsewhere: match tcConfig.diagnosticStyle with
| DiagnosticStyle.Emacs -> ...
| DiagnosticStyle.Default -> ...
| DiagnosticStyle.Rich -> ...
... |
Yep, precisely. And then we can add a new compiler flag, which will be selecting |
@muqiuhan : I have marked the PR as a draft to avoid accidental merging. Once this is done as a new DiagnosticsStyle (per the suggestion from Vlad above), this will be ready for merge. |
I intend to add a flag tomorrow so we can maybe start testing it sooner? It should take me a couple of hours. I will add a new format for the diagnostic and make tests green (won't be adding any tests now). Let me know if anyone has any objections. |
(me and @rainersigwald right now) We're going to be watching what y'all do from the perspective of "what information would a compiler need to give to MSBuild in order for MSBuild to be able to render a message as nicely as this". |
Currently, I'm going to test it with FSI, thought it's applicable to msbuild(fsc) as well. |
Great job @muqiuhan and @vzarytovskii. I’m looking forward to see what is next here. |
Happy to merge it if everyone agrees, to start working on some format adjustments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These bubbles looks weird to me really - but it's a good move anyway.
Yea, it's just "make it work" PR |
Leaving the merge on you here, in case you want anyone else to take a look. |
Description
In this PR, I tried to make some changes to CompilerDiagnostics.fs to make the compiler print clearer error messages (or warning messages, etc.)
I tried adding a Context field to
FormattedDiagnosticDetailedInfo
, which reads the corresponding content from the target file according to the information range indicated by the Range type, and then adds it tobuf
inPhasedDiagnostic
.This is my first time entering the world of the F# compiler, and I know this PR has a lot of issues, but I would like to put forward a small idea about #14832 . ^_^
Checklist