CsWinRT
CsWinRT copied to clipboard
Source generator error should result in build failure
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
- Create CppWinRT module defining
Interface1 - Create CsWinRT projection of module from step 1
- Create CsWinRT authoring module consuming projection from step 2
a. Define
Interface2b. Create class that implements bothInterface1andInterface2 - Call
GetIidson class object and note thatInterface1is present, butInterface2is 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" />
See #1202