From 7c3e2391eaa00f87b15394fb10a0372865d5c53d Mon Sep 17 00:00:00 2001 From: David Vreony Date: Thu, 13 Jun 2024 18:28:19 +0100 Subject: [PATCH 1/6] add avalonia generation --- ...UI.Avalonia.ViewToViewModelBindings.csproj | 30 +++++++++++++ ...loniaControlBindingModelSourceGenerator.cs | 35 ++++++++++++++++ .../AvaloniaPlatformResolver.cs | 42 +++++++++++++++++++ src/Vetuviem.sln | 23 ++++++++++ 4 files changed, 130 insertions(+) create mode 100644 src/ReactiveUI.Avalonia.ViewToViewModelBindings/ReactiveUI.Avalonia.ViewToViewModelBindings.csproj create mode 100644 src/Vetuviem.Avalonia.SourceGenerator/AvaloniaControlBindingModelSourceGenerator.cs create mode 100644 src/Vetuviem.Avalonia.SourceGenerator/AvaloniaPlatformResolver.cs diff --git a/src/ReactiveUI.Avalonia.ViewToViewModelBindings/ReactiveUI.Avalonia.ViewToViewModelBindings.csproj b/src/ReactiveUI.Avalonia.ViewToViewModelBindings/ReactiveUI.Avalonia.ViewToViewModelBindings.csproj new file mode 100644 index 00000000..6435ef59 --- /dev/null +++ b/src/ReactiveUI.Avalonia.ViewToViewModelBindings/ReactiveUI.Avalonia.ViewToViewModelBindings.csproj @@ -0,0 +1,30 @@ + + + net8.0-windows10.0.19041 + 9 + full + True + true + + + + False + + + + + + + + + + + + + true + + diff --git a/src/Vetuviem.Avalonia.SourceGenerator/AvaloniaControlBindingModelSourceGenerator.cs b/src/Vetuviem.Avalonia.SourceGenerator/AvaloniaControlBindingModelSourceGenerator.cs new file mode 100644 index 00000000..2f29d041 --- /dev/null +++ b/src/Vetuviem.Avalonia.SourceGenerator/AvaloniaControlBindingModelSourceGenerator.cs @@ -0,0 +1,35 @@ +// Copyright (c) 2022 DPVreony and Contributors. All rights reserved. +// DPVreony and Contributors licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis; +using Vetuviem.SourceGenerator; +using Vetuviem.SourceGenerator.Features.Core; + +namespace Vetuviem.Avalonia.SourceGenerator +{ + /// + /// Control Binding Model Source Generator for Blazor. + /// + [Generator] + public sealed class AvaloniaControlBindingModelSourceGenerator : AbstractControlBindingModelSourceGenerator + { + /// + protected override MetadataReference? CheckIfShouldAddMissingAssemblyReference(string assemblyOfInterest) + { + return null; + } + + /// + protected override IPlatformResolver GetPlatformResolver() + { + return new AvaloniaPlatformResolver(); + } + + /// + protected override string GetPlatformName() + { + return "Avalonia"; + } + } +} diff --git a/src/Vetuviem.Avalonia.SourceGenerator/AvaloniaPlatformResolver.cs b/src/Vetuviem.Avalonia.SourceGenerator/AvaloniaPlatformResolver.cs new file mode 100644 index 00000000..499c5d23 --- /dev/null +++ b/src/Vetuviem.Avalonia.SourceGenerator/AvaloniaPlatformResolver.cs @@ -0,0 +1,42 @@ +// Copyright (c) 2022 DPVreony and Contributors. All rights reserved. +// DPVreony and Contributors licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using Vetuviem.SourceGenerator.Features.Core; + +namespace Vetuviem.Avalonia.SourceGenerator +{ + /// + /// UI Platform resolver for Blazor. + /// + public sealed class AvaloniaPlatformResolver : IPlatformResolver + { + /// + public string[] GetAssemblyNames() + { + return new[] + { + "Avalonia.Controls.dll", + "Avalonia.ReactiveUI.dll", + }; + } + + /// + public string GetBaseUiElement() + { + return "global::Avalonia.Visual"; + } + + /// + public string? GetCommandSourceInterface() + { + return "global::Avalonia.Input.ICommandSource"; + } + + /// + public string GetCommandInterface() + { + return "global::Avalonia.Input.ICommand"; + } + } +} diff --git a/src/Vetuviem.sln b/src/Vetuviem.sln index e2ea1c37..ddba71ff 100644 --- a/src/Vetuviem.sln +++ b/src/Vetuviem.sln @@ -47,6 +47,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vetuviem.Winforms.SourceGen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vetuviem.Avalonia.SourceGenerator", "Vetuviem.Avalonia.SourceGenerator\Vetuviem.Avalonia.SourceGenerator.csproj", "{00BC63E3-7FD3-483E-A2E0-CCB9897947E0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactiveUI.Avalonia.ViewToViewModelBindings", "ReactiveUI.Avalonia.ViewToViewModelBindings\ReactiveUI.Avalonia.ViewToViewModelBindings.csproj", "{ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -441,6 +443,26 @@ Global {00BC63E3-7FD3-483E-A2E0-CCB9897947E0}.Release|x64.Build.0 = Release|Any CPU {00BC63E3-7FD3-483E-A2E0-CCB9897947E0}.Release|x86.ActiveCfg = Release|Any CPU {00BC63E3-7FD3-483E-A2E0-CCB9897947E0}.Release|x86.Build.0 = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|ARM.ActiveCfg = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|ARM.Build.0 = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|ARM64.Build.0 = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|x64.ActiveCfg = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|x64.Build.0 = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|x86.ActiveCfg = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Debug|x86.Build.0 = Debug|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|Any CPU.Build.0 = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|ARM.ActiveCfg = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|ARM.Build.0 = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|ARM64.ActiveCfg = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|ARM64.Build.0 = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|x64.ActiveCfg = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|x64.Build.0 = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|x86.ActiveCfg = Release|Any CPU + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -455,6 +477,7 @@ Global {15274B47-731E-4352-9CBD-2639C548D9A9} = {1B3AF279-0165-4820-947C-222B1AE379D9} {3AA61E19-4EC3-4B5E-B7DB-3AB65F931F6C} = {1B3AF279-0165-4820-947C-222B1AE379D9} {D8E39D69-FD9A-4ACF-8743-048EF199884C} = {106C1632-9789-48A3-B7D0-FE793EC46DB8} + {ED7AD6E7-AA52-419A-A127-6AEA2933EEFB} = {1B3AF279-0165-4820-947C-222B1AE379D9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3C43A2D4-5AAF-4846-936D-75F742D25A81} From ddabfc9290e34ab8148569fb2f8d5ea519d937bf Mon Sep 17 00:00:00 2001 From: David Vreony Date: Thu, 13 Jun 2024 18:35:17 +0100 Subject: [PATCH 2/6] Update ReactiveUI.Avalonia.ViewToViewModelBindings.csproj --- .../ReactiveUI.Avalonia.ViewToViewModelBindings.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ReactiveUI.Avalonia.ViewToViewModelBindings/ReactiveUI.Avalonia.ViewToViewModelBindings.csproj b/src/ReactiveUI.Avalonia.ViewToViewModelBindings/ReactiveUI.Avalonia.ViewToViewModelBindings.csproj index 6435ef59..11fde669 100644 --- a/src/ReactiveUI.Avalonia.ViewToViewModelBindings/ReactiveUI.Avalonia.ViewToViewModelBindings.csproj +++ b/src/ReactiveUI.Avalonia.ViewToViewModelBindings/ReactiveUI.Avalonia.ViewToViewModelBindings.csproj @@ -4,7 +4,6 @@ 9 full True - true