Skip to content

Commit

Permalink
Merge branch 'main' into release/3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Jan 16, 2025
2 parents d793827 + 9861595 commit ec04597
Show file tree
Hide file tree
Showing 24 changed files with 125 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fantomas": {
"version": "6.3.16",
"version": "7.0.0",
"commands": [
"fantomas"
],
Expand Down
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[*.fs]
max_line_length=160
fsharp_space_before_lowercase_invocation = false
fsharp_space_before_lowercase_invocation = false
fsharp_max_dot_get_expression_width = 60
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 9.x
- name: Restore
run: dotnet restore ${SLN_FILE}
- name: Build
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Pack
run: dotnet pack ${SLN_FILE} -p:Version=${NIGHTLY_VERSION} -c ${CONFIG} --no-build --property PackageOutputPath=${PWD}/nupkgs
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Packages
path: nupkgs/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 9.x
- name: Check code formatting
run: |
dotnet tool restore
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 9.x
- name: Restore
run: dotnet restore ${SLN_FILE}
- name: Build
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Pack
run: dotnet pack ${SLN_FILE} -p:Version=${RELEASE_VERSION} -p:PackageReleaseNotes="${{ steps.changelog_reader.outputs.changes }}" -c ${CONFIG} --no-build --property PackageOutputPath=${PWD}/nupkgs
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Packages
path: nupkgs/
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_No unreleased changes_

## [3.0.0-pre18] - 2025-01-16

### Changed
- Improve memory usage by @kerams (https://github.com/fabulous-dev/Fabulous/pull/1095)

## [3.0.0-pre17] - 2024-12-15

### Changed
Expand Down Expand Up @@ -206,7 +211,8 @@ _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/3.0.0-pre17...HEAD
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre18...HEAD
[3.0.0-pre18]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre18
[3.0.0-pre17]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre17
[3.0.0-pre16]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre16
[3.0.0-pre15]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre15
Expand Down
9 changes: 5 additions & 4 deletions Fabulous.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Files", "_Solutio
README.md = README.md
CHANGELOG.md = CHANGELOG.md
LICENSE.md = LICENSE.md
.gitignore = .gitignore
pull_request.yml = .github/workflows/pull_request.yml
build.yml = .github/workflows/build.yml
release.yml = .github/workflows/release.yml
.gitignore = .gitignore
pull_request.yml = .github/workflows/pull_request.yml
build.yml = .github/workflows/build.yml
release.yml = .github/workflows/release.yml
.editorconfig = .editorconfig
Directory.Packages.props = Directory.Packages.props
Directory.Build.props = Directory.Build.props
EndProjectSection
Expand Down
5 changes: 0 additions & 5 deletions global.json

This file was deleted.

8 changes: 2 additions & 6 deletions src/Fabulous.Benchmarks/Benchmarks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,9 @@ module DiffingAttributes =

let rec viewInner depth counter =
Stack() {
Label($"label1:{counter} {depth}")
.textColor("red")
.automationId($"label1:{depth}")
Label($"label1:{counter} {depth}").textColor("red").automationId($"label1:{depth}")

Label($"label2:{counter} {depth}")
.textColor("green")
.automationId($"label2:{depth}")
Label($"label2:{counter} {depth}").textColor("green").automationId($"label2:{depth}")

Button($"btn: {depth}", IncBy 2)

Expand Down
2 changes: 1 addition & 1 deletion src/Fabulous.Benchmarks/Fabulous.Benchmarks.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
10 changes: 3 additions & 7 deletions src/Fabulous.Tests/APISketchTests/APISketchTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,7 @@ module SmallScalars =
| Inc value -> { value = model.value + value }

let view model =
InlineNumericBag(model.value, model.value + 1UL, float(model.value + 2UL))
.automationId("numbers")
InlineNumericBag(model.value, model.value + 1UL, float(model.value + 2UL)).automationId("numbers")

let init () = { value = 0UL }

Expand Down Expand Up @@ -898,12 +897,9 @@ module ViewHelpers =

let grandParentView _model =
Stack() {
Button("Grand Parent button", GrandParentClick)
.automationId("grandParentButton")
Button("Grand Parent button", GrandParentClick).automationId("grandParentButton")

(View.map ParentMessage parentView)
.automationId("parentStack")
.tapContainer(GrandParentTap)
(View.map ParentMessage parentView).automationId("parentStack").tapContainer(GrandParentTap)
}


Expand Down
2 changes: 1 addition & 1 deletion src/Fabulous.Tests/Fabulous.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Library</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Fabulous/Array.fs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module Array =
let inline sortInPlace<'T, 'V when 'V: comparison> ([<InlineIfLambda>] getKey: 'T -> 'V) (attrs: 'T[]) : 'T[] =
let N = attrs.GetLength(0)

for i in [ 1 .. N - 1 ] do
for i in 1 .. N - 1 do
for j = i downto 1 do
let key = getKey attrs[j]
let prevKey = getKey attrs[j - 1]
Expand Down
9 changes: 3 additions & 6 deletions src/Fabulous/AttributeDefinitions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,6 @@ module AttributeHelpers =
open ScalarAttributeDefinitions

let tryFindSimpleScalarAttribute (definition: SimpleScalarAttributeDefinition<'T>) (widget: Widget) =
match widget.ScalarAttributes with
| ValueNone -> ValueNone
| ValueSome attrs ->
match attrs |> Array.tryFind(fun attr -> attr.Key = definition.Key) with
| None -> ValueNone
| Some attr -> ValueSome(unbox<'T> attr.Value)
match widget.ScalarAttributes |> Array.tryFind(fun attr -> attr.Key = definition.Key) with
| None -> ValueNone
| Some attr -> ValueSome(unbox<'T> attr.Value)
70 changes: 41 additions & 29 deletions src/Fabulous/Builders.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open Fabulous.StackAllocatedCollections
open Fabulous.StackAllocatedCollections.StackList
open Microsoft.FSharp.Core

type AttributesBundle = (struct (StackList<ScalarAttribute> * WidgetAttribute[] voption * WidgetCollectionAttribute[] voption * EnvironmentAttribute[] voption))
type AttributesBundle = (struct (StackList<ScalarAttribute> * WidgetAttribute[] * WidgetCollectionAttribute[] * EnvironmentAttribute[]))

[<Struct; NoComparison; NoEquality>]
type WidgetBuilder<'msg, 'marker when 'msg: equality> =
Expand All @@ -17,25 +17,25 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =

new(key: WidgetKey) =
{ Key = key
Attributes = AttributesBundle(StackList.empty(), ValueNone, ValueNone, ValueNone) }
Attributes = AttributesBundle(StackList.empty(), [||], [||], [||]) }

new(key: WidgetKey, attributes: AttributesBundle) = { Key = key; Attributes = attributes }

new(key: WidgetKey, scalar: ScalarAttribute) =
{ Key = key
Attributes = AttributesBundle(StackList.one scalar, ValueNone, ValueNone, ValueNone) }
Attributes = AttributesBundle(StackList.one scalar, [||], [||], [||]) }

new(key: WidgetKey, scalarA: ScalarAttribute, scalarB: ScalarAttribute) =
{ Key = key
Attributes = AttributesBundle(StackList.two(scalarA, scalarB), ValueNone, ValueNone, ValueNone) }
Attributes = AttributesBundle(StackList.two(scalarA, scalarB), [||], [||], [||]) }

new(key: WidgetKey, scalar1: ScalarAttribute, scalar2: ScalarAttribute, scalar3: ScalarAttribute) =
{ Key = key
Attributes = AttributesBundle(StackList.three(scalar1, scalar2, scalar3), ValueNone, ValueNone, ValueNone) }
Attributes = AttributesBundle(StackList.three(scalar1, scalar2, scalar3), [||], [||], [||]) }

new(key: WidgetKey, widget: WidgetAttribute) =
{ Key = key
Attributes = AttributesBundle(StackList.empty(), ValueSome [| widget |], ValueNone, ValueNone) }
Attributes = AttributesBundle(StackList.empty(), [| widget |], [||], [||]) }

[<EditorBrowsable(EditorBrowsableState.Never)>]
member x.Compile() : Widget =
Expand All @@ -48,14 +48,26 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =
#endif
ScalarAttributes =
match StackList.length &scalarAttributes with
| 0us -> ValueNone
| _ -> ValueSome(Array.sortInPlace _.Key (StackList.toArray &scalarAttributes))

WidgetAttributes = ValueOption.map (Array.sortInPlace(_.Key)) widgetAttributes

WidgetCollectionAttributes = widgetCollectionAttributes |> ValueOption.map(Array.sortInPlace(_.Key))

EnvironmentAttributes = environmentAttributes |> ValueOption.map(Array.sortInPlace(_.Key)) }
| 0us -> [||]
| _ -> Array.sortInPlace _.Key (StackList.toArray &scalarAttributes)

WidgetAttributes =
if widgetAttributes.Length > 1 then
Array.sortInPlace _.Key widgetAttributes
else
widgetAttributes

WidgetCollectionAttributes =
if widgetCollectionAttributes.Length > 1 then
Array.sortInPlace _.Key widgetCollectionAttributes
else
widgetCollectionAttributes

EnvironmentAttributes =
if environmentAttributes.Length > 1 then
Array.sortInPlace _.Key environmentAttributes
else
environmentAttributes }

[<EditorBrowsable(EditorBrowsableState.Never)>]
member inline x.AddScalar(attr: ScalarAttribute) =
Expand Down Expand Up @@ -103,14 +115,14 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =

let res =
match attribs with
| ValueNone -> [| attr |]
| ValueSome attribs ->
| [||] -> [| attr |]
| attribs ->
let attribs2 = Array.zeroCreate(attribs.Length + 1)
Array.blit attribs 0 attribs2 0 attribs.Length
attribs2[attribs.Length] <- attr
attribs2

WidgetBuilder<'msg, 'marker>(x.Key, struct (scalarAttributes, ValueSome res, widgetCollectionAttributes, environmentAttributes))
WidgetBuilder<'msg, 'marker>(x.Key, struct (scalarAttributes, res, widgetCollectionAttributes, environmentAttributes))

[<EditorBrowsable(EditorBrowsableState.Never)>]
member x.AddWidgetCollection(attr: WidgetCollectionAttribute) =
Expand All @@ -121,14 +133,14 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =

let res =
match attribs with
| ValueNone -> [| attr |]
| ValueSome attribs ->
| [||] -> [| attr |]
| attribs ->
let attribs2 = Array.zeroCreate(attribs.Length + 1)
Array.blit attribs 0 attribs2 0 attribs.Length
attribs2[attribs.Length] <- attr
attribs2

WidgetBuilder<'msg, 'marker>(x.Key, struct (scalarAttributes, widgetAttributes, ValueSome res, environmentAttributes))
WidgetBuilder<'msg, 'marker>(x.Key, struct (scalarAttributes, widgetAttributes, res, environmentAttributes))

[<EditorBrowsable(EditorBrowsableState.Never)>]
member inline x.AddEnvironment(key: EnvironmentAttributeKey, value: obj) =
Expand All @@ -146,14 +158,14 @@ type WidgetBuilder<'msg, 'marker when 'msg: equality> =

let res =
match attribs with
| ValueNone -> [| attr |]
| ValueSome attribs ->
| [||] -> [| attr |]
| attribs ->
let attribs2 = Array.zeroCreate(attribs.Length + 1)
Array.blit attribs 0 attribs2 0 attribs.Length
attribs2[attribs.Length] <- attr
attribs2

WidgetBuilder<'msg, 'marker>(x.Key, struct (scalarAttributes, widgetAttributes, widgetCollectionAttributes, ValueSome res))
WidgetBuilder<'msg, 'marker>(x.Key, struct (scalarAttributes, widgetAttributes, widgetCollectionAttributes, res))
end


Expand All @@ -170,12 +182,12 @@ type CollectionBuilder<'msg, 'marker, 'itemMarker when 'msg: equality> =

new(widgetKey: WidgetKey, scalars: StackList<ScalarAttribute>, attr: WidgetCollectionAttributeDefinition) =
{ WidgetKey = widgetKey
Attributes = AttributesBundle(scalars, ValueNone, ValueNone, ValueNone)
Attributes = AttributesBundle(scalars, [||], [||], [||])
Attr = attr }

new(widgetKey: WidgetKey, attr: WidgetCollectionAttributeDefinition) =
{ WidgetKey = widgetKey
Attributes = AttributesBundle(StackList.empty(), ValueNone, ValueNone, ValueNone)
Attributes = AttributesBundle(StackList.empty(), [||], [||], [||])
Attr = attr }

new(widgetKey: WidgetKey, attr: WidgetCollectionAttributeDefinition, attributes: AttributesBundle) =
Expand All @@ -185,12 +197,12 @@ type CollectionBuilder<'msg, 'marker, 'itemMarker when 'msg: equality> =

new(widgetKey: WidgetKey, attr: WidgetCollectionAttributeDefinition, scalar: ScalarAttribute) =
{ WidgetKey = widgetKey
Attributes = AttributesBundle(StackList.one scalar, ValueNone, ValueNone, ValueNone)
Attributes = AttributesBundle(StackList.one scalar, [||], [||], [||])
Attr = attr }

new(widgetKey: WidgetKey, attr: WidgetCollectionAttributeDefinition, scalarA: ScalarAttribute, scalarB: ScalarAttribute) =
{ WidgetKey = widgetKey
Attributes = AttributesBundle(StackList.two(scalarA, scalarB), ValueNone, ValueNone, ValueNone)
Attributes = AttributesBundle(StackList.two(scalarA, scalarB), [||], [||], [||])
Attr = attr }

member inline x.Run(c: Content<'msg>) =
Expand All @@ -205,8 +217,8 @@ type CollectionBuilder<'msg, 'marker, 'itemMarker when 'msg: equality> =

let widgetCollections =
match widgetCollections with
| ValueNone -> ValueSome([| widgetCollAttr |])
| ValueSome widgetCollectionAttributes -> ValueSome(Array.appendOne widgetCollAttr widgetCollectionAttributes)
| [||] -> [| widgetCollAttr |]
| widgetCollectionAttributes -> Array.appendOne widgetCollAttr widgetCollectionAttributes

WidgetBuilder<'msg, 'marker>(x.WidgetKey, AttributesBundle(scalars, widgets, widgetCollections, environments))

Expand Down
3 changes: 1 addition & 2 deletions src/Fabulous/Components/Binding.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ type BindingExtensions =

let bindingValue = BindingValue<'T>(stateValue)

(continuation bindingValue)
.Invoke(envContext, treeContext, context, bindings + 1<binding>))
(continuation bindingValue).Invoke(envContext, treeContext, context, bindings + 1<binding>))
Loading

0 comments on commit ec04597

Please sign in to comment.