CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

Source generator error should result in build failure

Open JohnMcPMS opened this issue 2 years ago • 1 comments

Describe the bug This error in the source generator did not result in a build failure. The resulting binary worked fine for a simple use case, but failed to work when attempting to use the interface authored in the component.

output: C:\Users\VssAdministrator\AppData\Local\Temp\CsWinRT\h15fvp31.aa2
error: 'Type '<INTERFACE FROM C++/WinRT PROJECTION>' could not be found' when processing <TYPE IMPLEMENTING IT IN C#/WinRT>
 error: Type '<INTERFACE FROM C++/WinRT PROJECTION>' could not be found


System.ComponentModel.Win32Exception (0x80004005): Incorrect function
   at Generator.ComponentGenerator.GenerateSources()
   at Generator.ComponentGenerator.Generate()

Additionally, it would be great if CsWinRT could find the .winmd through the project system, but it took far longer to root cause the "it built but it didn't work" than it did to pass along the proper .winmd through the documented project properties.

To Reproduce

  1. Create CppWinRT module defining Interface1
  2. Create CsWinRT projection of module from step 1
  3. Create CsWinRT authoring module consuming projection from step 2 a. Define Interface2 b. Create class that implements both Interface1 and Interface2
  4. Call GetIids on class object and note that Interface1 is present, but Interface2 is not

Note that if the step 1 .winmd can be found, the source generator error does not happen and things work properly.

Expected behavior If there is an error in the source generator, the build should fail.

Version Info

    <PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.1" />

JohnMcPMS avatar Jun 28 '23 23:06 JohnMcPMS

See #1202

asklar avatar Jun 27 '24 21:06 asklar