From af3b0beacf8a183a4852c69ab6f60ec8319dae1b Mon Sep 17 00:00:00 2001 From: "Artyom V. Gorchakov" Date: Sat, 6 Feb 2021 16:03:04 +0300 Subject: [PATCH] housekeeping: Add GIF recordings --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cf6d013fbf..d401414ab4 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,16 @@ ### C# `SourceGenerator` for Typed Avalonia `x:Name` References -This is a [C# `SourceGenerator`](https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/) built for generating strongly-typed references to controls with `x:Name` (or just `Name`) attributes declared in XAML (or, in `.axaml`). The sandbox app is targeting `net5` which is still in preview, so this source generator is an early proof-of-concept. The idea is that you include your Avalonia XAML files into your project via `` and then decorate your view class with `[GenerateTypedNameReferences]` and the source generator will look for the `xaml` (or `axaml`) file with the same name as your C# class. The source generator then parses the XML markup, finds all XML tags with `x:Name` attributes and generates the C# code. + + +This is a [C# `SourceGenerator`](https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/) built for generating strongly-typed references to controls with `x:Name` (or just `Name`) attributes declared in XAML (or, in `.axaml`). The idea is that you include your Avalonia XAML files into your project via `` and then decorate your view class with `[GenerateTypedNameReferences]` and the source generator will look for the `xaml` (or `axaml`) file with the same name as your C# class. The source generator then parses the XML markup, finds all XML tags with `x:Name` attributes and generates the C# code. ### Getting Started -So in your project file you write the following code: +So in your project file you paste the following code: ```xml - - %(Filename) - - - Designer - - @@ -30,7 +25,7 @@ And then you reference the source generator by installing a NuGet package: dotnet add package XamlNameReferenceGenerator ``` -Or, if you are using submodules, reference the generator as such: +Or, if you are using [submodules](https://git-scm.com/docs/git-submodule), you can reference the generator as such: ```xml @@ -56,6 +51,8 @@ public partial class SignUpView : Window } ``` + + ### What do the generated sources look like? For the [`SignUpView` view class](https://github.com/avaloniaui/Avalonia.NameGenerator/blob/main/src/Avalonia.NameGenerator.Sandbox/Views/SignUpView.xaml) from [the sandbox project](https://github.com/avaloniaui/Avalonia.NameGenerator/tree/main/Avalonia.NameGenerator.Sandbox), we get the following generated output: