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

Running tool in Azure Pipelines will throw exception #6

Closed
wterpstra opened this issue Apr 22, 2021 · 6 comments · Fixed by #9
Closed

Running tool in Azure Pipelines will throw exception #6

wterpstra opened this issue Apr 22, 2021 · 6 comments · Fixed by #9

Comments

@wterpstra
Copy link
Contributor

When running the tool in Azure Pipelines to inspect my repository it throws the following exception:

Command I run:

dotnet affected -p $(System.DefaultWorkingDirectory) --from origin/develop generate --output $(System.DefaultWorkingDirectory)\changed.proj
Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at System.CommandLine.Rendering.Views.ScreenView.Render(Region region)
   at Affected.Cli.Views.ViewRenderingContext.Render(View rootView) in C:\Projects\dotnet-affected\src\dotnet-affected\Views\ViewRenderingContext.cs:line 29
   at Affected.Cli.Commands.GenerateCommand.GenTraversalHandler(IConsole console, String output, CommandExecutionData data, ViewRenderingContext renderingContext) in C:\Projects\dotnet-affected\src\dotnet-affected\Commands\GenerateCommand.cs:line 71
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass27_0.<<UseVersionOption>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__24_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseDebugDirective>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()

It looks like the System.CommandLine.Rendering package cannot handle the way that Azure DevOps handles the stdout.

@wterpstra
Copy link
Contributor Author

I did some further investigation and when I output straight to the IConsole it does work.

@leonardochaia
Copy link
Owner

Hi @wterpstra ! I'm sorry I haven't been able to spend some time on this one.

screen.Render(Region.EntireTerminal);

I'm not really sure what's going on TBH but maybe changing the Region we provide here might have something to do with it?
I don't really know.

If we can determine it's an issue with CommandLine.Rendering then we should file an issue there.
We can definitively remove it for now if its giving us problems, however I think view-related the code looks much cleaner using it.

@wterpstra
Copy link
Contributor Author

Hi @leonardochaia, no worries. I have both tried Region.EntireTerminal and Region.Scrolling. When I find the time I can try to extract a simplified reproduction of the issue and raise an issue with the CommandLine.Rendering folks. I'll reference this issue to keep track. I agree that the code looks much cleaner this way.

@leonardochaia
Copy link
Owner

leonardochaia commented Jul 7, 2021

Hey @wterpstra! Just wanted you to know that I'm be building an Azure Pipelines where I'm using the current deployed version (1.0.0-preview-1) of dotnet-affected which works fine, since it is not using the ComandLine.Rendering stuff.

I wanted to ask you if you can give me more info of the stuff you have tried, so that we don't duplicate effort.
I'm planning merging #5, figure out #1 and deploy a new preview release.

@leonardochaia
Copy link
Owner

leonardochaia commented Jul 8, 2021

All right, managed to reproduce it in this GitHub build.

The fix came from here

leonardochaia added a commit that referenced this issue Jul 8, 2021
Run tool in CI pipeline.
Fix NRE when piping output 
Fixes #6
@leonardochaia
Copy link
Owner

Hey @wterpstra, I've released v1.0.0-preview-3 which includes the fix.

I've tested in Azure DevOps and it seems to be working fine.

So perhaps with the --solution-path and this fix you could give v1.0.0-preview-3 and report back? :)

Thanks for the help bud!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants