-
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
Merged
Merged
FakeVar enhancements #1978
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b6f0a86
Add ability to get fake var with a type
BlythMeister 5fcfbac
Add function to get fakevar or fail if not present
BlythMeister a6467ab
Add get fakevar or default function
BlythMeister 0e0453e
Added tests on FakeVar logic
BlythMeister d44b388
Update to use the type passing on fakevar
BlythMeister 1298eb0
Build and test fix
BlythMeister cac5c48
Remove Expecto flip opens
BlythMeister 7f33f85
Migrate FakeVar usage into separate module
BlythMeister 73da350
Fix AssemblyInfo warnings
BlythMeister d5e51e8
Fix more warnings
BlythMeister 3c44abb
Fix some more warnings
BlythMeister cdd194c
Add the new file into FakeLib.fsproj
BlythMeister b71163e
Added tests for type mismatch
BlythMeister e1f8edd
Add [<RequireQualifiedAccess>] to variables.fs
BlythMeister 6dba481
Update error message on cast error
BlythMeister 5882326
Fix tests now error has changed
BlythMeister 4a9867b
Improve cast error message
BlythMeister d662d63
Fix compilation
matthid baca2d8
Rename Fake.Core.Variables to Fake.Core.FakeVar
BlythMeister 2b66f5a
add vscode restore task & nest FakeVar project in Fake.sln
BlythMeister 1671636
Test fixes
BlythMeister 9448868
Remove redundant statements
BlythMeister 7faa14c
Correct FakeVar error message
BlythMeister e649774
Test fixes
BlythMeister b9fb1c2
Simplify and add P2P="true"
BlythMeister 99e7402
Fixing INT tests
BlythMeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Auto-Generated by FAKE; do not edit | ||
namespace System | ||
open System.Reflection | ||
|
||
[<assembly: AssemblyTitleAttribute("FAKE - F# Make Core FakeVar")>] | ||
[<assembly: AssemblyProductAttribute("FAKE - F# Make")>] | ||
[<assembly: AssemblyVersionAttribute("5.0.0")>] | ||
[<assembly: AssemblyInformationalVersionAttribute("5.0.0.0")>] | ||
[<assembly: AssemblyFileVersionAttribute("5.0.0")>] | ||
do () | ||
|
||
module internal AssemblyVersionInformation = | ||
let [<Literal>] AssemblyTitle = "FAKE - F# Make Core FakeVar" | ||
let [<Literal>] AssemblyProduct = "FAKE - F# Make" | ||
let [<Literal>] AssemblyVersion = "5.0.0" | ||
let [<Literal>] AssemblyInformationalVersion = "5.0.0.0" | ||
let [<Literal>] AssemblyFileVersion = "5.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net46;netstandard1.6;netstandard2.0</TargetFrameworks> | ||
<AssemblyName>Fake.Core.FakeVar</AssemblyName> | ||
<OutputType>Library</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="AssemblyInfo.fs" /> | ||
<Compile Include="FakeVar.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Fake.Core.Context\Fake.Core.Context.fsproj" /> | ||
</ItemGroup> | ||
<Import Project="..\..\..\.paket\Paket.Restore.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/// This module contains helpers for managing build time variables | ||
[<RequireQualifiedAccess>] | ||
module Fake.Core.FakeVar | ||
|
||
open Fake.Core.Context | ||
|
||
/// Gets a strongly typed FakeVar by name returning an option type | ||
let get<'a> name = | ||
forceFakeContext() | ||
|> getFakeContext name | ||
|> Option.map (fun o -> try | ||
o :?> 'a | ||
with e -> | ||
raise <| exn(sprintf "Cast error on variable '%s'" name, e) | ||
) | ||
|
||
/// Gets a strongly typed FakeVar by name will fail if variable is not found | ||
let getOrFail<'a> name = | ||
match get<'a> name with | ||
| Some v -> v | ||
| _ -> failwithf "Unable to find variable '%s'" name | ||
|
||
/// Gets a strongly typed FakeVar by name will return default value if variable is not found | ||
let getOrDefault<'a> name defaultValue = | ||
match get<'a> name with | ||
| Some v -> v | ||
| _ -> defaultValue | ||
|
||
/// Removes a FakeVar by name | ||
let remove name = | ||
forceFakeContext() | ||
|> removeFakeContext name | ||
|> ignore | ||
|
||
/// Sets value of a FakeVar | ||
let set name (v:'a) = | ||
forceFakeContext() | ||
|> setFakeContext name v (fun _ -> v :> obj) | ||
|> ignore | ||
|
||
/// Define a named FakeVar providing the get, remove and set | ||
/// Will fail if there is no context | ||
let define<'a> name = | ||
if isFakeContext() then | ||
(fun () -> get name : 'a option), | ||
(fun () -> remove name), | ||
(fun (v : 'a) -> set name v) | ||
else | ||
failwithf "Cannot define variable %s without context" name | ||
|
||
/// Define a named FakeVar providing the get, remove and set | ||
/// Will create a local variable if there is no context | ||
let defineAllowNoContext<'a> name = | ||
if isFakeContext() then | ||
(fun () -> get name : 'a option), | ||
(fun () -> remove name), | ||
(fun (v : 'a) -> set name v) | ||
else | ||
let mutable varWithoutContext = None | ||
(fun () -> varWithoutContext), | ||
(fun () -> varWithoutContext <- None), | ||
(fun (v : 'a) -> varWithoutContext <- Some v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
group netcore | ||
|
||
FSharp.Core | ||
NETStandard.Library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)