Skip to content

ArgumentNullException on multiple tfms #43

Description

@rgroenewoudt

ArgumentNullException happens when parsing a project containing < TargetFrameworks >

Stacktrace:

>	NuGet.Frameworks.dll!NuGet.Frameworks.NuGetFramework.Parse(string folderName, NuGet.Frameworks.IFrameworkNameProvider mappings) Line 377	C#
 	Snitch.dll!Snitch.Analysis.AnalyzerResultExtensions.GetNearestFrameworkMoniker.AnonymousMethod__0(string x) Line 28	C#
 	System.Linq.dll!System.Linq.Enumerable.ToDictionary<string, NuGet.Frameworks.NuGetFramework, string>(System.Collections.Generic.IEnumerable<string> source, System.Func<string, NuGet.Frameworks.NuGetFramework> keySelector, System.Func<string, string> elementSelector, System.Collections.Generic.IEqualityComparer<NuGet.Frameworks.NuGetFramework> comparer) Line 8144	C#
 	Snitch.dll!Snitch.Analysis.AnalyzerResultExtensions.GetNearestFrameworkMoniker(NuGet.Frameworks.NuGetFramework framework, System.Collections.Generic.IEnumerable<string> candidates) Line 26	C#
 	Snitch.dll!Snitch.Analysis.AnalyzerResultExtensions.GetNearestFrameworkMoniker(System.Collections.Generic.IEnumerable<Buildalyzer.IAnalyzerResult> source, string framework) Line 18	C#
 	Snitch.dll!Snitch.Analysis.ProjectBuilder.Build(Buildalyzer.AnalyzerManager manager, Snitch.Analysis.Project project, string tfm, int indentation) Line 166	C#

Project.TargetFramework and IAnalyzerResult.TargetFramework are null, which causes issues.

Example csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
	<TargetFrameworks>net48;net8.0</TargetFrameworks>
  </PropertyGroup>

</Project>

Metadata

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