Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"fantomas": {
"version": "6.2.3",
"commands": [
"fantomas"
]
}
}
}
17 changes: 16 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,19 @@ root = true
insert_final_newline = false
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
indent_size = 2

##### F# files #####
[*.{fs,fsi,fsx}]

# Fantomas settings

max_line_length = 120 # default

# Set all max width to large value and let max_line_length split lines when necessary
# Max width of binding name plus binding definition, not including keywords
fsharp_max_value_binding_width = 120
# Max width of function binding value, not including keywords and binding name
fsharp_max_function_binding_width = 120
# Max width of series of dot-expression
fsharp_max_dot_get_expression_width = 120
6 changes: 6 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
dotnet-version: |
3.1.x
6.0.x

- name: Restore Fantomas
run: dotnet -d tool restore --tool-manifest ${{ github.workspace }}/.config/dotnet-tools.json

- name: Format
run: dotnet fantomas src --check

- name: Restore
run: dotnet restore src/Elmish.WPF.sln
Expand Down
14 changes: 8 additions & 6 deletions src/Elmish.WPF.Benchmarks/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,31 @@ type public BenchmarkDynamicViewModel() =

[<GlobalSetup>]
member public x.GlobalSetup() =
let createBinding i =
Binding.oneWay id $"testBinding_%i{i}"
let createBinding i = Binding.oneWay id $"testBinding_%i{i}"

let bindings =
System.Linq.Enumerable.Range(0, x.BindingCount) |> Seq.map createBinding |> Seq.toList
System.Linq.Enumerable.Range(0, x.BindingCount)
|> Seq.map createBinding
|> Seq.toList

vm <- DynamicViewModel<int, obj>(ViewModelArgs.simple model, bindings)


[<Benchmark>]
member public x.Update() =
model <- 0

while model < x.UpdateCount do
model <- model + 1
IViewModel.updateModel (vm, model)

vm :> obj

[<Params (1, 10, 100)>]
[<Params(1, 10, 100)>]
member val public BindingCount = 0 with get, set

[<Params (1, 100, 10000)>]
[<Params(1, 100, 10000)>]
member val public UpdateCount = 0 with get, set


let _ = BenchmarkRunner.Run<BenchmarkDynamicViewModel>()
let _ = BenchmarkRunner.Run<BenchmarkDynamicViewModel>()
44 changes: 23 additions & 21 deletions src/Elmish.WPF.Tests/AutoOpen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,53 @@ module AutoOpen
type InvokeTester<'a, 'b>(f: 'a -> 'b) =
let mutable count = 0
let mutable values = []

let wrapped a =
count <- count + 1
values <- values @ [a]
values <- values @ [ a ]
f a

member __.Fn = wrapped
member __.Count = count
member __.Values = values
member __.Reset () =

member __.Reset() =
count <- 0
values <- []


type InvokeTester2<'a, 'b, 'c>(f: 'a -> 'b -> 'c) =
let mutable count = 0
let mutable values = []

let wrapped a b =
count <- count + 1
values <- values @ [a, b]
values <- values @ [ a, b ]
f a b

member __.Fn = wrapped
member __.Count = count
member __.Values = values
member __.Reset () =

member __.Reset() =
count <- 0
values <- []


type InvokeTester3<'a, 'b, 'c, 'd>(f: 'a -> 'b -> 'c -> 'd) =
let mutable count = 0
let mutable values = []

let wrapped a b c =
count <- count + 1
values <- values @ [a, b, c]
values <- values @ [ a, b, c ]
f a b c

member __.Fn = wrapped
member __.Count = count
member __.Values = values
member __.Reset () =

member __.Reset() =
count <- 0
values <- []

Expand All @@ -57,18 +66,11 @@ module String =
module List =

let swap i j =
List.permute
(function
| a when a = i -> j
| a when a = j -> i
| a -> a)

let insert i a ma =
(ma |> List.take i)
@ [ a ]
@ (ma |> List.skip i)

let replace i a ma =
(ma |> List.take i)
@ [ a ]
@ (ma |> List.skip (i + 1))
List.permute (function
| a when a = i -> j
| a when a = j -> i
| a -> a)

let insert i a ma = (ma |> List.take i) @ [ a ] @ (ma |> List.skip i)

let replace i a ma = (ma |> List.take i) @ [ a ] @ (ma |> List.skip (i + 1))
Loading