Skip to content

Generator crash when no matching constructors for an attribute type #938

Open
@asklar

Description

@asklar

Crash in WinRTTypeWriter.AddCustomAttributes when no matching constructors are found (we blindly access matchingConstructor.First())

 	System.Linq.dll!System.Linq.ThrowHelper.ThrowNoElementsException()	Unknown
 	System.Linq.dll!System.Linq.Enumerable.First<Microsoft.CodeAnalysis.IMethodSymbol>(System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.IMethodSymbol> source)	Unknown
>	CsWinMD.dll!Generator.WinRTTypeWriter.AddCustomAttributes(string attributeTypeName, System.Collections.Generic.IList<Microsoft.CodeAnalysis.ITypeSymbol> primitiveTypes, System.Collections.Generic.IList<object> primitiveValues, System.Reflection.Metadata.EntityHandle parentHandle) Line 1717	C#
 	CsWinMD.dll!Generator.WinRTTypeWriter.AddExclusiveToAttribute(System.Reflection.Metadata.EntityHandle interfaceHandle, string className) Line 1578	C#
 	CsWinMD.dll!Generator.WinRTTypeWriter.AddSynthesizedInterface(Generator.TypeDeclaration classDeclaration, Generator.WinRTTypeWriter.SynthesizedInterfaceType interfaceType, System.Collections.Generic.HashSet<Microsoft.CodeAnalysis.ISymbol> classMembersFromInterfaces) Line 2469	C#
 	CsWinMD.dll!Generator.WinRTTypeWriter.AddSynthesizedInterfaces(Generator.TypeDeclaration classDeclaration) Line 2358	C#
 	CsWinMD.dll!Generator.WinRTTypeWriter.AddComponentType(Microsoft.CodeAnalysis.INamedTypeSymbol type, System.Action visitTypeDeclaration) Line 2148	C#
 	CsWinMD.dll!Generator.WinRTTypeWriter.VisitClassDeclaration(Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax node) Line 1344	C#
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.Syntax.ClassDeclarationSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(Microsoft.CodeAnalysis.SyntaxNode node)	Unknown
 	CsWinMD.dll!Generator.ComponentGenerator.Generate() Line 180	C#
 	CsWinMD.dll!Generator.SourceGenerator.Execute(Microsoft.CodeAnalysis.GeneratorExecutionContext context) Line 219	C#

Metadata

Metadata

Assignees

Labels

authoringRelated to authoring feature workbugSomething isn't workingcswinmd

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions