Skip to content

XamlTypeInfo.g.c Trim and Obsolete Warning #10356

@ghost1372

Description

@ghost1372

Describe the bug

After enabling AOT compilation (<PublishAot>true</PublishAot>) in my WinUI 3 project, I encountered several warnings related to XamlTypeInfo.

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Type.TypeInitializer.get'. The parameter 'instance' of method 'PSXMaster.PSXMaster_XamlTypeInfo.XamlTypeInfoProvider.get_127_Type_TypeInitializer(Object)' 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.

'Type.IsSerializable' is obsolete: 'Formatter-based serialization is obsolete and should not be used.'

'TypeAttributes.Serializable' is obsolete: 'Formatter-based serialization is obsolete and should not be used.'

Image

when i double click on warning i navigated to this:

Image

Image

Image

Steps to reproduce the bug

Create a WinUI 3 (Windows App SDK) project.
Enable AOT compilation by adding the following to the .csproj file:
<PublishAot>true</PublishAot>
Build the project.

Expected behavior

The XAML compiler should generate code that is compatible with AOT without triggering trimming-related warnings.
Obsolete serialization APIs should not be used in auto-generated code.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.5: 1.6.250205002

Windows version

Windows 11 (24H2): Build 26100

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions