-
Notifications
You must be signed in to change notification settings - Fork 585
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
[WIP] Fake.IO.FileSystem rework #1670
[WIP] Fake.IO.FileSystem rework #1670
Conversation
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.
Thanks for taking care of the cleanup work!
There are some things I have not decided yet, but I think we can release it like this anyway (it probably is a bit more sane than before)
src/app/Fake.Core.Process/Process.fs
Outdated
@@ -361,7 +361,7 @@ let tryFindFile dirs file = | |||
|> String.replace "[ProgramFiles]" Environment.ProgramFiles | |||
|> String.replace "[ProgramFilesX86]" Environment.ProgramFilesX86 | |||
|> String.replace "[SystemRoot]" Environment.SystemRoot | |||
|> DirectoryInfo.ofPath |
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.
I'm really back and forth about this. We have ofSeq
ofList
and a lot of these everywhere. But you are right in that this meets the F# Guidelines better :/
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.
As said on Gitter, I asked people at FableConf, people seems to prefer camelCase for functions.
@@ -0,0 +1,49 @@ | |||
namespace Fake.IO.FileSystem |
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.
Maybe these modules should move to Fake.IO
:/
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.
no preferences...
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.
Yes I think we should move them (I can do that if you want), because then it is more similar to System.IO
and one less open Fake.IO.FileSystem
at the top...
module Directory = | ||
|
||
/// Creates a directory if it does not exist. | ||
let CreateDir path = |
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.
Create
?
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.
Yep not yet cleaned all modules, just the DirectoryInfo one.
if not (Directory.Exists dir) then | ||
Directory.CreateDirectory dir |> ignore | ||
|
||
let isDirectory path = Path.isDirectory path |
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.
Directory.isDirectory path
reads a bit strange. Though I have no suggestion how to improve. Maybe just leave Directory.Exist
and drop this?
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.
Obsolete to use Path.IsDirectory?
|> DirectoryInfo.OfPath | ||
|> DirectoryInfo.MatchingFiles pattern | ||
|> fun files -> | ||
if Seq.isEmpty files then None |
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.
Seq.tryHead
?
//|> (SetReadOnly false) | ||
//logfn "Deleting %s" dir.FullName | ||
dir.Delete true | ||
else () //TODO: logfn "%s does not exist." dir.FullName |
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.
After all these comments: The Directory
module is really not well thought through - for historic reasons. Read my comments not as something you need to fix but as thoughts I'm having when I go through the code...
|> Seq.toList) @ files | ||
|
||
/// Copies the file structure recursively. | ||
let CopyRecursiveTo overwrite (outputDir : DirectoryInfo) (dir : DirectoryInfo) = CopyRecursiveToWithFilter overwrite (fun _ _ -> true) outputDir dir |
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.
The DirectoryInfo
module reads a lot better...
@@ -1,304 +0,0 @@ | |||
/// Contains helpers which allow to interact with the file system. | |||
namespace Fake.IO.FileSystem |
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.
Generally I don't feel we need to have a separate file for each module (this is not C#).
I'm not against splitting on some defined boundaries, for example we could split out the Operators
or File/FileInfo
, but as they are quite coupled I don't think that is too viable.
This module is probably one of the hardest to get into a nice state.
@@ -0,0 +1,26 @@ | |||
/// NOTE: Maybe this should be an extra module? | |||
/// Contains basic templating functions. Used in other helpers. | |||
module Fake.IO.FileSystem.Templates |
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.
Yes, currently this is quite coupled throughout other modules. I don't like this module ... Kind of broken by design.
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.
But works in practice /shrug
src/Fake-netcore.sln
Outdated
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26124.0 |
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.
I'm pretty sure something in here makes the build fail on travis... Maybe try to minimize the diff here or revert this change and add changes by hand?
The appveyor failure has something to do with the tests for the legacy FakeLib component. Some behavior was changed?
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.
yep not intended to cmmit this file...I will revert
671e441
to
429a520
Compare
1838e79
to
9eac867
Compare
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.
I really really like it :)
@@ -134,7 +139,7 @@ Target.Create "RenameFSharpCompilerService" (fun _ -> | |||
for framework in ["netstandard1.6"; "net45"] do | |||
let dir = __SOURCE_DIRECTORY__ </> "packages"</>packDir</>"lib"</>framework | |||
let targetFile = dir </> "FAKE.FSharp.Compiler.Service.dll" | |||
File.DeleteFile targetFile | |||
File.Delete targetFile |
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.
This is System.IO.File.Delete isn't it?
Should we provide delete
(ie lower case version) to have unified looking code?
I think there is no easy answer.
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.
yes that's it. I saw System.IO.File is used a lot because some functions in Fake.IO.FileSystem modules are just one line call to BCL...
I will replace it in build.fsx
@@ -120,7 +125,7 @@ Target.Create "Clean" (fun _ -> | |||
//-- "src/*/*/obj/*.props" | |||
//-- "src/*/*/obj/*.paket.references.cached" | |||
//-- "src/*/*/obj/*.NuGet.Config" | |||
|> File.DeleteFiles | |||
|> File.deleteAll |
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.
good choice.
@@ -0,0 +1,49 @@ | |||
namespace Fake.IO.FileSystem |
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.
Yes I think we should move them (I can do that if you want), because then it is more similar to System.IO
and one less open Fake.IO.FileSystem
at the top...
|
||
open System.IO | ||
|
||
module Operators = |
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.
If we move to Fake.IO
I'm not sure how we should call this. Fake.IO.Operators
might be too generic. Maybe we leave it in this namespace or call it PathOperators
?
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.
I will change namespace to File.IO. And for Operators, PathOperators seems good ? or FileSystemOperators ? (since we are in Fake.IO.FileSystem package)
Ok I'm releasing this (Will move move everything to |
The idea was to add Obsolete documentation at first. I also splitted modules in their own files.
Then I noted that there is an issue of naming/casing consistency accross the FAKE API. Then, I also propose to use a consistent.
For now, I applied the rework only to DirectoryInfo module (given even without the casing changes, there are already some changes in the API). Wait for your feedback before I complete other modules of Fake.IO.FileSystem.