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

component authoring fails with unhelpful error if no TargetFrameworkVersion is set #1593

Open
stevenbrix opened this issue Apr 29, 2024 · 0 comments
Labels
authoring Related to authoring feature work bug Something isn't working

Comments

@stevenbrix
Copy link
Contributor

stevenbrix commented Apr 29, 2024

Since there aren't default templates for creating runtime components, one has to start with a regular class library and start modifying the .csproj from there. if you don't set the TargetFramework correctly to something like net8.0-windows10.0.19041.0 you'll get random errors. instead, the error isn't helpful and if you enable logging, the log file just shows this:

Generating assembly AppService version 1.0.0.0
Found 1 types
defining type: Class AppService.Class1
writing custom mapped interfaces for AppService.Class1
add method from symbol: .ctor
custom mapping System.Object to System.Object from mscorlib
attribute type found 
adding attribute type
System.NullReferenceException: Object reference not set to an instance of an object.
   at Generator.WinRTTypeWriter.AddType(INamedTypeSymbol type, Boolean treatAsProjectedType)
   at Generator.WinRTTypeWriter.AddCustomAttributes(String attributeTypeName, IList`1 primitiveTypes, IList`1 primitiveValues, EntityHandle parentHandle)
   at Generator.WinRTTypeWriter.AddActivatableAttribute(EntityHandle parentHandle, UInt32 version, String factoryInterface)
   at Generator.WinRTTypeWriter.AddComponentType(INamedTypeSymbol type, Action visitTypeDeclaration)
   at Generator.WinRTTypeWriter.VisitClassDeclaration(ClassDeclarationSyntax node)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
   at Generator.ComponentGenerator.Generate()

To Reproduce

  1. create .NET8 class library
  2. add package reference to cswinrt
  3. set <CSWinRTComponent>true</CSWinRTComponent> in the csproj
  4. change TargetFramework to net8.0-windows
  5. build

Expected behavior
this would provide an error that the project isn't configured correctly

Version Info
2.0.7

@stevenbrix stevenbrix added the bug Something isn't working label Apr 29, 2024
@manodasanW manodasanW added the authoring Related to authoring feature work label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authoring Related to authoring feature work bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants