diff --git a/.github/workflows/publish_ci.yml b/.github/workflows/publish_ci.yml new file mode 100644 index 00000000..bd92b026 --- /dev/null +++ b/.github/workflows/publish_ci.yml @@ -0,0 +1,65 @@ +name: Publish to MyGet + +on: + push: + branches: + - uno + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + +jobs: + build: + + runs-on: windows-2022 + + steps: + + - name: Check-out + uses: actions/checkout@v4 + + - name: Set Build Version + run: | + cd src/Elmish.Uno + $version = "$env:GITHUB_REF_NAME".Substring("releases/".Length) + $File = ( + Select-Xml -XPath "/Project/PropertyGroup[@Label='NuGet']/Version" -Path Elmish.Uno.fsproj + )[0].Node + $File.InnerText = $version + $File.OwnerDocument.Save((Join-Path $PWD.ProviderPath Elmish.Uno.fsproj)) + echo "VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Add the GitHub and MyGet sources + run: | + dotnet nuget add source --username USERNAME --password ${{secrets.GITHUB_TOKEN}} --store-password-in-clear-text --name "github.com" "https://nuget.pkg.github.com/fsprojects/index.json" + dotnet nuget add source --username USERNAME --password ${{secrets.MYGET_TOKEN}} --store-password-in-clear-text --name "myget.org" "https://www.myget.org/F/elmish_uno/api/v3/index.json" + + - name: Install local tools + run: dotnet tool restore + + - name: Restore NuGet packages + run: dotnet restore Elmish.Uno.sln + + - name: Build + run: dotnet build --no-restore Elmish.Uno.sln --configuration Release -maxcpucount + + - name: Test + run: dotnet test --no-build --configuration Release src/Elmish.Uno.Tests/Elmish.Uno.Tests.fsproj + + - name: Pack + run: | + cd src/Elmish.Uno + dotnet pack --no-build --configuration Release /p:ContinuousIntegrationBuild=true -o ../../nuget + + - name: Publish to MyGet + run: | + dotnet nuget push nuget/Elmish.Uno.${{env.VERSION}}.{nupkg,snupkg} -s "github.com" -k ${{secrets.GITHUB_TOKEN}} --skip-duplicate + dotnet nuget push nuget/Elmish.Uno.${{env.VERSION}}.{nupkg,snupkg} -s "myget.org" -k ${{secrets.MYGET_SECRET}} --skip-duplicate + diff --git a/.github/workflows/publish_myget.yml b/.github/workflows/publish_myget.yml deleted file mode 100644 index e8a0977a..00000000 --- a/.github/workflows/publish_myget.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Publish to MyGet - -on: - push: - branches: - - develop - - NET_6 - -jobs: - build: - - runs-on: windows-2022 - - steps: - - uses: actions/checkout@v2 - - - name: Install .NET SDK 6.0.x - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - - name: Install MSBuild - uses: microsoft/setup-msbuild@v1.1 - with: - #vs-version: '[17.0,)' - vs-prerelease: true - msbuild-architecture: x64 - - - name: Install NuGet 6.x - uses: nuget/setup-nuget@v1 - with: - nuget-version: '6.x' - - - name: Restore NuGet packages - run: | - nuget restore 'src\\Elmish.Uno.sln' -ConfigFile 'NuGet.Config' - - - name: Build with MSBuild - run: | - msbuild 'src\\Elmish.Uno.sln' /t:Rebuild /p:Configuration=Release /p:Platform='Any CPU' -maxcpucount - - - name: Pack Elmish.Uno with NuGet - run: | - $nuspec = get-content 'Elmish.Uno.nuspec' | %{ $_ -replace '\$versionSuffix\$',"-ci-${Env:GITHUB_RUN_ID}"} - set-content 'Elmish.Uno.nuspec' -value $nuspec - nuget pack 'Elmish.Uno.nuspec' -Properties Configuration=Release - - - name: Pack Templates with NuGet - run: | - $nuspec = get-content 'src\\Templates\\Templates.nuspec' | %{ $_ -replace '\$versionSuffix\$',"-ci-${Env:GITHUB_RUN_ID}"} - set-content 'src\\Templates\\Templates.nuspec' -value $nuspec - nuget pack 'src\\Templates\\Templates.nuspec' -Properties Configuration=Release -NoDefaultExcludes - - - name: Publish to MyGet - run: | - $source='https://www.myget.org/F/elmish_uno/api/v3/index.json' - $key='${{secrets.MyGet_Key}}' - dotnet nuget push -s $source -k $key *.nupkg - diff --git a/.github/workflows/publish_nuget.yml b/.github/workflows/publish_nuget.yml deleted file mode 100644 index daff8c56..00000000 --- a/.github/workflows/publish_nuget.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Publish to NuGet - -on: - push: - branches: - - uno - -jobs: - build: - - runs-on: windows-2022 - - steps: - - uses: actions/checkout@v2 - - - name: Install .NET SDK 6.0.x - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - - name: Install MSBuild - uses: microsoft/setup-msbuild@v1.1 - with: - #vs-version: '[17.0,)' - vs-prerelease: true - msbuild-architecture: x64 - - - name: Install NuGet 6.x - uses: nuget/setup-nuget@v1 - with: - nuget-version: '6.x' - - - name: Restore NuGet packages - run: | - nuget restore 'src\\Elmish.Uno.sln' -ConfigFile 'NuGet.Config' - - - name: Build with MSBuild - run: | - msbuild 'src\\Elmish.Uno.sln' /t:Rebuild /p:Configuration=Release /p:Platform='Any CPU' -maxcpucount - - - name: Pack Elmish.Uno with NuGet - run: | - $nuspec = get-content 'Elmish.Uno.nuspec' | %{ $_ -replace '\$versionSuffix\$',""} - set-content 'Elmish.Uno.nuspec' -value $nuspec - nuget pack 'Elmish.Uno.nuspec' -Properties Configuration=Release - - - name: Pack Templates with NuGet - run: | - $nuspec = get-content 'src\\Templates\\Templates.nuspec' | %{ $_ -replace '\$versionSuffix\$',""} - set-content 'src\\Templates\\Templates.nuspec' -value $nuspec - nuget pack 'src\\Templates\\Templates.nuspec' -Properties Configuration=Release -NoDefaultExcludes - - - name: Publish to NuGet - run: | - $key='${{secrets.NuGet_Key}}' - $dotnet nuget push -k $key *.nupkg diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml new file mode 100644 index 00000000..84ee9069 --- /dev/null +++ b/.github/workflows/publish_release.yml @@ -0,0 +1,60 @@ +name: Publish to NuGet + +on: + push: + tags: + - 'releases/*' + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + +jobs: + build: + + runs-on: windows-2022 + + steps: + + - name: Check-out + uses: actions/checkout@v4 + with: + # This is necessary so that we have the tags. + fetch-depth: 0 + + - name: Set Build Version + run: | + $version = "$env:GITHUB_REF_NAME".Substring("releases/".Length) + $File = ( + Select-Xml -XPath "/Project/PropertyGroup[@Label='NuGet']/Version" -Path "src\Elmish.Uno\Elmish.Uno.fsproj" + )[0].Node + $File.InnerText = $version + $File.OwnerDocument.Save((Join-Path $PWD.ProviderPath "src\Elmish.Uno\Elmish.Uno.fsproj")) + echo "VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + shell: pwsh + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Install local tools + run: dotnet tool restore + + - name: Restore NuGet packages + run: dotnet restore Elmish.Uno.sln + + - name: Build + run: dotnet build --no-restore Elmish.Uno.sln --configuration Release -maxcpucount + + - name: Test + run: dotnet test --no-build --configuration Release src/Elmish.Uno.Tests/Elmish.Uno.Tests.fsproj + + - name: Pack + run: | + cd src/Elmish.Uno + dotnet pack --no-build --configuration Release /p:ContinuousIntegrationBuild=true -o ../../nuget + + - name: Publish to NuGet + run: | + dotnet nuget push nuget/Elmish.Uno.${{env.VERSION}}.{nupkg,snupkg} -s "nuget.org" -k ${{secrets.NUGET_SECRET}} --skip-duplicate diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 8d655c42..83a6841a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -6,34 +6,37 @@ on: - opened - synchronize +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + jobs: build: - runs-on: windows-2022 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + dotnet: [8.0.202] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Install .NET SDK 6.0.x - uses: actions/setup-dotnet@v1 + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.x + dotnet-version: ${{ matrix.dotnet }} - - name: Install MSBuild - uses: microsoft/setup-msbuild@v1.1 - with: - #vs-version: '[17.0,)' - vs-prerelease: true - msbuild-architecture: x64 + - name: Install local tools + run: dotnet tool restore - name: Restore NuGet packages - run: nuget restore 'src\\Elmish.Uno.sln' -ConfigFile 'NuGet.Config' + run: dotnet restore Elmish.Uno.sln - - name: Build with MSBuild - run: | - msbuild 'src\\Elmish.Uno.sln' /t:Rebuild /p:Configuration=Release /p:Platform='Any CPU' -p:TargetFramework=net6.0-windows10.0.22000.0 -maxcpucount - msbuild 'src\\Elmish.Uno.sln' /t:Rebuild /p:Configuration=Release /p:Platform='Any CPU' -p:TargetFramework=net6.0 -maxcpucount + - name: Build + run: dotnet build --no-restore Elmish.Uno.sln --configuration Release -maxcpucount - name: Test run: dotnet test --no-build --configuration Release src/Elmish.Uno.Tests/Elmish.Uno.Tests.fsproj diff --git a/Elmish.Uno.nuspec b/Elmish.Uno.nuspec deleted file mode 100644 index 39db4e5e..00000000 --- a/Elmish.Uno.nuspec +++ /dev/null @@ -1,55 +0,0 @@ - - - - Elmish.Uno.WinUI - 1.0.0$versionSuffix$ - Elmish.Uno for WinUI - docs\README.md - XperiAndri,dim-37 - XperiAndri,dim-37 - false - MIT - https://github.com/XperiAndri/Elmish.Uno - F# bindings for using Elmish in Uno for WinUI - Uno F# fsharp Elmish Elm - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Elmish.Uno.sln b/Elmish.Uno.sln similarity index 73% rename from src/Elmish.Uno.sln rename to Elmish.Uno.sln index 0a65ca2a..2f160b57 100644 --- a/src/Elmish.Uno.sln +++ b/Elmish.Uno.sln @@ -5,35 +5,34 @@ VisualStudioVersion = 17.0.31612.314 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{51DF5F61-CE23-4BB5-A1D6-8421974B760B}" ProjectSection(SolutionItems) = preProject - ..\.editorconfig = ..\.editorconfig - ..\Elmish.Uno.nuspec = ..\Elmish.Uno.nuspec - ..\global.json = ..\global.json - ..\nuget.config = ..\nuget.config - Packages.props = Packages.props - ..\README.md = ..\README.md - ..\RELEASE_NOTES.md = ..\RELEASE_NOTES.md - Solution.Build.props = Solution.Build.props - ..\TUTORIAL.md = ..\TUTORIAL.md + .editorconfig = .editorconfig + src\Directory.Build.props = src\Directory.Build.props + src\Directory.Build.targets = src\Directory.Build.targets + src\Directory.Packages.props = src\Directory.Packages.props + global.json = global.json + nuget.config = nuget.config + README.md = README.md + RELEASE_NOTES.md = RELEASE_NOTES.md + TUTORIAL.md = TUTORIAL.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub", "GitHub", "{C6184090-416E-43D5-A110-F76B45317E0F}" EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Elmish.Uno.Tests", "Elmish.Uno.Tests\Elmish.Uno.Tests.fsproj", "{70BE17FF-A5E8-4D4A-B5C4-8B60C81D125B}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Elmish.Uno.Tests", "src\Elmish.Uno.Tests\Elmish.Uno.Tests.fsproj", "{70BE17FF-A5E8-4D4A-B5C4-8B60C81D125B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{E036A399-66BF-4656-98E0-45A30EABDBC7}" ProjectSection(SolutionItems) = preProject - ..\.github\workflows\publish_myget.yml = ..\.github\workflows\publish_myget.yml - ..\.github\workflows\publish_nuget.yml = ..\.github\workflows\publish_nuget.yml - ..\.github\workflows\pull_request.yml = ..\.github\workflows\pull_request.yml + .github\workflows\pull_request.yml = .github\workflows\pull_request.yml + .github\workflows\publish_ci.yml = .github\workflows\publish_ci.yml + .github\workflows\publish_release.yml = .github\workflows\publish_release.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{49DD7592-B03D-4EEE-B1BF-522488992C80}" ProjectSection(SolutionItems) = preProject - ..\Elmish.Uno.nuspec = ..\Elmish.Uno.nuspec Templates\Templates.nuspec = Templates\Templates.nuspec EndProjectSection EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Elmish.Uno", "Elmish.Uno\Elmish.Uno.fsproj", "{8C6E8D34-7205-4C57-9722-87E30E4FC5CE}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Elmish.Uno", "src\Elmish.Uno\Elmish.Uno.fsproj", "{8C6E8D34-7205-4C57-9722-87E30E4FC5CE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/NuGet.Config b/NuGet.Config index 29a9dd26..57d1a49d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,9 +1,25 @@  - - - - + + + + + + + + + + + + + + + diff --git a/src/Samples.sln b/Samples.sln similarity index 100% rename from src/Samples.sln rename to Samples.sln diff --git a/global.json b/global.json index f253e861..e864c33b 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,6 @@ { - "sdk": { - "allowPrerelease": true, - "rollForward": "major", - "version": "6.0.201" + "msbuild-sdks": { + "Uno.Sdk": "5.1.87", + "Microsoft.Build.NoTargets": "3.7.56" } } diff --git a/src/Elmish.Uno/elmish-uno-logo-128x128.png b/logo/elmish-uno-logo-128x128.png similarity index 100% rename from src/Elmish.Uno/elmish-uno-logo-128x128.png rename to logo/elmish-uno-logo-128x128.png diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..89fae90b --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,18 @@ + + + XperiAndri + Elmish.Uno + XperiAndri, Dim-37 + Copyright © XperiAndri + + + net8.0 + latest + latest + true + true + + + + + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 3b6a6781..8c119d54 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,3 +1,2 @@ - diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props new file mode 100644 index 00000000..9ddc0184 --- /dev/null +++ b/src/Directory.Packages.props @@ -0,0 +1,106 @@ + + + 8.0.0 + 8.0.0 + 8.0.0 + 8.1.240322-build.0 + 4.1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Elmish.Uno.Mobile/Navigation.fs b/src/Elmish.Uno.Mobile/Navigation.fs deleted file mode 100644 index 1ec0555f..00000000 --- a/src/Elmish.Uno.Mobile/Navigation.fs +++ /dev/null @@ -1,40 +0,0 @@ -namespace Elmish.Uno.Navigation - -open System -open System.Collections.Generic -open FSharp.Collections.Immutable -open Windows.UI.Xaml.Controls - -type public NavigationService (frame : Frame, pageMap : IReadOnlyDictionary) = - - new (frame, pageMap : KeyValuePair seq) = - let pageMap' = pageMap - |> Seq.fold - (fun (b : HashMap.Builder) p -> b.Add (p.Key, p.Value); b) - (HashMap.Empty.ToBuilder()) - NavigationService (frame, pageMap'.ToImmutable()) - - interface INavigationService with - member this.BackStackDepth = frame.BackStackDepth - member this.CacheSize = frame.CacheSize - member this.CanGoBack = frame.CanGoBack - member this.CanGoForward = frame.CanGoForward - - - member this.GetNavigationState (): string = - frame.GetNavigationState () - - member this.SetNavigationState(navigationState: string): unit = - frame.SetNavigationState (navigationState) - - member this.GoBack (): unit = - frame.GoBack () - - member this.GoForward (): unit = - frame.GoForward () - - member this.Navigate (name: string, navigationParams: INavigationParameters): bool = - frame.Navigate (pageMap.[name], navigationParams) - - member this.Navigate (name: string): bool = - frame.Navigate (pageMap.[name], null) diff --git a/src/Elmish.Uno.Tests/Elmish.Uno.Tests.fsproj b/src/Elmish.Uno.Tests/Elmish.Uno.Tests.fsproj index b55168ec..fb09df5a 100644 --- a/src/Elmish.Uno.Tests/Elmish.Uno.Tests.fsproj +++ b/src/Elmish.Uno.Tests/Elmish.Uno.Tests.fsproj @@ -1,13 +1,11 @@  - - net6.0 - $(RootNamespace).Tests - $(AssemblyBaseName).Tests + $(DotNetVersion) false - Library false + true + Library $(OtherFlags) --warnon:1182 FS0988 diff --git a/src/Elmish.Uno/DynamicCustomProperty.fs b/src/Elmish.Uno/DynamicCustomProperty.fs index bb65cd62..b35db93c 100644 --- a/src/Elmish.Uno/DynamicCustomProperty.fs +++ b/src/Elmish.Uno/DynamicCustomProperty.fs @@ -1,31 +1,29 @@ namespace Elmish.Uno open System -#if __UWP__ +open System.Runtime.InteropServices open Microsoft.UI.Xaml.Data; // TODO: investigate why nulls come to the constructor instead of None /// /// Implementation of dynamic property required by WinRT to do bindings. /// -/// Target object type from which to get and to which to set a property value. -/// Value type. +/// Target object type from which to get and to which to set a property value. +/// Value type. type DynamicCustomProperty<'target, 'value> ( - // name : string, - // getter : Func<'TValue>, - // [] - // setter : Action<'TValue>, - // [] - // indexGetter : Func, - // [] - // indexSetter : Action) = + name : string, + getter : Func<'target, 'value>, + [] setter : Action<'target, 'value>, + [] indexGetter : Func<'target, obj, 'value>, + [] indexSetter : Action<'target, 'value, obj> +) = //new ( - name : string, - ?getter : 'target -> 'value, - ?setter : 'value -> 'target -> unit, - ?indexGetter : obj -> 'target -> 'value, - ?indexSetter : 'value -> obj -> 'target -> unit) = + //name : string, + //?getter : 'target -> 'value, + //?setter : 'value -> 'target -> unit, + //?indexGetter : obj -> 'target -> 'value, + //?indexSetter : 'value -> obj -> 'target -> unit) = //let setter' = defaultArg setter null //let indexGetter' = defaultArg indexGetter null //let indexSetter' = defaultArg indexSetter null @@ -52,20 +50,20 @@ type DynamicCustomProperty<'target, 'value> ( member _.GetValue (target : obj) = let target = target :?> 'target - match getter with Some getter -> getter target |> box | None -> null + match getter with null -> null | _ -> getter.Invoke target |> box member _.SetValue (target : obj, value : obj) = let target = target :?> 'target - match setter with Some setter -> setter (value :?> 'value) target | None -> () + let value = value :?> 'value + match setter with null -> () | _ -> setter.Invoke (target, value) member _.GetIndexedValue(target : obj, index : obj) = let target = target :?> 'target - match indexGetter with Some indexGetter -> indexGetter index target |> box | None -> null + match indexGetter with null -> null | _ -> indexGetter.Invoke(target, index) |> box member _.SetIndexedValue(target : obj, value : obj, index : obj) = let target = target :?> 'target - match indexSetter with Some indexSetter -> indexSetter (value :?> 'value) index target | None -> () + let value = value :?> 'value + match indexSetter with null -> () | _ -> indexSetter.Invoke(target, value, index) - member _.CanRead = getter.IsSome || indexGetter.IsSome - member _.CanWrite = setter.IsSome || indexSetter.IsSome + member _.CanRead = getter <> null || indexGetter <> null + member _.CanWrite = setter <> null || indexSetter <> null member _.Name = name member _.Type = typeof<'value> - -#endif diff --git a/src/Elmish.Uno/Elmish.Uno.fsproj b/src/Elmish.Uno/Elmish.Uno.fsproj index f3752759..d243f5f8 100644 --- a/src/Elmish.Uno/Elmish.Uno.fsproj +++ b/src/Elmish.Uno/Elmish.Uno.fsproj @@ -1,37 +1,52 @@ - - - + - netstandard2.0;net6.0;net6.0-windows10.0.22000.0 - 10.0.17763.0 - $(AssemblyBaseName) + $(TargetFrameworks);$(DotNetVersion)-windows10.0.22621 + $(TargetFrameworks);$(DotNetVersion) + $(OverrideTargetFramework) + true - + true + + + + Elmish implementation for WInUI and Uno Platform + + $([System.IO.Path]::GetDirectoryName($([MSBuild]::GetPathOfFileAbove('.gitignore', '$(MSBuildThisFileDirectory)')))) + https://github.com/fsprojects/FSharp.Data.GraphQL + git 1.0.0 - --> + FSharp Elmish Uno WinUI + README.md + elmish-uno-logo-128x128.png + https://github.com/xperiandri/Elmish.Uno/ + false + MIT + true + snupkg + true + true $(OtherFlags) --warnon:1182 - - $(DefineConstants);__UWP__ - + + + + - - True - - <_Parameter1>Elmish.Uno.Tests @@ -44,25 +59,16 @@ - - + - - - - - + + + - - - + diff --git a/src/Elmish.Uno/Navigation.fs b/src/Elmish.Uno/Navigation.fs deleted file mode 100644 index e2ae6a61..00000000 --- a/src/Elmish.Uno/Navigation.fs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Elmish.Uno.Navigation - -open System -open System.Collections.Generic - -type public NavigationParameter = KeyValuePair -type public INavigationParameters = IReadOnlyDictionary - -type public INavigationService = - abstract Navigate : name : string -> bool - abstract Navigate : name : string * navigationParams : INavigationParameters -> bool - - abstract GoBack : unit -> unit - abstract GoForward : unit -> unit - abstract GetNavigationState : unit -> string - abstract SetNavigationState : navigationState : string -> unit - - abstract CacheSize : int - abstract BackStackDepth : int - abstract CanGoBack : bool - abstract CanGoForward : bool diff --git a/src/Elmish.Uno/Program.fs b/src/Elmish.Uno/Program.fs index 54f3609b..6f2e6ed0 100644 --- a/src/Elmish.Uno/Program.fs +++ b/src/Elmish.Uno/Program.fs @@ -1,7 +1,6 @@ [] module Elmish.Uno.Program -open System.Windows open Elmish @@ -42,7 +41,7 @@ let mkProgramUnoWithCmdMsg /// Traces all updates using System.Diagnostics.Debug.WriteLine. let withDebugTrace program = - program |> Program.withTrace (fun msg model -> + program |> Program.withTrace (fun msg model _ -> System.Diagnostics.Debug.WriteLine(sprintf "New message: %A" msg) System.Diagnostics.Debug.WriteLine(sprintf "Updated state: %A" model) ) diff --git a/src/Elmish.Uno/ViewModel.fs b/src/Elmish.Uno/ViewModel.fs index 6b3c0691..17a417e4 100644 --- a/src/Elmish.Uno/ViewModel.fs +++ b/src/Elmish.Uno/ViewModel.fs @@ -3,20 +3,15 @@ open System open System.Collections.Generic open System.Collections.ObjectModel -open System.ComponentModel open System.Diagnostics open System.Dynamic open System.Reflection open Microsoft.FSharp.Reflection +open Microsoft.UI.Xaml.Data open FSharp.Collections.Immutable open Elmish.Uno -#if __UWP__ -open Microsoft.UI.Xaml.Data -#endif - - [] module internal ViewModelHelpers = @@ -124,7 +119,7 @@ and internal SubModelSelectedItemBinding<'model, 'msg, 'bindingModel, 'bindingMs and internal CachedBinding<'model, 'msg, 'value> = { Binding: VmBinding<'model, 'msg> - Cache: 'value option ref + Cache: 'value voption ref } @@ -143,7 +138,7 @@ and internal VmBinding<'model, 'msg> = | Cached of CachedBinding<'model, 'msg, obj> -and [] internal ViewModel<'model, 'msg> +and [] public ViewModel<'model, 'msg> ( initialModel: 'model, dispatch: 'msg -> unit, bindings: Binding<'model, 'msg> list, @@ -154,8 +149,8 @@ and [] internal ViewModel<'model, 'msg> let mutable currentModel = initialModel - let propertyChanged = Event() - let errorsChanged = DelegateEvent>() + let propertyChanged = Event() + let errorsChanged = DelegateEvent>() let modelTypeChanged = Event() static let multicastFiled = typeof>.GetField("multicast", BindingFlags.NonPublic ||| BindingFlags.Instance) @@ -168,7 +163,7 @@ and [] internal ViewModel<'model, 'msg> /// Error messages keyed by property name. let errors = Dictionary() - let withCaching b = Cached { Binding = b; Cache = ref None } + let withCaching b = Cached { Binding = b; Cache = ref ValueNone } let log fmt = let innerLog (str: string) = @@ -188,14 +183,14 @@ and [] internal ViewModel<'model, 'msg> let notifyPropertyChanged propName = log "[%s] PropertyChanged \"%s\"" propNameChain propName try - propertyChanged.Trigger(this, PropertyChangedEventArgs propName) + propertyChanged.Trigger(this, System.ComponentModel.PropertyChangedEventArgs propName) with _ -> Debugger.Break() let notifyErrorsChanged propName = log "[%s] ErrorsChanged \"%s\"" propNameChain propName try - errorsChanged.Trigger([| box this; box <| DataErrorsChangedEventArgs propName |]) + errorsChanged.Trigger([| box this; box <| System.ComponentModel.DataErrorsChangedEventArgs propName |]) with _ -> Debugger.Break() @@ -444,7 +439,7 @@ and [] internal ViewModel<'model, 'msg> | Cmd { Cmd = cmd } | CmdParam cmd -> box cmd - | SubModel { Vm = vm } -> !vm |> ValueOption.toObj |> box + | SubModel { Vm = vm } -> vm.Value |> ValueOption.toObj |> box | SubModelSeq { Vms = vms } -> box vms | SubModelSelectedItem b -> let selectedId = b.Get model @@ -457,11 +452,11 @@ and [] internal ViewModel<'model, 'msg> (selected |> Option.map (fun vm -> b.SubModelSeqBinding.GetId vm.CurrentModel)) selected |> Option.toObj |> box | Cached b -> - match !b.Cache with - | Some v -> v - | None -> + match b.Cache.Value with + | ValueSome v -> v + | ValueNone -> let v = tryGetMember model b.Binding - b.Cache := Some v + b.Cache.Value <- ValueSome v v let rec canSetMember = function @@ -496,7 +491,7 @@ and [] internal ViewModel<'model, 'msg> | Cached b -> let successful = trySetMember model value b.Binding if successful then - b.Cache := None // TODO #185: write test + b.Cache.Value <- ValueNone // TODO #185: write test successful | OneWay _ | OneWayLazy _ @@ -509,7 +504,7 @@ and [] internal ViewModel<'model, 'msg> /// Updates the binding value (for relevant bindings) and returns a value /// indicating whether to trigger PropertyChanged for this binding - member this.UpdateValue = + member internal this.UpdateValue = let rec updateValue bindingName newModel = function | OneWay { Get = get } | TwoWay { Get = get } @@ -533,15 +528,15 @@ and [] internal ViewModel<'model, 'msg> | CmdParam _ -> false | SubModel b -> - match !b.Vm, b.GetModel newModel with + match b.Vm.Value, b.GetModel newModel with | ValueNone, ValueNone -> false | ValueSome _, ValueNone -> if b.Sticky then false else - b.Vm := ValueNone + b.Vm.Value <- ValueNone true | ValueNone, ValueSome m -> - b.Vm := ValueSome <| this.Create(m, b.ToMsg >> dispatch, b.GetBindings (), config, getPropChainFor bindingName) + b.Vm.Value <- ValueSome <| this.Create(m, b.ToMsg >> dispatch, b.GetBindings (), config, getPropChainFor bindingName) true | ValueSome vm, ValueSome m -> vm.UpdateModel m @@ -560,7 +555,7 @@ and [] internal ViewModel<'model, 'msg> | Cached b -> let valueChanged = updateValue bindingName newModel b.Binding if valueChanged then - b.Cache := None + b.Cache.Value <- ValueNone valueChanged updateValue @@ -644,22 +639,21 @@ and [] internal ViewModel<'model, 'msg> member internal __.TrySetMember(value, binding) = trySetMember currentModel value binding - interface INotifyPropertyChanged with + interface System.ComponentModel.INotifyPropertyChanged with [] member __.PropertyChanged = propertyChanged.Publish - interface INotifyDataErrorInfo with + interface System.ComponentModel.INotifyDataErrorInfo with [] member __.ErrorsChanged = errorsChanged.Publish member __.HasErrors = errors.Count > 0 member __.GetErrors propName = - log "[%s] GetErrors %s" propNameChain (propName |> Option.ofObj |> Option.defaultValue "") + log "[%s] GetErrors %s" propNameChain (propName |> ValueOption.ofObj |> ValueOption.defaultValue "") match errors.TryGetValue propName with | true, err -> upcast err | false, _ -> null -#if __UWP__ member private this.GetProperty(name : string) : ICustomProperty = if name = "CurrentModel" then DynamicCustomProperty, obj>(name, fun vm -> vm.CurrentModel |> box) :> _ @@ -681,14 +675,15 @@ and [] internal ViewModel<'model, 'msg> let twoWay = TwoWay twoWay DynamicCustomProperty, obj>(name, (fun vm -> vm.TryGetMember(twoWay)), - (fun value vm -> vm.TrySetMember(value, twoWay) |> ignore)) :> _ + (fun vm value -> vm.TrySetMember(value, twoWay) |> ignore)) :> _ | TwoWayValidate twoWayValidate -> let twoWayValidate = TwoWayValidate twoWayValidate DynamicCustomProperty, obj>(name, (fun vm -> vm.TryGetMember(twoWayValidate)), - (fun value vm -> vm.TrySetMember(value, twoWayValidate) |> ignore)) :> _ - | Cmd cmd -> DynamicCustomProperty, System.Windows.Input.ICommand>(name, - fun vm -> vm.TryGetMember(Cmd cmd) :?> _) :> _ + (fun vm value -> vm.TrySetMember(value, twoWayValidate) |> ignore)) :> _ + | Cmd cmd -> + DynamicCustomProperty, System.Windows.Input.ICommand>(name, + fun vm -> vm.TryGetMember(Cmd cmd) :?> _) :> _ | CmdParam cmdParam -> DynamicCustomProperty, obj>(name, fun vm -> vm.TryGetMember(CmdParam cmdParam)) :> _ @@ -705,7 +700,7 @@ and [] internal ViewModel<'model, 'msg> let cached = Cached cached DynamicCustomProperty, obj>(name, (fun vm -> vm.TryGetMember(cached)), - (fun value vm -> vm.TrySetMember(value, cached) |> ignore)) :> _ + (fun vm value -> vm.TrySetMember(value, cached) |> ignore)) :> _ interface ICustomPropertyProvider with @@ -716,4 +711,3 @@ and [] internal ViewModel<'model, 'msg> member this.GetStringRepresentation() = this.CurrentModel.ToString() member this.Type = this.CurrentModel.GetType() -#endif diff --git a/src/Elmish.Uno/ViewModelModule.fs b/src/Elmish.Uno/ViewModelModule.fs index e51366ed..25bf9a8f 100644 --- a/src/Elmish.Uno/ViewModelModule.fs +++ b/src/Elmish.Uno/ViewModelModule.fs @@ -14,8 +14,9 @@ type ViewModel() = static let startLoop (config: ElmConfig) (element: FrameworkElement) - (programRun: Program<'t, 'model, 'msg, Binding<'model, 'msg> list> -> unit) - (program: Program<'t, 'model, 'msg, Binding<'model, 'msg> list>) = + (program: Program<'t, 'model, 'msg, Binding<'model, 'msg> list>) + arg + = let mutable lastModel = None @@ -38,14 +39,13 @@ type ViewModel() = program |> Program.withSetState setState - |> Program.withSyncDispatch uiDispatch - |> programRun + |> Program.runWithDispatch uiDispatch arg - static member StartLoop (config, element, programRun : Action list>>, program) = - startLoop config element (FuncConvert.FromAction programRun) program + static member StartLoop (config, element, program) = + startLoop config element program () - static member StartLoop (config, element, programRun : Action<'arg, Program<'arg, 'model, 'msg, Binding<'model, 'msg> list>>, program, arg) = - startLoop config element (FuncConvert.FromAction programRun arg) program + static member StartLoop (config, element, program, arg) = + startLoop config element program arg static member DesignInstance (model: 'model, bindings: Binding<'model, 'msg> list) = ViewModel<_,_> (model, ignore, bindings, ElmConfig.Default, "main") |> box diff --git a/src/Elmish.Uno/elmish-wpf-logo-128x128.png b/src/Elmish.Uno/elmish-wpf-logo-128x128.png deleted file mode 100644 index 02eda92a..00000000 Binary files a/src/Elmish.Uno/elmish-wpf-logo-128x128.png and /dev/null differ diff --git a/src/Packages.props b/src/Packages.props deleted file mode 100644 index e1d6cfd3..00000000 --- a/src/Packages.props +++ /dev/null @@ -1,109 +0,0 @@ - - - - 6.0.* - 7.1.* - 4.10.* - 4.10.* - [3.0.3, 4) - - - - - - - - - - - - - - - - - - - - - - - - - - 6.2.13 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/src/Solution.Build.props b/src/Solution.Build.props deleted file mode 100644 index 0fad1114..00000000 --- a/src/Solution.Build.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - Elmish.Uno - Elmish.Uno - XperiAndri - Elmish.Uno - XperiAndri, Dim-37 - Copyright © XperiAndri - -