Skip to content

Generation fails when the EventSource Interface contains a collection parameter #24

Open
@gmiserez

Description

Hi,

We have an interface that contains a method which has a parameter that is a collection.

[EventSourceDefinition(Name = "xxx")]
public interface IXXXEventSource
{
    [Event(1, Level = EventLevel.Warning,
        Message = "XXX", Version = 4)]
    void SomeXXXs(List<string> xxxs);
}

The Thor Generator v1.3.3 currently fails to generate the class for this interface. We get the following error in the console output:

Processing \src\EventSources\EventSources.csproj -> \src\EventSources\EventSources.csproj ...
1>
1>Unhandled Exception: System.ArgumentNullException: Value cannot be null.
1>Parameter name: type
1> at Thor.Generator.Templates.ModelExtensions.AddParameter(EventModel eventModel, String name, String type) in C:\thor\generator\src\Generator\Templates\ModelExtensions.cs:line 65
1> at Thor.Generator.Templates.EventSourceDefinitionVisitor.VisitMethodDeclaration(MethodDeclarationSyntax node) in C:\thor\generator\src\Generator\Templates\EventSourceDefinitionVisitor.cs:line 85
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.DefaultVisit(SyntaxNode node)
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxWalker.Visit(SyntaxNode node)
1> at Thor.Generator.EventSourceResolver.d__3.MoveNext() in C:\thor\generator\src\Generator\EventSourceResolver.cs:line 33
1> at Thor.Generator.EventSourceGenerator.Generate() in C:\thor\generator\src\Generator\EventSourceGenerator.cs:line 39
1> at Thor.Generator.Tasks.EventSourceGeneratorTaskBase.GenerateEventSources(Project source, Project target) in C:\thor\generator\src\Generator\Tasks\EventSourceGeneratorTaskBase.cs:line 123
1> at Thor.Generator.Tasks.ProjectEventSourceGeneratorTask.Execute() in C:\thor\generator\src\Generator\Tasks\ProjectEventSourceGeneratorTask.cs:line 77
1> at Thor.Generator.CLI.Program.Main(String[] args) in C:\thor\generator\src\Generator.CLI\Program.cs:line 20
1> .nuget\packages\thor.generator\1.3.3\build\Thor.Generator.targets(16,5): error MSB3073: The command "".nuget\packages\thor.generator\1.3.3\build..\tools\win10-x64\thorgen.exe" project -s "\src\EventSources\EventSources.csproj" -t "\src\EventSources\EventSources.csproj"" exited with code -532462766.
1>Done building project "EventSources.csproj" -- FAILED.

There is an easy workaround for this issue: use a wrapper class around the collection and have the parameter be of that type.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions