-
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
Show default value of compiler options #18054
Conversation
❗ Release notes required
|
tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/misc/compiler_help_output.bsl
Outdated
Show resolved
Hide resolved
Thank you for the first contribution. The default value for each switch can change over time (and it does), and is not only done so via .fs code in the compiler project itself, the default can also be specified in the respective Fsc and Fsi msbuild build tasks. This makes a hardcoded selection of defaults, directly as text, prone to mismatches when settings are changed. Even more so when immediate changes of values can happen as a consequence of issues that need immediate fixing. This then resurfaces one more time as a result of tests needing a change every time a value changes it's defaultness as well. The fact of settings being a "living" artefact that changes over time and the situation of being override-able at more levels (compiler project, Fsc/Fsi build task, xml config in .net sdk targets) makes a human-managed text easy to get wrong as time passes. Another small, but acceptable, downside is that every text has to be localized for every supported language. And text needing review / retranslation, even if small suffix like "default:true" is added or when the default gets changed. I think this only makes sense for acceptance if it can be fully automated and will not get in the way of changing values |
+1 to what Tomáš wrote, hardcoding defaults for what they are at this point in time will bring more desynchronisation, ideally we want to generate them from the actual defaults in code (which might require a redoing how flags are parsed/stored). |
I think this is decent improvement to the command line compiler. It does make the things the compiler does a bit clearer. It is fair to say that the way this feature is tested is a lot dependent on the console output and is thus sensitive to spelling corrections, additional options and text changes, but that is what the feature is. As for translation, the repo is set up to make it as easy as possible for our translation partners to make those changes. So we would always take change that improve clarity. |
If the F# compiler is meant to be a product, then there must be documentation for the flag defaults. For both fsc and the build task. And every change of the default value must be documented and tested, also in "urgent" cases. Therefore, I like very much that this contribution makes an attempt to provide such documentation. |
Yes, however it's "hard-coded" here in the message itself, meaning when you change default for the given option, documentation won't reflect it, and one will need to go and change documentation, every single translation, change help baseline tests (and they won't be failing either if the default is changed accidentally). Default values should be auto-generated from actual default values. But this will require change in how compiler options are organised. This will allow us to easier change defaults, and will prevent changing it accidentally, since baseline tests will start failing. |
Thanks for the feedbacks, @T-Gro is right this should be auto generated, I did this way because I saw |
That's a good point. I wander if should be hardcoding more or shall invest in having some universal mechanism of printing them. |
We for sure cannot risk the defaults being wrong. Between an automated test checking correctness, and an automated implementation - I am more inclined to an automated implementation. |
I've made some changes in the code and would like to know if I'm going in the right direction, my idea is to create multiple |
@T-Gro Now it's auto-generated, but I still have problems with |
What is the spacing problem? Is it not deterministic? |
I pasted the expected and actual from the test output to an online diff and it shows that there's multiple spaces before the text I updated I have no idea how to solve it, the |
I assume the help is printed using a maxWidth setting. |
@T-Gro Fixed it, now I think it's ready for review |
The test still fails on CI, was it passing locally? Failed FSharp.Compiler.Service.Tests.ConsoleOnlyOptionsTests.fsc help text is displayed correctly [8 ms] |
The only failing tests are FsharpQA now - if you haven't seen it yet, the testguide https://github.com/dotnet/fsharp/blob/main/TESTGUIDE.md has instructions on it. |
Passed |
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.
Great work, thanks a tonne!
This is ready to merge - it will auto-merge once release notes are added. |
Really good stuff, one of the things I was missing here - great work Fernando! |
Head branch was pushed to by a user without write access
Description
Fixes #16294
I used the following files as reference to get the default values:
Unfortunately I could not make the
Help - variant
tests pass because of a generation mismatch on--delaysign
and--realsig
, I need a little bit of help on thisChecklist
Test cases added
Performance benchmarks added in case of performance changes
Release notes entry updated: