-
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
FakeVar enhancements #1978
FakeVar enhancements #1978
Conversation
src/app/Fake.Core.Context/Context.fs
Outdated
forceFakeContext() | ||
|> getFakeContext name | ||
|> Option.map (fun o -> o :?> 'a) | ||
|
||
let getFakeVarOrFail<'a> name = | ||
match getFakeVar<'a> name with |
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'd prefer this to be in a new module and try to keep the api surface (and changes) of the context module as minimal as possible. This is the only module where you have to update the runner in order to get the changes. Therefore your suggestion will break on old runners
Adding the generic parameter is (I believe) harmless.
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.
ohhh really :s
i wonder if it's possible to remove all the variable stuff?
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 wonder if it's possible to remove all the variable stuff?
We maybe could move it somewhere else but have to leave an obsolete attribute for now (we can do the breaking change sometime after the release)
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.
Exactly what I've started working on 😂
All internal usage I'll migrate away from obsolete.
This makes it harder for newbies to understand since the core readme on expecto states "All expect-functions have the signature actual -> expected -> string -> unit, leaving out expected when obvious from the function." When flip is needed (for pipelines) it's explicitly mentioned
Have also updated use of Expecto.Flip as this is quite confusing and subtle when used as a file level "open" statement |
Looking at this, we probably should have basic integration-tests to test if we are still compatible with the old runner |
Agreed...not sure how to implement... |
The tests? Basically like the current integration tests, but using the "installed" version if fake and not the built one (for example we could use |
Also remove the obsolete i added on AssemblyInfoFile - if someone wants to directly call, they should be able to...
@matthid done the refactoring and also fixed a few other things which were build warnings to make it easier to see the wood for the trees when building locally |
Improved interface for remove and set variables
|> Option.map (fun o -> try | ||
o :?> 'a | ||
with e -> | ||
failwithf "Variable '%s' - %s" name e.Message |
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.
please use raise <| exn(sprintf "", e)
instead (at the very least)
@@ -21,29 +25,35 @@ let getOrDefault<'a> name defaultValue = | |||
let remove name = | |||
forceFakeContext() | |||
|> removeFakeContext name | |||
|> Option.map (fun o -> o :?> 'a) | |||
|> ignore |
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.
Sometimes you might want to know which value has been removed? Anyway I'm not sure if it is worth the potential breaking change ;) (On the other hand this one isn't too bad - I don't think anyone uses this directly at the moment.
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 was working on this being brand new, so not breaking change.
Nobody is using this function at the moment 😉
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.
Ah sorry, I'm probably a bit over cautious on this thing :)
Problem is this is the "connection" between runtime and script and breaking stuff there is a huge pain to cleanup :P
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 completely agree, I was unaware of the link originally
@@ -213,7 +213,6 @@ module AssemblyInfoFile = | |||
|
|||
/// Creates a C# AssemblyInfo file with the given attributes and configuration. | |||
/// The generated AssemblyInfo file contains an AssemblyVersionInformation class which can be used to retrieve the current version no. from inside of an assembly. | |||
[<System.Obsolete "Please use 'create' instead">] |
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.
You don't like create anymore or what is the rationale?
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 thought I was a big agressive on the obsolete. What if someone wanted to control themselves?
Since we don't plan to delete, only make private i see no harm in leaving without obsolete
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.
Since we don't plan to delete
;)
Generally I really like the direction of this. Good idea to make this a thing and simplify the context module.
I always thought that's how to use it :/. I personally don't really like the default signature, but whatever |
@@ -0,0 +1,59 @@ | |||
/// This module contains helpers for managing build time variables | |||
module Fake.Core.Variables |
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.
Should we add [<RequireQualifiedAccess>]
?
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.
Agreed
Re expecto I agree it seems wrong, but personnally spent an hour confused as the code didn't match the docs 😂 |
Seems like AppVeyor died :/ |
I noticed it vanished... I didn't do it. 😂 |
@@ -0,0 +1,60 @@ | |||
/// This module contains helpers for managing build time variables | |||
[<RequireQualifiedAccess>] | |||
module Fake.Core.Variables |
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 just fixed the compilation error and I'm not sure about the plural form. But Variable.set
doesn't really sound better. Maybe explicitly call it FakeVar
or FakeContext
for example? Any idea?
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 like FakeVar
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.
Though that means there is a function called fakeVar so would be FakeVar.fakeVar
How about ContextVariable ?
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 but FakeVar.fakeVar
;)
maybe FakeVar.create
instead of that and
FakeContext.set
for the raw stuff (or we make that internal)
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.
Oooo FakeVar.create love it!
@matthid made the updates to Fake.Core.FakeVar and really quite like it. |
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 it reads really nice now!
Shame it has build error. |
<ProjectReference Include="..\Fake.Core.Context\Fake.Core.Context.fsproj"> | ||
<FromP2P>true</FromP2P> | ||
</ProjectReference> | ||
<ProjectReference Include="..\Fake.Core.Context\Fake.Core.Context.fsproj" FromP2P="true" /> |
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.
What does P2P mean here? I hope this has no effect on dependencies.
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.
It was already here, i just made the projects nicer.
From what i can tell, it enables the transitive project dependencies to be pulled
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 actually think all of the references should have it...based on this: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-add-reference
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.
P2P = project-to-project
@@ -19,6 +19,7 @@ | |||
<ProjectReference Include="..\Fake.Core.Environment\Fake.Core.Environment.fsproj" /> | |||
<ProjectReference Include="..\Fake.Core.String\Fake.Core.String.fsproj" /> | |||
<ProjectReference Include="..\Fake.Core.Context\Fake.Core.Context.fsproj" /> |
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.
We probably could remove Fake.Core.Context now (but I guess it doesn't hurt)
Thanks a lot for going all the way with this :) Let's see how it works on staging |
Added:
Also added tests to the above