fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Synchronize implementation files and signature files

Open nojaf opened this issue 3 years ago • 1 comments

Large projects can benefit from signature files due to an optimization in FCS that skips type checking for files that have a matching signature file.

https://github.com/dotnet/fsharp/blob/36af364b538cde99d8de8df93db241af53329f22/src/Compiler/Driver/ParseAndCheckInputs.fs#L1211-L1229

This solution could make working on said large projects more optimal. The problem with this is that signature files can get out of sync quite rapidly when changing the implementation file.

Describe the solution you'd like

Could we at some level (FCS or editor) introduce a feature that automatically keeps signature files up to date? Or perhaps display a light bulb when the signature file no longer matches the implementation.

Describe alternatives you've considered

Maintain the signature files by hand.

Additional context

If we were to have a synchronization mechanism, I wonder if we could generate the files in a .vscode like folder? So that end-users don't even need to include them inside the fsproj.

nojaf avatar May 31 '22 14:05 nojaf

There are some codefixes around synchronization already - FSAC and VS both have a fix for renaming a parameter that has gotten out of sync with a signature file. But more would be good. It would also be nice to be able to generate a matching signature for a member.

baronfel avatar May 31 '22 14:05 baronfel

I messed around with some potential fix strategies in https://github.com/dotnet/fsharp/compare/main...nojaf:fsharp:sample-for-james?expand=1

I'm not sure we need something extra in FCS perse, each editor will deal with this in a slightly different way. The point is that GetValSignatureText can be used to propose the correct data to add or update the signature file.

nojaf avatar Jun 15 '23 19:06 nojaf