Skip to content

Commit

Permalink
Merge branch 'main' into release/2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Jan 16, 2024
2 parents 259b593 + 7fe2a8d commit 5d9befe
Show file tree
Hide file tree
Showing 30 changed files with 669 additions and 666 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_No unreleased changes_

## [2.5.0-pre3] - 2024-01-16

### Changed
- Consolidation of the new Component API and the existing ViewAdapter by @TimLariviere (https://github.com/fabulous-dev/Fabulous/pull/1056)

## [2.5.0-pre2] - 2023-11-22

### Changed
- Couple of changes to the new Component API

## [2.5.0-pre1] - 2023-11-22

### Added
Expand Down Expand Up @@ -55,8 +65,10 @@ _No unreleased changes_
### Changed
- Fabulous.XamarinForms & Fabulous.MauiControls have been moved been out of the Fabulous repository. Find them in their own repositories: [https://github.com/fabulous-dev/Fabulous.XamarinForms](https://github.com/fabulous-dev/Fabulous.XamarinForms) / [https://github.com/fabulous-dev/Fabulous.MauiControls](https://github.com/fabulous-dev/Fabulous.MauiControls)

[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/2.5.0-pre1...HEAD
[2.5.0-preview.1]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.5.0-pre1
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/2.5.0-pre3...HEAD
[2.5.0-pre3]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.5.0-pre3
[2.5.0-pre2]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.5.0-pre2
[2.5.0-pre1]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.5.0-pre1
[2.4.0]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.4.0
[2.3.2]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.3.2
[2.3.1]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.3.1
Expand Down
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<PropertyGroup>
<OtherFlags>$(OtherFlags) --test:GraphBasedChecking --test:ParallelOptimization --test:ParallelIlxGen</OtherFlags>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>

</Project>
7 changes: 3 additions & 4 deletions src/Fabulous.Benchmarks/Benchmarks.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Fabulous.Tests.Benchmarks

open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Jobs

open BenchmarkDotNet.Running
open Fabulous.Tests.APISketchTests.TestUI_Widgets
Expand Down Expand Up @@ -95,7 +94,7 @@ module DiffingAttributes =

let instance = Run.Instance program

let _tree = (instance.Start())
let _tree = instance.Start()

for i in 1..100 do
instance.ProcessMessage(IncBy i)
Expand Down Expand Up @@ -171,15 +170,15 @@ module DiffingSmallScalars =

let instance = Run.Instance program

let _tree = (instance.Start())
let _tree = instance.Start()

for i in 1..100 do
instance.ProcessMessage(IncBy 1UL)



[<EntryPoint>]
let main argv =
let main _argv =
// BenchmarkRunner.Run<NestedTreeCreation.Benchmarks>()
// |> ignore
//
Expand Down
29 changes: 13 additions & 16 deletions src/Fabulous.Tests/APISketchTests/APISketchTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ open Fabulous.StackAllocatedCollections
open Fabulous.Tests.APISketchTests.Platform
open NUnit.Framework

open Platform
open TestUI_Widgets
open Fabulous

Expand Down Expand Up @@ -75,7 +74,7 @@ module ButtonTests =

let update msg model =
match msg with
| Increment -> { model with count = model.count + 1 }
| Increment -> { count = model.count + 1 }


let view model =
Expand Down Expand Up @@ -137,30 +136,30 @@ module SimpleStackTests =
instance.ProcessMessage(AddNew(1, "yo"))
Assert.AreEqual(1, stack.Children.Count)

let label = stack.Children.[0] :?> TestLabel :> IText
let label = stack.Children[0] :?> TestLabel :> IText

Assert.AreEqual(label.Text, "yo")

// add second in front
instance.ProcessMessage(AddNew(2, "yo2"))
Assert.AreEqual(2, stack.Children.Count)

let label = stack.Children.[0] :?> TestLabel :> IText
let label = stack.Children[0] :?> TestLabel :> IText

Assert.AreEqual(label.Text, "yo2")

// modify the initial one
instance.ProcessMessage(ChangeText(1, "just 1"))

let label = stack.Children.[1] :?> TestLabel :> IText
let label = stack.Children[1] :?> TestLabel :> IText

Assert.AreEqual(label.Text, "just 1")

// delete the one in front
instance.ProcessMessage(Delete 2)
Assert.AreEqual(stack.Children.Count, 1)

let label = stack.Children.[0] :?> TestLabel :> IText
let label = stack.Children[0] :?> TestLabel :> IText

Assert.AreEqual(label.Text, "just 1")

Expand Down Expand Up @@ -549,9 +548,7 @@ module SmallScalars =

let update msg model =
match msg with
| Inc value ->
{ model with
value = model.value + value }
| Inc value -> { value = model.value + value }

let view model =
InlineNumericBag(model.value, model.value + 1UL, float(model.value + 2UL))
Expand Down Expand Up @@ -690,7 +687,7 @@ module Issue104 =
module Issue1044 =
[<Test>]
let ``Multiple Widgets + for loops in builder causes crash`` () =
let view model =
let view _model =
Stack() {
Label($"Foo") // It also crashes only with the multiple for loops
Label($"bar") // It also crashes only with the multiple for loops
Expand All @@ -717,7 +714,7 @@ module Issue1044 =

[<Test>]
let ``Multiple for loops in builder causes crash`` () =
let view model =
let view _model =
Stack() {
for i = 0 to 10 do
Label($"T{i}")
Expand Down Expand Up @@ -815,7 +812,7 @@ module ViewHelpers =

let childView = Button("Child button", ChildClick).automationId("childButton")

let parentView model =
let parentView _model =
Stack() {
Button("Parent button", ParentClick).automationId("parentButton")

Expand Down Expand Up @@ -846,7 +843,7 @@ module ViewHelpers =
let ``Adding property modifiers to widget converted with View.map is valid`` () =
let childView = Button("Child button", ChildClick).automationId("childButton")

let parentView model =
let parentView _model =
Stack() { (View.map ChildMessage childView).textColor("blue") }

let init () = true
Expand All @@ -867,7 +864,7 @@ module ViewHelpers =

let childView = Button("Child button", ChildClick).automationId("childButton")

let parentView model =
let parentView _model =
Stack() { (View.map ChildMessage childView).tap(ParentTap) }

let init () = true
Expand Down Expand Up @@ -899,7 +896,7 @@ module ViewHelpers =
(View.map ChildMessage childView).tap(ParentTap)
}

let grandParentView model =
let grandParentView _model =
Stack() {
Button("Grand Parent button", GrandParentClick)
.automationId("grandParentButton")
Expand Down Expand Up @@ -951,7 +948,7 @@ module ViewHelpers =

let parentView = (View.map ChildMessage childView).tap(ParentTap)

let grandParentView model =
let grandParentView _model =
(View.map ParentMessage parentView).tap2(GrandParentTap)

let init () = true
Expand Down
12 changes: 12 additions & 0 deletions src/Fabulous.Tests/APISketchTests/TestUI.Component.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Fabulous.Tests.APISketchTests

module TestUI_Component =

open Fabulous
open Platform

module Component =
let ComponentProperty = "ComponentProperty"

let getComponent (target: obj) =
(target :?> TestViewElement).PropertyBag.Item ComponentProperty
4 changes: 2 additions & 2 deletions src/Fabulous.Tests/APISketchTests/TestUI.Platform.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ module Platform =
interface IText with
member x.Text
with get () = text
and set (value) =
and set value =
if x.record then
x.changeList <- List.append x.changeList [ TextSet value ]

text <- value

member x.TextColor
with get () = textColor
and set (value) =
and set value =
if x.record then
x.changeList <- List.append x.changeList [ ColorSet value ]

Expand Down
8 changes: 5 additions & 3 deletions src/Fabulous.Tests/APISketchTests/TestUI.Widgets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module TestUI_Widgets =
open Platform
open TestUI_Attributes
open TestUI_ViewNode
open TestUI_Component


//----WidgetsBuilderCE---
Expand All @@ -29,7 +30,7 @@ module TestUI_Widgets =
TargetType = typeof<'T>
CreateView =
fun (widget, context, parentNode) ->
let name = typeof<'T>.Name
// let name = typeof<'T>.Name
// printfn $"Creating view for {name}"

let view = new 'T()
Expand Down Expand Up @@ -211,7 +212,8 @@ module TestUI_Widgets =
Logger =
{ Log = fun _ -> ()
MinLogLevel = LogLevel.Fatal }
Dispatch = fun msg -> unbox<'msg> msg |> x.ProcessMessage }
Dispatch = fun msg -> unbox<'msg> msg |> x.ProcessMessage
GetComponent = Component.getComponent }

member x.ProcessMessage(msg: 'msg) =
match state with
Expand All @@ -237,7 +239,7 @@ module TestUI_Widgets =
()

member x.Start(arg: 'arg) =
let model = (program.Init(arg))
let model = program.Init(arg)
let widget = program.View(model).Compile()
let widgetDef = WidgetDefinitionStore.get widget.Key

Expand Down
1 change: 0 additions & 1 deletion src/Fabulous.Tests/ArrayTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ namespace Fabulous.Tests
open System
open Fabulous.StackAllocatedCollections
open NUnit.Framework
open Fabulous

[<TestFixture>]
type ``Array tests``() =
Expand Down
1 change: 1 addition & 0 deletions src/Fabulous.Tests/Fabulous.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<ItemGroup>
<Compile Include="APISketchTests\TestUI.Platform.fs" />
<Compile Include="APISketchTests\TestUI.ViewNode.fs" />
<Compile Include="APISketchTests\TestUI.Component.fs" />
<Compile Include="APISketchTests\TestUI.ViewUpdaters.fs" />
<Compile Include="APISketchTests\TestUI.Attributes.fs" />
<Compile Include="APISketchTests\TestUI.Widgets.fs" />
Expand Down
1 change: 0 additions & 1 deletion src/Fabulous.Tests/ViewTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ namespace Fabulous.Tests
open Fabulous
open Fabulous.StackAllocatedCollections.StackList
open NUnit.Framework
open FsCheck.NUnit

type ITestControl =
interface
Expand Down
Loading

0 comments on commit 5d9befe

Please sign in to comment.