roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

ArgumentNullException thrown from CommandLineProject.CreateProjectInfo()

Open huizhonglong opened this issue 10 years ago • 6 comments

Version Used: Latest master Steps to Reproduce: Get a .csproj containing analyzer items that need to be installed via nuget packages. I picked the one in Step 1.

  1. git clone https://github.com/code-cracker/code-cracker.git Now those packages are not installed yet, go straight to step 2.
  2. Generate the command line args for CodeCracker.csproj by executing msbuild target "CoreCompile", with property ProvideCommandLineArgs set as true (Roslyn enables this feature starting Dev14 Update 1) The command line args generated contains /analyzer: with a path that does not exist.
  3. Now try to create a ProjectInfo by calling CommandLineProject.CreateProjectInfo(), passing in the command line args produced in above step

Expected Behavior: Creates the ProjectInfo Actual Behavior: The expected ProjectInfo is not created due to ArgumentNullException thrown: Can't resolve analyzer reference: 'Unresolved: ..........

huizhonglong avatar Mar 04 '16 22:03 huizhonglong

Compiler?

davkean avatar Mar 05 '16 04:03 davkean

@huizhonglong can you post the full message and stack trace of the exception?

This appears to be an analyzer issue. CC @srivatsn

jaredpar avatar Mar 06 '16 15:03 jaredpar

System.ArgumentException occurred HResult=-2147024809 Message=Can't resolve analyzer reference: 'Unresolved: E:\Repos\code-cracker\packages\codecracker.CSharp.1.0.0-rc5-1047\analyzers\dotnet\cs\CodeCracker.Common.dll'. Source=Microsoft.CodeAnalysis.Workspaces.Desktop StackTrace: at Microsoft.CodeAnalysis.CommandLineProject.CreateProjectInfo(String projectName, String language, IEnumerable`1 commandLineArgs, String projectDirectory, Workspace workspace)

Microsoft.CodeAnalysis.Workspaces.Desktop.dll!Microsoft.CodeAnalysis.CommandLineProject.CreateProjectInfo(string projectName, string language, System.Collections.Generic.IEnumerable commandLineArgs, string projectDirectory, Microsoft.CodeAnalysis.Workspace workspace) Line 64 C# Microsoft.VisualStudio.Workspaces.Extensions.dll!Microsoft.VisualStudio.Workspaces.Extensions.CodeUnderstanding.Contexts.ManagedProjectContext.CreateProjectInfo(string workspaceDirectory) Line 113 C# @jaredpar

huizhonglong avatar Mar 07 '16 21:03 huizhonglong

The issue here is that CommandLineProject.CreateProjectInfo() throws an exception when there's an invalid reference or analyzer that's passed in. Moving to IDE since they already have an internal bug tracking the change needed to fix this issue.

srivatsn avatar Mar 07 '16 21:03 srivatsn

Related internal issue for references is 154302.

Pilchie avatar Mar 11 '16 17:03 Pilchie

closing out due to lack of feedback.

CyrusNajmabadi avatar Oct 19 '24 21:10 CyrusNajmabadi