Skip to content

Deriving from FluentTheme triggers AVLN3000 error #21007

@vpenades

Description

@vpenades

Describe the bug

I am trying to create a custom theme, deriving from Fluent theme

public partial class CustomTheme : FluentTheme
{
    public CustomTheme (IServiceProvider? sp = null)
        : base(sp) // notice I am calling the base class constructor
        { }
}

The code above triggers this error:

AVL3000 No call to AvaloniaXamlLoader.Load(this) call found anywhere in the type ... and type seems to have custom constructors.

Which is produced by the check located here:

The problem is that the code above checks for an explicit call to AvaloniaXamlLoader.Load(this); but does not check if the constructor calls :base() which in turns calls the xaml loader.

This results in producing an error that prevents build to complete, when the code is correct.

To Reproduce

public partial class CustomTheme : FluentTheme
{
    public CustomTheme (IServiceProvider? sp = null)
        : base(sp)
        { }
}

Expected behavior

I expect the validation to check the code is correct and let it compile.

Avalonia version

11.3.12

OS

No response

Additional context

Not sure which would be the solution to fix this,

Ideally it should check for derived class calling the base constructor as an additional valid pattern.

Id that's too complex, maybe change the validation from error to warning, so it could be possible to use #pragma warning disable

Right now the only way I've found to circunvent this is adding the AvaloniaXamlLoader.Load(sp, this); to the constructor body, but this is effectively loading the xaml content twice.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions