Skip to content
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

Fix fromRawWindowsCommandLine (now fromRawCommandLine), fixes #2197 #2206

Merged
merged 14 commits into from
Dec 3, 2018

Conversation

matthid
Copy link
Member

@matthid matthid commented Nov 18, 2018

Description

/cc @vbfox

@@ -178,7 +178,7 @@ let testCases =
let assemblies = [ Guid.NewGuid().ToString() ]
let proc = FxCop.composeCommandLine p assemblies
let expected =
sprintf """%s /c "/f:\"%s\"" "/o:\"%s\"" /s /v""" dummy
sprintf """%s /c /f:\"%s\" /o:\"%s\" /s /v""" dummy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there was a slight behavior change here. @SteveGilham I hope this still works. Actually I'm a bit puzzled that this even works with the argument containing the quoted quotes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The escaping of quotes is required when they fall within a quoted parameter, and only then.
This style works

"/o:\"_Reports/FxCopReport.xml\""

and this style works

/o:"_Reports/FxCopReport.xml"

but this one (the one as per the diff above) doesn't

/o:\"_Reports/FxCopReport.xml\"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this command line style is similar to the problem this PR tries to solve (#2197)

Does fxcop accept "/o:_Reports/FxCopReport.xml" (ie without the inner quotes)?
Which would simplify this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes (with the proviso that the file name contains no spaces).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So "/o:_Reports/with space/FxCopReport.xml" doesn't work even it is correctly escaped and given to fxcop as single argument?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"/o:_Reports/with space/FxCopReport.xml" works it's /o:_Reports/with space/FxCopReport.xml that, of course, doesn't.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks for confirming, than we should do it like ed0bb86.

@matthid
Copy link
Member Author

matthid commented Nov 18, 2018

I think this is actually ready, but I'd like to wait until @vbfox reviews and gives feedback about concat, because once released it will break people if BlackFox.CommandLine is updated...

@vbfox
Copy link
Contributor

vbfox commented Nov 18, 2018

Concat API is made for being piped and it's ordering is weird if not used like that... It's documented but I admit it's weird.

I'm tempted to align the lib to the standard modules naming, renaming appendXXX to addXXX, having append concatenate 2 CmdLine and concat take a sequence of CmdLine might as well do that now and release a 1.0 then not change the API anymore.

@vbfox
Copy link
Contributor

vbfox commented Nov 18, 2018

So in the end I won't change Append but i'll change concat signature to go with the CmdLine seq one so it's clearer what's going on

vbfox added a commit to vbfox/FoxSharp that referenced this pull request Nov 18, 2018
(Breaking change, see fsprojects/FAKE#2206 for the confusion created by the previous API)
@vbfox
Copy link
Contributor

vbfox commented Nov 18, 2018

Ok 1.0.0 published, let's see !

{ Args = a.Args |> CmdLine.appendSeq s }
//Arguments.OfArgs(Seq.append a.Args s)

/// Forward API from https://github.com/vbfox/FoxSharp/tree/master/src/BlackFox.CommandLine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand why but it mean that the API in FAKE might diverge at some point.

Also you're losing both the "." style API and doc comments

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the APIs diverge something most likely breaks?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I was not speaking about breakage, mostly playing catch-up with whatever is added on one side needing an equivalent PR on the other

let fromArray s = { Args = CmdLine.fromArray s }
let toList (a:Arguments) = CmdLine.toList a.Args
let toArray (a:Arguments) = CmdLine.toArray a.Args
let toStringForMsvcr e (a:Arguments) = CmdLine.toStringForMsvcr e a.Args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a little too low level.

If you wrap, maybe add a fromCmdLine or something and users can go to my lib directly if they need advanced features

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I just don't want people to convert back and forth ... Maybe with a different entry point? (see new changes)

@matthid
Copy link
Member Author

matthid commented Nov 19, 2018

Ok 1.0.0 published, let's see !

Well, I hope you are a bit more careful with releasing breaking changes in the future ;)

/// |> CreateProcess.fromCmdLine "dotnet.exe"
/// |> Proc.run
/// |> ignore
let fromCmdLine command args =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vbfox Maybe that is Okish if we says fake only has build-in APIs for working with argument lists and properly escaping them and other weird stuff (or the builder-API) is external

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that but i'm not 100% objective on the subjects :)

It also suggest that other builder libraries could happen.

If needed I can produce another package with only the escaping part completely separate from the builder one. FAKE core would then depend on it and each FAKE package could use whatever builder it wants.

Not sure it's worth the complexity but it's doable

@matthid
Copy link
Member Author

matthid commented Nov 19, 2018

Honestly, somehow I'm a bit nervous with this change. Probably because the dependency is "out of control" and a potential source of breakage at the very core ;)

@kblohm
Copy link
Contributor

kblohm commented Nov 19, 2018

I feel like something that is so core to fake should preferably be included out ouf the box. Every module should probably use this api in the long run, so having a bit more control might be nice.

@vbfox
Copy link
Contributor

vbfox commented Nov 19, 2018

Well, I hope you are a bit more careful with releasing breaking changes in the future ;)

I'll follow SemVer as much as I can so not before 2.0 ;) whenever it's soon or not will depend on problems found XD

Anything less than 1.0 is free for all (That's also why I bumped VsWhere, no way to change it now it's too used)

@vbfox
Copy link
Contributor

vbfox commented Nov 19, 2018

Honestly, somehow I'm a bit nervous with this change. Probably because the dependency is "out of control" and a potential source of breakage at the very core ;)

I can't really help much on that part, taking dependencies is always a risk. And it's also a bit scary for me too.

I added you as a collaborator on the repo (There is also VsWhere that FAKE references) so if you ends up using it we can work together keeping the lib compatible.

@matthid
Copy link
Member Author

matthid commented Nov 19, 2018

@vbfox
Or maybe asked differently: Is there any particular reason you think it should be separate?
Usually when building command line you also want to start the process afterwards, which is exactly what Fake.Core.Process does.

Also related: We could include the thing via paket-files, but that is not something I'd like to do for various reasons (just something I wanted to mention here)

@vbfox
Copy link
Contributor

vbfox commented Nov 19, 2018

Or maybe asked differently: Is there any particular reason you think it should be separate?

Well I use it in FAKE libraries but also in code not linked to FAKE at all and Fake.Core.Process is too much linked to FAKE to be usable outside of it. So I personally and professionally need a separate library & will continue to maintain it.

Now why FAKE shouldn't copy paste the code, then include it I don't have any good reason except maintenance (Always the consequence of NIH syndrome).

Usually when building command line you also want to start the process afterwards

Once you have a command line string, the framework contains a perfectly suitable class to start a process ;)

@vbfox
Copy link
Contributor

vbfox commented Nov 19, 2018

@matthid we can discuss on gitter/slack whatever if you want

@matthid
Copy link
Member Author

matthid commented Nov 19, 2018

Well I use it in FAKE libraries but also in code not linked to FAKE at all and Fake.Core.Process is too much linked to FAKE to be usable outside of it.

It's a bit of an outside discussion, but it was one of the design goals to be able to use the packages standalone which we didn't achieve apparently. It would be nice if you could elaborate on that (either here or a separate issue). However that is only partially related to this.

we can discuss on gitter/slack whatever if you want

Sure, feel free to ping me :). However, there shouldn't be the impression that I own fake and need to be convinced. In fact it feels like there might be a deeper issue (maybe with how I maintain the repository?!) which we hopefully uncover with the discussion above.

Personally, I'm probably fine with merging as is, but I can see users asking why they need to use some other component to build command lines or open BlackFox... it's also something that is not "consistent". I learned the hard way that some people really really really like consistency ;)

Also the aspect from @kblohm

@matthid
Copy link
Member Author

matthid commented Dec 3, 2018

OK I think I have figured out how I want to do this. Basically the problem of #2197 was that there is no "raw" API. With the most recent commit I changed fromRawCommandLine (previously fromRawWindowsCommandLine) to actually behave properly and use the exact given string (if no transformations are made). There are probably still edge cases when you actually do transformations, but at least you can workaround now.
Also I removed BlackFox library from the public API surface as I feel like that is actually a cross cutting concern and not really required for this "bugfix".

If there is no reason against this change this is probably how I want to do it. What do you think @vbfox and @kblohm ? I also added documentation on how you can use BlackFox.CommandLine with this "fixed" API.

@vbfox
Copy link
Contributor

vbfox commented Dec 3, 2018

👍, It does a double parsing when an external lib is used but it can be removed if needed and that's not much of an issue.

I'm a fan of small libs & compositions 😉

@matthid matthid changed the title switch to BlackFox.CommandLine, first step in fixing #2197 Fix fromRawWindowsCommandLine (now fromRawCommandLine), fixes #2197 Dec 3, 2018
@matthid matthid merged commit 6bbc98b into release/next Dec 3, 2018
@kblohm
Copy link
Contributor

kblohm commented Dec 3, 2018

I feel like support to build commandline-arguments should be included. Starting external processes is one of the main use-cases of FAKE, so it should be as easy as possible.

I learned the hard way that some people really really really like consistency ;)

Consistency does make it easier to get started. I looked into some of the existing modules before i started on one and all of them did the command-line stuff differently. At least for first time contributors, a dedicated way of doing all the command-line-building would make it easier.

@matthid matthid deleted the fix_2197 branch March 17, 2019 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants