diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 5bbc3d69158..875161d336e 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -84,11 +84,11 @@ "GenerateCppHeaders", "Package", "RunCoreLibsTests", - "RunDesignerTests", "RunHtmlPreviewerTests", "RunLeakTests", "RunRenderTests", "RunTests", + "RunToolsTests", "ZipFiles" ] } @@ -123,11 +123,11 @@ "GenerateCppHeaders", "Package", "RunCoreLibsTests", - "RunDesignerTests", "RunHtmlPreviewerTests", "RunLeakTests", "RunRenderTests", "RunTests", + "RunToolsTests", "ZipFiles" ] } diff --git a/Avalonia.sln b/Avalonia.sln index e66b73de0ef..b21df076289 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -244,8 +244,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls.ItemsRepe EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls.ItemsRepeater.UnitTests", "tests\Avalonia.Controls.ItemsRepeater.UnitTests\Avalonia.Controls.ItemsRepeater.UnitTests.csproj", "{F4E36AA8-814E-4704-BC07-291F70F45193}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Generators", "src\tools\Avalonia.Generators\Avalonia.Generators.csproj", "{DDA28789-C21A-4654-86CE-D01E81F095C5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Generators.Tests", "tests\Avalonia.Generators.Tests\Avalonia.Generators.Tests.csproj", "{2D7C812B-7E73-4252-8EFD-BC8A4D5CCB9F}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Fonts.Inter", "src\Avalonia.Fonts.Inter\Avalonia.Fonts.Inter.csproj", "{13F1135D-BA1A-435C-9C5B-A368D1D63DE4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generators.Sandbox", "samples\Generators.Sandbox\Generators.Sandbox.csproj", "{A82AD1BC-EBE6-4FC3-A13B-D52A50297533}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -573,10 +579,22 @@ Global {F4E36AA8-814E-4704-BC07-291F70F45193}.Debug|Any CPU.Build.0 = Debug|Any CPU {F4E36AA8-814E-4704-BC07-291F70F45193}.Release|Any CPU.ActiveCfg = Release|Any CPU {F4E36AA8-814E-4704-BC07-291F70F45193}.Release|Any CPU.Build.0 = Release|Any CPU + {DDA28789-C21A-4654-86CE-D01E81F095C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDA28789-C21A-4654-86CE-D01E81F095C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDA28789-C21A-4654-86CE-D01E81F095C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDA28789-C21A-4654-86CE-D01E81F095C5}.Release|Any CPU.Build.0 = Release|Any CPU + {2D7C812B-7E73-4252-8EFD-BC8A4D5CCB9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D7C812B-7E73-4252-8EFD-BC8A4D5CCB9F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D7C812B-7E73-4252-8EFD-BC8A4D5CCB9F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D7C812B-7E73-4252-8EFD-BC8A4D5CCB9F}.Release|Any CPU.Build.0 = Release|Any CPU {13F1135D-BA1A-435C-9C5B-A368D1D63DE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {13F1135D-BA1A-435C-9C5B-A368D1D63DE4}.Debug|Any CPU.Build.0 = Debug|Any CPU {13F1135D-BA1A-435C-9C5B-A368D1D63DE4}.Release|Any CPU.ActiveCfg = Release|Any CPU {13F1135D-BA1A-435C-9C5B-A368D1D63DE4}.Release|Any CPU.Build.0 = Release|Any CPU + {A82AD1BC-EBE6-4FC3-A13B-D52A50297533}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A82AD1BC-EBE6-4FC3-A13B-D52A50297533}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A82AD1BC-EBE6-4FC3-A13B-D52A50297533}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A82AD1BC-EBE6-4FC3-A13B-D52A50297533}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -643,7 +661,10 @@ Global {75C47156-C5D8-44BC-A5A7-E8657C2248D6} = {9B9E3891-2366-4253-A952-D08BCEB71098} {C810060E-3809-4B74-A125-F11533AF9C1B} = {9B9E3891-2366-4253-A952-D08BCEB71098} {C692FE73-43DB-49CE-87FC-F03ED61F25C9} = {4ED8B739-6F4E-4CD4-B993-545E6B5CE637} + {DDA28789-C21A-4654-86CE-D01E81F095C5} = {4ED8B739-6F4E-4CD4-B993-545E6B5CE637} + {2D7C812B-7E73-4252-8EFD-BC8A4D5CCB9F} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {F4E36AA8-814E-4704-BC07-291F70F45193} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} + {A82AD1BC-EBE6-4FC3-A13B-D52A50297533} = {9B9E3891-2366-4253-A952-D08BCEB71098} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A} diff --git a/build/SourceGenerators.props b/build/SourceGenerators.props index 4929578b604..a66bff49993 100644 --- a/build/SourceGenerators.props +++ b/build/SourceGenerators.props @@ -1,5 +1,10 @@ - + + true + false + + + + + + + + diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index 46f267ae171..40232947d9f 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -220,16 +220,18 @@ void RunCoreTest(string projectName) .Executes(() => { RunCoreTest("Avalonia.Skia.RenderTests"); - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (Parameters.IsRunningOnWindows) RunCoreTest("Avalonia.Direct2D1.RenderTests"); }); - Target RunDesignerTests => _ => _ - .OnlyWhenStatic(() => !Parameters.SkipTests && Parameters.IsRunningOnWindows) + Target RunToolsTests => _ => _ + .OnlyWhenStatic(() => !Parameters.SkipTests) .DependsOn(Compile) .Executes(() => { - RunCoreTest("Avalonia.DesignerSupport.Tests"); + RunCoreTest("Avalonia.Generators.Tests"); + if (Parameters.IsRunningOnWindows) + RunCoreTest("Avalonia.DesignerSupport.Tests"); }); Target RunLeakTests => _ => _ @@ -276,7 +278,7 @@ void DoMemoryTest() Target RunTests => _ => _ .DependsOn(RunCoreLibsTests) .DependsOn(RunRenderTests) - .DependsOn(RunDesignerTests) + .DependsOn(RunToolsTests) .DependsOn(RunHtmlPreviewerTests) .DependsOn(RunLeakTests); diff --git a/nukebuild/numerge.config b/nukebuild/numerge.config index d1c0408241c..09f22ec527d 100644 --- a/nukebuild/numerge.config +++ b/nukebuild/numerge.config @@ -11,6 +11,11 @@ "Id": "Avalonia.Build.Tasks", "IgnoreMissingFrameworkBinaries": true, "DoNotMergeDependencies": true + }, + { + "Id": "Avalonia.Generators", + "IgnoreMissingFrameworkBinaries": true, + "DoNotMergeDependencies": true } ] } diff --git a/packages/Avalonia/Avalonia.csproj b/packages/Avalonia/Avalonia.csproj index 4d0ed866a36..1d210172f0e 100644 --- a/packages/Avalonia/Avalonia.csproj +++ b/packages/Avalonia/Avalonia.csproj @@ -6,11 +6,15 @@ - + all true TargetFramework=netstandard2.0 + diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index 0e84b3d1826..5125b42426a 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -2,7 +2,8 @@ netstandard2.0;net6.0 true - enable + enable + true @@ -35,14 +36,5 @@ - - - - - - - - - - + diff --git a/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs b/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs index 7db6d9d3341..89441513856 100644 --- a/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs +++ b/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs @@ -1,11 +1,10 @@ using Avalonia.Controls; using Avalonia.Controls.Primitives; -using Avalonia.Markup.Xaml; using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public class FlyoutsPage : UserControl + public partial class FlyoutsPage : UserControl { public FlyoutsPage() { @@ -28,11 +27,6 @@ private void Afp_DoubleTapped(object? sender, RoutedEventArgs e) } } - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - private void SetXamlTexts() { var bfxt = this.Get("ButtonFlyoutXamlText"); diff --git a/samples/ControlCatalog/Pages/LabelsPage.axaml.cs b/samples/ControlCatalog/Pages/LabelsPage.axaml.cs index f05e5fd0333..f3a7647f8c8 100644 --- a/samples/ControlCatalog/Pages/LabelsPage.axaml.cs +++ b/samples/ControlCatalog/Pages/LabelsPage.axaml.cs @@ -1,11 +1,9 @@ -using Avalonia; -using Avalonia.Controls; -using Avalonia.Markup.Xaml; +using Avalonia.Controls; using ControlCatalog.Models; namespace ControlCatalog.Pages { - public class LabelsPage : UserControl + public partial class LabelsPage : UserControl { private Person? _person; @@ -25,11 +23,6 @@ private void CreateDefaultPerson() }; } - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - public void DoSave() { diff --git a/samples/ControlCatalog/Pages/RefreshContainerPage.axaml.cs b/samples/ControlCatalog/Pages/RefreshContainerPage.axaml.cs index f9d0328d9ae..a710cd7e5c7 100644 --- a/samples/ControlCatalog/Pages/RefreshContainerPage.axaml.cs +++ b/samples/ControlCatalog/Pages/RefreshContainerPage.axaml.cs @@ -1,18 +1,15 @@ -using System.Threading.Tasks; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Markup.Xaml; +using Avalonia.Controls; using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public class RefreshContainerPage : UserControl + public partial class RefreshContainerPage : UserControl { private RefreshContainerViewModel _viewModel; public RefreshContainerPage() { - this.InitializeComponent(); + InitializeComponent(); _viewModel = new RefreshContainerViewModel(); @@ -27,10 +24,5 @@ private async void RefreshContainerPage_RefreshRequested(object? sender, Refresh deferral.Complete(); } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } } } diff --git a/samples/ControlCatalog/Pages/RelativePanelPage.axaml.cs b/samples/ControlCatalog/Pages/RelativePanelPage.axaml.cs index 11d0a5152e0..aec13a18e37 100644 --- a/samples/ControlCatalog/Pages/RelativePanelPage.axaml.cs +++ b/samples/ControlCatalog/Pages/RelativePanelPage.axaml.cs @@ -1,19 +1,12 @@ -using Avalonia; -using Avalonia.Controls; -using Avalonia.Markup.Xaml; +using Avalonia.Controls; namespace ControlCatalog.Pages { - public class RelativePanelPage : UserControl + public partial class RelativePanelPage : UserControl { public RelativePanelPage() { - this.InitializeComponent(); - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); + InitializeComponent(); } } } diff --git a/samples/ControlCatalog/Pages/ThemePage.axaml.cs b/samples/ControlCatalog/Pages/ThemePage.axaml.cs index f0ae1a722da..5a0c4cba43d 100644 --- a/samples/ControlCatalog/Pages/ThemePage.axaml.cs +++ b/samples/ControlCatalog/Pages/ThemePage.axaml.cs @@ -1,35 +1,31 @@ -using Avalonia; -using Avalonia.Controls; +using Avalonia.Controls; using Avalonia.Markup.Xaml; using Avalonia.Styling; namespace ControlCatalog.Pages { - public class ThemePage : UserControl + public partial class ThemePage : UserControl { public static ThemeVariant Pink { get; } = new("Pink", ThemeVariant.Light); public ThemePage() { - AvaloniaXamlLoader.Load(this); + InitializeComponent(); - var selector = this.FindControl("Selector")!; - var themeVariantScope = this.FindControl("ThemeVariantScope")!; - - selector.Items = new[] + Selector.Items = new[] { ThemeVariant.Default, ThemeVariant.Dark, ThemeVariant.Light, Pink }; - selector.SelectedIndex = 0; + Selector.SelectedIndex = 0; - selector.SelectionChanged += (_, _) => + Selector.SelectionChanged += (_, _) => { - if (selector.SelectedItem is ThemeVariant theme) + if (Selector.SelectedItem is ThemeVariant theme) { - themeVariantScope.RequestedThemeVariant = theme; + ThemeVariantScope.RequestedThemeVariant = theme; } }; } diff --git a/samples/Generators.Sandbox/App.xaml b/samples/Generators.Sandbox/App.xaml new file mode 100644 index 00000000000..8064eac3f5c --- /dev/null +++ b/samples/Generators.Sandbox/App.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/samples/Generators.Sandbox/App.xaml.cs b/samples/Generators.Sandbox/App.xaml.cs new file mode 100644 index 00000000000..6118b3f177b --- /dev/null +++ b/samples/Generators.Sandbox/App.xaml.cs @@ -0,0 +1,20 @@ +using Avalonia; +using Avalonia.Markup.Xaml; +using Generators.Sandbox.ViewModels; + +namespace Generators.Sandbox; + +public class App : Application +{ + public override void Initialize() => AvaloniaXamlLoader.Load(this); + + public override void OnFrameworkInitializationCompleted() + { + var view = new Views.SignUpView + { + ViewModel = new SignUpViewModel() + }; + view.Show(); + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/samples/Generators.Sandbox/Controls/CustomTextBox.cs b/samples/Generators.Sandbox/Controls/CustomTextBox.cs new file mode 100644 index 00000000000..68ee9259867 --- /dev/null +++ b/samples/Generators.Sandbox/Controls/CustomTextBox.cs @@ -0,0 +1,10 @@ +using System; +using Avalonia.Controls; +using Avalonia.Styling; + +namespace Generators.Sandbox.Controls; + +public class CustomTextBox : TextBox, IStyleable +{ + Type IStyleable.StyleKey => typeof(TextBox); +} \ No newline at end of file diff --git a/samples/Generators.Sandbox/Controls/SignUpView.xaml b/samples/Generators.Sandbox/Controls/SignUpView.xaml new file mode 100644 index 00000000000..c126f36f534 --- /dev/null +++ b/samples/Generators.Sandbox/Controls/SignUpView.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + +