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

Regression: NullReferenceException thrown when argument customization is not provided. #6

Closed
Romanx opened this issue Sep 4, 2018 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Romanx
Copy link
Owner

Romanx commented Sep 4, 2018

Seems to surface like #3 although could be something different.

@Romanx Romanx added the bug Something isn't working label Sep 4, 2018
@Romanx Romanx added this to the 1.2.2 milestone Sep 4, 2018
@Romanx Romanx self-assigned this Sep 4, 2018
@anthony-roe-cko
Copy link

Hi the stacktrace is below:

System.NullReferenceException: Object reference not set to an instance of an object. at Cake.Coverlet.CoverletAliases.<>c__DisplayClass0_0.<DotNetCoreTest>b__0(ProcessArgumentBuilder args) at Cake.Core.Tooling.Tool1.RunProcess(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings)
at Cake.Core.Tooling.Tool1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action1 postAction)
at Cake.Common.Tools.DotNetCore.Test.DotNetCoreTester.Test(String project, DotNetCoreTestSettings settings)
at Submission#0.DotNetCoreTest(FilePath project, DotNetCoreTestSettings settings, CoverletSettings coverletSettings)
at Submission#0.<>b__0_2()
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass20_0.b__0(ICakeContext x)
at Cake.Core.CakeTask.d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.DefaultExecutionStrategy.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.d__30.MoveNext()`

@ctcoulter
Copy link

I haven't had a chance to pull it down and check and am not at a computer, but at first glance it looks like the null check needs to happen in ProcessArguments as well before trying to use the builder.

@ctcoulter
Copy link

whoops.. posted stack trace info in wrong issue...

Settings:

Task("Test").Does(() => 
{
    foreach (var project in testProjects) 
    {
        var projectName = project.GetFilenameWithoutExtension().ToString();
        
        var testSettings = new DotNetCoreTestSettings 
        {
            Configuration = configuration,
            NoBuild = true,
            NoRestore = true,
            Logger = $"trx;LogFileName={projectName}.TestResults.xml",
            ResultsDirectory = distDir,
            //ArgumentCustomization = (args) => args
        };

        var coverletSettings = new CoverletSettings 
        {
            CollectCoverage = true,
            CoverletOutputFormat = CoverletOutputFormat.opencover,
            CoverletOutputDirectory = distDir,
            CoverletOutputName = $"{projectName}.Coverage.xml"
        };

        DotNetCoreTest(project.ToString(), testSettings, coverletSettings);
    }
});

Stack trace:

Executing task: Test
An error occurred when executing task 'Test'.
Error: System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Cake.Coverlet.CoverletAliases.<>c__DisplayClass0_0.<DotNetCoreTest>b__0(ProcessArgumentBuilder args) in C:\projects\cake-coverlet\src\Cake.Coverlet\CoverletAliases.cs:line 35
   at Cake.Core.Tooling.Tool`1.RunProcess(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings) in C:\projects\cake\src\Cake.Core\Tooling\Tool.cs:line 166
   at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction) in C:\projects\cake\src\Cake.Core\Tooling\Tool.cs:line 101
   at Submission#0.DotNetCoreTest(FilePath project, DotNetCoreTestSettings settings, CoverletSettings coverletSettings)
   at Submission#0.<<Initialize>>b__0_2()
   at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass20_0.<Does>b__0(ICakeContext x) in C:\projects\cake\src\Cake.Core\CakeTaskBuilder.Execution.cs:line 82
   at Cake.Core.CakeTask.Execute(ICakeContext context) in C:\projects\cake\src\Cake.Core\CakeTask.cs:line 125
   at Cake.Core.DefaultExecutionStrategy.ExecuteAsync(CakeTask task, ICakeContext context) in C:\projects\cake\src\Cake.Core\DefaultExecutionStrategy.cs:line 87
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report) in C:\projects\cake\src\Cake.Core\CakeEngine.cs:line 336
   at Cake.Core.CakeEngine.RunTask(ICakeContext context, IExecutionStrategy strategy, CakeTask task, String target, Stopwatch stopWatch, CakeReport report) in C:\projects\cake\src\Cake.Core\CakeEngine.cs:line 284
   at Cake.Core.CakeEngine.RunTargetAsync(ICakeContext context, IExecutionStrategy strategy, ExecutionSettings settings) in C:\projects\cake\src\Cake.Core\CakeEngine.cs:line 247
   at Cake.Scripting.BuildScriptHost.RunTargetAsync(String target) in C:\projects\cake\src\Cake\Scripting\BuildScriptHost.cs:line 47
   at Cake.Core.Scripting.ScriptHost.RunTarget(String target) in C:\projects\cake\src\Cake.Core\Scripting\ScriptHost.cs:line 191
   at Submission#0.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.Script`1.RunSubmissionsAsync(ScriptExecutionState executionState, ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script) in C:\projects\cake\src\Cake\Scripting\Roslyn\RoslynScriptSession.cs:line 129
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments) in C:\projects\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 212
   at Cake.Commands.BuildCommand.Execute(CakeOptions options) in C:\projects\cake\src\Cake\Commands\BuildCommand.cs:line 41
   at Cake.CakeApplication.Run(CakeOptions options) in C:\projects\cake\src\Cake\CakeApplication.cs:line 45
   at Cake.Program.Main() in C:\projects\cake\src\Cake\Program.cs:line 73
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
   at Cake.Coverlet.CoverletAliases.<>c__DisplayClass0_0.<DotNetCoreTest>b__0(ProcessArgumentBuilder args) in C:\projects\cake-coverlet\src\Cake.Coverlet\CoverletAliases.cs:line 35
   at Cake.Core.Tooling.Tool`1.RunProcess(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings) in C:\projects\cake\src\Cake.Core\Tooling\Tool.cs:line 166
   at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction) in C:\projects\cake\src\Cake.Core\Tooling\Tool.cs:line 101
   at Submission#0.DotNetCoreTest(FilePath project, DotNetCoreTestSettings settings, CoverletSettings coverletSettings)
   at Submission#0.<<Initialize>>b__0_2()
   at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass20_0.<Does>b__0(ICakeContext x) in C:\projects\cake\src\Cake.Core\CakeTaskBuilder.Execution.cs:line 82
   at Cake.Core.CakeTask.Execute(ICakeContext context) in C:\projects\cake\src\Cake.Core\CakeTask.cs:line 125
   at Cake.Core.DefaultExecutionStrategy.ExecuteAsync(CakeTask task, ICakeContext context) in C:\projects\cake\src\Cake.Core\DefaultExecutionStrategy.cs:line 87
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report) in C:\projects\cake\src\Cake.Core\CakeEngine.cs:line 336
   at Cake.Core.CakeEngine.RunTask(ICakeContext context, IExecutionStrategy strategy, CakeTask task, String target, Stopwatch stopWatch, CakeReport report) in C:\projects\cake\src\Cake.Core\CakeEngine.cs:line 284
   at Cake.Core.CakeEngine.RunTargetAsync(ICakeContext context, IExecutionStrategy strategy, ExecutionSettings settings) in C:\projects\cake\src\Cake.Core\CakeEngine.cs:line 247
   at Cake.Scripting.BuildScriptHost.RunTargetAsync(String target) in C:\projects\cake\src\Cake\Scripting\BuildScriptHost.cs:line 47
   at Cake.Core.Scripting.ScriptHost.RunTarget(String target) in C:\projects\cake\src\Cake.Core\Scripting\ScriptHost.cs:line 191
   at Submission#0.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Scripting.Script`1.RunSubmissionsAsync(ScriptExecutionState executionState, ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, Func`2 catchExceptionOpt, CancellationToken cancellationToken)<---

If I remove the comment for the ArgumentCustomization setting, it works just fine (as mentioned earlier in thread).

@Romanx
Copy link
Owner Author

Romanx commented Sep 4, 2018

Hi there,

Took me awhile to get to the bottom of this. It seems while making the change for #5 I managed to somehow get a tag on a version of code that doesn't exist but got pushed remote and overwritten after a bad merge. This code got pushed to nuget and only had half of my actual changes. The odd phantom commit can be found here.

Since i use git versioning to determine my scheme i've bumped the version to 1.3 to make sure people should pull the new version however it has no actual new changes but should fix this regression.

Hopefully that makes some sense, please report back if you have any issues or just to confirm it's fixed.

Thanks,

@Romanx Romanx closed this as completed Sep 4, 2018
@anthony-roe-cko
Copy link

All seems good now @Romanx thanks for the very quick fix 👍

@Romanx
Copy link
Owner Author

Romanx commented Sep 5, 2018

You're more than welcome, thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants