Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authoring component with a class implementing a projected interface breaks source generation with incorrect function #1339

Closed
roxk opened this issue Jun 25, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@roxk
Copy link

roxk commented Jun 25, 2023

Describe the bug
When authoring a component, if a public class implements a projected interface, source generator hard-error and emits 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

  1. Clone roxk/packaged-oop-winrt-server-app-extension@d03f24e. The commit is currently the head of the csharp branch.
  2. Open PackagedOOPWinRTServerAppExtension.sln and build AppExtensionCSharp
  3. Observe warning CS8785 and compile error.

image

Expected behavior
It builds successfully. AppExtensionCSharp.WidgetProvider should implement SDK.IWidgetProvider in the generated winmd.

Version Info

  <PropertyGroup>
	<OutputType>WinExe</OutputType>
	<TargetFramework>net6.0-windows10.0.22621.0</TargetFramework>
	<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
	<Platforms>x64</Platforms>
	<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.3" />
  </ItemGroup>

Additional context

  1. Adding another internal class that implements projected interface works fine. It's only when the class is public (i.e. included in the generated winmd) source generator would freak out.
  2. I'm working on a sample of implementing app extension point via OOP WinRT Server, to replace OOP COM Server. This bug is a show-stopper for C#. C++ as found in the repo above is working as expected.
@manodasanW
Copy link
Member

manodasanW commented Jul 14, 2023

@roxk Thanks for the repro. The issue is the WinRT authoring source generator needs to be able to find the WinMDs for any referenced components. In this case, it is failing to find the SDK component's WinMD due to it is not included in the referenced NuGet. If you include it in the referenced NuGet by doing something like below in the nuspec, you should see it build without issues. Feel free to reopen if you still run into issues.

<file src="..\..\x64\Release\SDK\SDK.winmd" target="lib\net6.0-windows10.0.22621.0\SDK.winmd" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants