Skip to content

Authoring generator throws Win32Exception for methods with WindowId parameters #1428

@Sergio0694

Description

@Sergio0694

Describe the bug

Just noticed the following failure when using WindowId as a parameter for a method:

"CSC : warning CS8785: Generator 'SourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'Win32Exception' with message 'Incorrect function'."

To Reproduce

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
    <Platforms>x64;ARM64</Platforms>
    <CsWinRTComponent>true</CsWinRTComponent>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" />
  </ItemGroup>
</Project>
using Windows.UI;

namespace MinimalWinRTComponentTest;

public sealed partial class MyClass
{
    public void Test(WindowId id)
    {
    }
}

Expected behavior

Should work fine..?

Version Info

  • Latest AOT previews for CsWinRT and Windows SDK (as of January 6th 2024)
  • Also reproes on normmal 2.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    authoringRelated to authoring feature workbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions