Closed OkkeHendriks closed 2 years ago
Hi Okke, I see your conundrum. Yes, the mismatch is an issue. There are ~1400 test cases, so my assumption is that a newer version which passes the existing tests, is assumed to be "more" correct. And this is all in a single assembly, so it likely won't be possible to have that as a setting in .editorconfig. But it's difficult to keep the tool versions constantly updated.
How about I add an option to try and use the version present in dotnet tools? Would that work out?
Yes I think that would definitely help!
When you say 'use the version present in dotnet tools' do you mean that it verifies that the versions match or would it be possible to actually use the dotnet-tool/apply a different version?
Verifying that the versions match might not be potentially very useful, because most of the time, they likely won't match up exactly. It's a bit more nuanced, I think. Suppose there's a solution with two projects
Solution
├───Project 1
│ └─── dotnet-tools.json
│ └─── File1.fs
├───Project 2
│ └─── dotnet-tools.json
│ └─── File2.fs
When you format File2.fs
, you should be formatting it with the version defined under Project 2
, correct?
We have the same problem: "We found a mismatch in the resulting formatting due to the fact that the tool was pinned on 4.3.0, while the extension was 0.7.3, build against fantomas 4.4.0." I did manage to build the F# Formatting tool with fantomas 4.3 (the latest stable version) and the problem was gone. It would be nice if you could create an version of the tool (F# formatting) using the latest stable version.
@OkkeHendriks Would this be able to solve your problem as well? (temporarily)
Yeah, I think this will help. With extension 0.7.3
and fantomas-tool 4.4.0-alpha-001
we still see another discrepancy in formatting. Apparently 0.7.3
was not build against that exact version of the tool.
While trying to find the exact version the extension uses I could not find the tag 0.7.3
? Anyhow it seems to be build against whatever HEAD of fantomas is at the moment of building via the submodule. I am not too familiar with git submodules but isn't it possible to pin the version there?
Ah, I now see your latest commit (https://github.com/deviousasti/fsharp-formatting-for-vs/commit/ce86917392491c32039d396e1717c7b3aa4a9b64 ). Do you plan to build stable with the nuget package and bleeding edge using the submodule?
@OkkeHendriks That's the plan. Although the implementation is slightly complicated because a number of types and libraries are incompatible between 4.3 and 4.4.
The biggest problem is that the nuget package uses an older version of FCS and this is something I need to control. I also publish F# Linting for VS which uses a newer version of FCS, and it's sure to break it for anyone if I publish it.
Additionally, 4.3.0 uses an additional package called Fantomas.Extras
(which was removed in 4.4) - which depends on a number of other packages.
I've pushed a release here (https://github.com/deviousasti/fsharp-formatting-for-vs/releases/tag/v0.7.4).
Please manually install it for now. I'll try to sort out the dual version this weekend.
Thanks for making the v0.7.4 release available for direct download here on GitHub. Could you perhaps do this for future releases as well?
This would be useful, since it will allow easy downloading and installing of a specific version (as far as I know this isn't currently possible from Visual Studio Marketplace). Combined with disabling automatic updates, this will allow manual syncing of fantomas-tool and F# Formatting versions, if need be.
(I'm on the same project team as @OkkeHendriks by the way.)
A dozen commits later, I've released version 0.8, which supports both bleeding edge and stable in a single extension. This can be changed in "Options > F# Formatting > Build Version". It defaults to stable (4.3.0 right now).
I believe this should be sorted for the immediate future. Perhaps, a future addition can be the warning of an older tool version, or using the specified tool version to format.
Thank you very much for your quick work, installing it right now!
I was browsing through the diffs and this caught my eye.
https://github.com/deviousasti/fsharp-formatting-for-vs/blob/3a8d9b8f08d3b08d048572572fd4c70fdb58f22c/src/FantomasHandler.cs#L283
Shouldn't there be a branch between StableCodeFormatter
and LatestCodeFormatter
there?
That's just a convenience method which calls FSharp.Compiler.Range.mkRange
, so the behavior shouldn't change. But good spotting, nonetheless.
I'm having this issue now with version 4.6.0-alpha-007
How about I add an option to try and use the version present in dotnet tools? Would that work out?
This would be the perfect solution for me.
Hello @peterhirn, we are looking for some help in #21 if you are interested.
Does this window open from this extension?
Yes, it does. That window opens when you don't have fantomas installed either globally or locally for the files which you're currently editing.
It is a typo in it
So at the end, will you migrate to #21 and not use the global tool?
@xperiandri #21 has been implemented. Global tool is only used as a fallback, in case the repository doesn't have fantomas installed. This is what's expected to happen when you format isolated files, like a script file.
In our setup our project members use this extension to format (on-save) while working on files, very nice! :). In our CI pipeline we use fantomas-tool to verify that the formatting is indeed as expected and thus that everybody had the extension installed or applied the formatting otherwise.
Both the extension and tool use the fantomas configuration from the .editorconfig in the repository.
We found a mismatch in the resulting formatting due to the fact that the tool was pinned on
4.3.0
, while the extension was0.7.3
, build against fantomas4.4.0
. This was fixed by changing the pinned version of the tool to4.4.0-alpha-001
.By default an extension automatically upgrades in VS, and it is not possible to install an old version easily.
It would be nice if there was a way to verify the fantomas version. As the reference fantoms version it could maybe use the dotnet-tool version in dotnet-tool.json and/or an entry in the .editorconfig?
Maybe pinning the fantomas version in the .editorconfig is an issue for fantomas itself? I am not sure.