Skip to content

Warnings and errors when publishing a .NET 8 app as NativeAOT #367

@Numpsy

Description

@Numpsy

This is a sort of followup to #281, but with a few FuncUI specific warnings in the build that might have local solutions, so -

I tried updating a FuncUI app to .NET 8 and publishing as NativeAOT with the RC2 SDK.
There are alas loads of warnings from FSharp.Core that are outside our control, but also these ones from FuncUI:

4>Avalonia.FuncUI.VirtualDom.Patcher.patchProperty(AvaloniaObject,Delta.PropertyDelta): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
4>Avalonia.FuncUI.VirtualDom.Patcher.patchProperty(AvaloniaObject,Delta.PropertyDelta): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The return value of method 'System.Reflection.PropertyInfo.PropertyType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
4>Avalonia.FuncUI.VirtualDom.Patcher.create(Delta.ViewDelta): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Activator.CreateInstance(Type,Object[])'. The field 'Avalonia.FuncUI.VirtualDom.Delta.ViewDelta.ViewType@' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
4>Avalonia.FuncUI.VirtualDom.Patcher.create(Delta.ViewDelta): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Activator.CreateInstance(Type)'. The field 'Avalonia.FuncUI.VirtualDom.Delta.ViewDelta.ViewType@' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

and then this happens at runtime:

Unhandled Exception: System.MissingMethodException: No parameterless constructor defined for type 'Avalonia.FuncUI.Component'.
   at System.ActivatorImplementation.CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo, Object[]) + 0x34b
   at Avalonia.FuncUI.VirtualDom.Patcher.create(Delta.ViewDelta) + 0x5e
   at Avalonia.FuncUI.VirtualDom.Patcher.patch_avalonia@167(FSharpOption`1, AvaloniaObject, AvaloniaProperty) + 0x72
   at Avalonia.FuncUI.VirtualDom.Patcher.patchContentSingle(AvaloniaObject, Types.Accessor, FSharpOption`1) + 0x82
   at Avalonia.FuncUI.VirtualDom.Patcher.create(Delta.ViewDelta) + 0x145
   at Avalonia.FuncUI.VirtualDom.VirtualDom.updateBorderRoot(Border, FSharpOption`1, FSharpOption`1) + 0x176
   at Avalonia.FuncUI.Component.UIThreadUpdate() + 0x6a
   at Avalonia.StyledElement.InitializeIfNeeded() + 0x2a
   at Avalonia.Controls.Control.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs) + 0x8d
   at Avalonia.Visual.SetVisualParent(Visual) + 0xe5
   at Avalonia.Visual.SetVisualParent(IList, Visual) + 0x6c
   at Avalonia.Collections.AvaloniaList`1.NotifyAdd(T, Int32) + 0x72
   at Avalonia.Controls.Presenters.ContentPresenter.UpdateChild(Object) + 0x1c7
   at Avalonia.Layout.Layoutable.MeasureCore(Size) + 0x12e
   at Avalonia.Layout.Layoutable.Measure(Size) + 0xf0
   at Avalonia.Layout.LayoutHelper.MeasureChild(Layoutable, Size, Thickness) + 0xa0
   at Avalonia.Controls.Primitives.VisualLayerManager.MeasureOverride(Size) + 0xb4
   at Avalonia.Layout.Layoutable.MeasureCore(Size) + 0x19f
   at Avalonia.Layout.Layoutable.Measure(Size) + 0xf0
   at Avalonia.Layout.Layoutable.MeasureOverride(Size) + 0x7f
   at Avalonia.Layout.Layoutable.MeasureCore(Size) + 0x19f
   at Avalonia.Layout.Layoutable.Measure(Size) + 0xf0
   at Avalonia.Layout.Layoutable.MeasureOverride(Size) + 0x7f
   at Avalonia.Controls.Window.MeasureOverride(Size) + 0x1d1
   at Avalonia.Controls.WindowBase.MeasureCore(Size) + 0x5c
   at Avalonia.Layout.Layoutable.Measure(Size) + 0xf0
   at Avalonia.Layout.LayoutManager.Measure(Layoutable) + 0xc2
   at Avalonia.Layout.LayoutManager.ExecuteInitialLayoutPass() + 0x27
   at Avalonia.Controls.Window.ShowCore(Window) + 0x1f9
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.ShowMainWindow() + 0x1b
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[]) + 0x139
   at PackageViewer!<BaseAddress>+0xf6d860

Which suggests that the existing DynamicallyAccessedMembers attributes aren't covering all required cases.

Also, some of this might be hitting the existing TODO here about not using reflection:

// TODO: get rid of reflection here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions