Create an API layer for external process#637
Create an API layer for external process#637MrLuje wants to merge 26 commits intofsprojects:masterfrom
Conversation
|
Added an |
|
Hello @MrLuje sorry for the delay here. Today I merged the NET5->NET6 transition. Can you now rebase this PR? |
6365ff0 to
b2c2b30
Compare
|
@knocte done |
|
|
||
| type VersionRequest = | ||
| { | ||
| FilePath: string |
There was a problem hiding this comment.
@MrLuje the consistency-chaser in me is wanting to suggest that we create here a similar type to Folder, e.g. File which uses FileInfo underneath (instead of DirectoryInfo)
There was a problem hiding this comment.
I'm all for consistency but IMHO there is less value for this one :
- VersionRequest is one of the API entrypoint (whereas
Folderwas only used internally) and it may be less intuitive to use - File check is already covered by
ErrFileNotFound, so we may want to change it if we go with theFileInfoway
There was a problem hiding this comment.
I know it has less value, but I'm just allergic to the PrimitiveObsession anti-pattern (since I came to know the type FileInfo, seeing a string for file paths makes my eyes bleed haha). I can make the change myself, I'll push to your branch yeah?
There was a problem hiding this comment.
There was a problem hiding this comment.
@MrLuje sure, I'll do it this week. BTW can you rebase the PR? looks like there is some conflict
|
@MrLuje side-note, the conflict is actually caused because there is a change in the 1st commit of this PR that has some unnecessary whitespace noise hehe: |
0757a99 to
8db5dc6
Compare
Oh, interesting, CI failed on your fork (macOS job), but I can't see the log because I guess I don't have permissions. Can you share it? |
Not a lot more information from my side (it timed out after 6h, maybe a runner issue ?) No more issue after a retry |
Hey @MrLuje, sorry for our delayed action on this, I just pushed a commit that introduces a Now, there are a couple of things to fix here:
|
| let handleFile filePath = | ||
| if not (isPathAbsolute filePath) then | ||
| Error FSharpLintServiceError.FilePathIsNotAbsolute | ||
| else match Folder.from filePath with |
There was a problem hiding this comment.
@MrLuje see the code here above? it is feeding a "filePath" to the Folder type. So is it a file or a folder? if it's a folder, it should be renamed from filePath to dirPath.
There was a problem hiding this comment.
It's a folder (getting the folder of a file)
There was a problem hiding this comment.
@MrLuje ok this is confusing, I thought the point of the from function was to convert a path(string) to a proper type. So, in my mind, Folder.from would map a (folderPath:string) to a (folder:Folder), and so that's why we included a File type equivalent to the Folder type that has a From method that works this way.
If we want to get the folder where a file lives, I think we should create an API that is more similar to the already existing BCL's System.IO API, to avoid confusions. So, in System.IO, the way to do this is convert the filePath:string to a FileInfo, and then accessing the .Directory property. So how about changing Folder's From method to receive a folderPath (not filePath; when given a filePath it should error saying that it is a file, not a folder). So if in this piece of code you want to get the folder where certain path lives, just create it via File.From and then let's create a Folder property in File type?
There was a problem hiding this comment.
I fear that it might be weird from a discovery POV (signature is a Folder but no clue that you have to go through a File before)
What about if Folder.From can handle both a filePath and a folderPath ? or a FromFile / FromFolder ?
There was a problem hiding this comment.
@MrLuje I like the FromFile/FromFolder idea, let's do it
There was a problem hiding this comment.
Done
I missed it when changing to FileInfo but I don't need Path.GetFullPath anymore, FileInfo handles it properly
2034983 to
2da5c06
Compare
Got it, cool new rule :) |
Introduce File type that checks existence of file on creation and is used in FSharpLintExecutableFile instead of string path.
ensure we can reuse an already found daemon version from another folder
bb70e3c to
a3429a0
Compare
|
@knocte done |

## Warning, I branched from the NET 6 version, so #606 should be merged first (ignore the first 4 commits for the review)WIP on #627, it covers the following points:
versionmethod for the Client/Console flowFSharpLint.ClientnugetAdd
--daemonflag to FSharpLint.ConsoleAll the "tool location detection" and "process handling" is copied from Fantomas project and adapted, basically:
Local DotnetToolfrom current file, then as aGlobal DotnetToolthen inPATHFSharpLint.Clientand theFSharpLint.Consoledaemon through JsonRpcI'll rebase everything once #606 is merged