Skip to content

[GeneratedComInterface] Produces SYSLIB1051 in WinUI3 project even though I have DisableRuntimeMarshalling=true #51159

@jevansaks

Description

@jevansaks

Description

In a WinUI3 project I get errors telling me that I need to set DisableRuntimeMarshalling but I have done so. And if I add [assembly:DisableRuntimeMarshalling] then I get a "duplicate attribute defined" later during compile.

Reproduction Steps

I pushed a repro up here: https://github.com/jevansaks/WinUI3ComGeneratorsRepro

But the repro is:

  1. File => New Project "WinUI Blank App (Packaged)"
  2. Add this to the csproj:
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <PublishAot>true</PublishAot>
    <DisableRuntimeMarshalling>true</DisableRuntimeMarshalling>
  1. Add this to app.xaml.cs:
    [Guid("00000000-0000-0000-0000-000000000003"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), GeneratedComInterface]
    public partial interface IRepro
    {
        void Test(global::System.Drawing.Point pt);
    }

Expected behavior

Compiles.

Actual behavior

Gives a confusing error:

App.xaml.cs(33,48,33,50): error SYSLIB1051: Runtime marshalling must be disabled in this project by applying the 'System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute' to the assembly to enable marshalling this type. The generated source will not handle marshalling of parameter 'pt'. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1051)

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

This seems to be because XamlPreCompile doesn't get all the things passed to it that CoreCompile does. Again. Why does this target exist? :)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions