AvaloniaUI / Avalonia.Markup.Declarative

Provides helpers for declarative ui in C#
372 stars 21 forks source link

Source generators not working with TemplatedControl #48

Closed tomasmalik closed 3 months ago

tomasmalik commented 3 months ago

I'm using the NuGet package Avalonia.Markup.Declarative v11.0.11, and the source generators aren't generating markup extensions for my custom templated controls. I also tried copying MyCustomTemplatedControl.cs from the samples folder, but it didn't work either.

IDE: Visual Studio 2022 (v17.10.4), VSCode (v1.91.1)

Thank you in advance.

gritsenko commented 3 months ago

Hey @tomasmalik! Source generator is processing only controls that implement IDeclarativeViewBase interface. So you should add it to your class declaration.

public class MyCustomTemplatedControl : TemplatedControl, IDeclarativeViewBase
{
...
}
tomasmalik commented 3 months ago

That was exactly it! Thank you for all your work on this awesome library @gritsenko.