question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ArgumentException when whitespace sent to logger

See original GitHub issue

This is related to https://github.com/nunit/nunit3-vs-adapter/issues/220. The previous fix was to send a single space when there was no text in the message, but TestSessionMessageLogger checks for IsNullOrWhitespace and throws an ArgumentException if the message is null or only whitespace, (https://github.com/Microsoft/vstest/blob/master/src/Microsoft.TestPlatform.Common/Logging/TestSessionMessageLogger.cs#L65) which means sending the single space causes an argument exception.

These are the versions we are referencing:

<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
<PackageReference Include="NUnitLite" Version="3.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta6" />

We use nunit to run unit tests for IronPython. Cloning https://github.com/IronLanguages/ironpython2 and running make.ps1 then make.ps1 test-test_macurl2path will show the issue. I worked around this in a local build of the adapter by implementing my own IsNullOrWhiteSpace (since the adapter is being built with a framework prior to IsNullOrWhiteSpace) and didn’t send the message if it is null or only whitespace.

This is the output we see from tests:

.\make.ps1 test-test_macurl2path
WARNING: No tests available for 'test_macurl2path' trying to run single test 'net45.test_macurl2path'
dotnet test C:\Users\USER\Code\_ipy\ironpython2/Src/IronPythonTest/IronPythonTest.csproj -f net45 -o C:\Users\USER\Code\_ipy\ironpython2/bin/Release/net45 -c Release --no-build -l trx;LogFileName=single-net45-Release-result.trx -s C:\Users\USER\Code\_ipy\ironpython2\Src\IronPythonTest\runsettings.xml --filter="Name=net45.test_macurl2path"
Microsoft (R) Build Engine version 15.7.177.53362 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 160.02 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\DLR\Src\Microsoft.Scripting\Microsoft.Scripting.csproj.
  Restore completed in 156.32 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\DLR\Src\Microsoft.Scripting.Metadata\Microsoft.Scripting.Metadata.csproj.
  Restore completed in 175.2 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\DLR\Src\Microsoft.Dynamic\Microsoft.Dynamic.csproj.
  Restore completed in 160.26 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\DLR\Tests\ClrAssembly\ClrAssembly.csproj.
  Restore completed in 48.03 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\IronPython\IronPython.csproj.
  Restore completed in 118 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\IronPythonTest\IronPythonTest.csproj.
Test run for C:\Users\USER\Code\_ipy\ironpython2\bin\Release\net45\IronPythonTest.dll(.NETFramework,Version=v4.5)
Microsoft (R) Test Execution Command Line Tool Version 15.7.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
test_macurl2path
.
.
Error processing test-output event for
System.ArgumentException: The parameter cannot be null or empty.
Parameter name: message
   at Microsoft.VisualStudio.TestPlatform.Common.Logging.TestSessionMessageLogger.SendMessage(TestMessageLevel testMessageLevel, String message)
   at NUnit.VisualStudio.TestAdapter.NUnitEventListener.OnTestEvent(String report)
----------------------------------------------------------------------
Error processing test-output event for
System.ArgumentException: The parameter cannot be null or empty.
Parameter name: message
   at Microsoft.VisualStudio.TestPlatform.Common.Logging.TestSessionMessageLogger.SendMessage(TestMessageLevel testMessageLevel, String message)
   at NUnit.VisualStudio.TestAdapter.NUnitEventListener.OnTestEvent(String report)
Ran 2 tests in 0.159s
Error processing test-output event for
System.ArgumentException: The parameter cannot be null or empty.
Parameter name: message
   at Microsoft.VisualStudio.TestPlatform.Common.Logging.TestSessionMessageLogger.SendMessage(TestMessageLevel testMessageLevel, String message)
   at NUnit.VisualStudio.TestAdapter.NUnitEventListener.OnTestEvent(String report)
Error processing test-output event for
System.ArgumentException: The parameter cannot be null or empty.
Parameter name: message
   at Microsoft.VisualStudio.TestPlatform.Common.Logging.TestSessionMessageLogger.SendMessage(TestMessageLevel testMessageLevel, String message)
   at NUnit.VisualStudio.TestAdapter.NUnitEventListener.OnTestEvent(String report)
OK
Error processing test-output event for
System.ArgumentException: The parameter cannot be null or empty.
Parameter name: message
   at Microsoft.VisualStudio.TestPlatform.Common.Logging.TestSessionMessageLogger.SendMessage(TestMessageLevel testMessageLevel, String message)
   at NUnit.VisualStudio.TestAdapter.NUnitEventListener.OnTestEvent(String report)
WARNING: Overwriting results file: C:\Users\USER\Code\_ipy\ironpython2\Src\IronPythonTest\TestResults\single-net45-Release-result.trx
Results File: C:\Users\USER\Code\_ipy\ironpython2\Src\IronPythonTest\TestResults\single-net45-Release-result.trx

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 22.1010 Seconds

We see this on both net45 and netcoreapp2.0

/cc @slozier

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:24 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
OsirisTerjecommented, Oct 18, 2021

@mthjones Thanks and very nice! I’ll make a repro and check if this fixes it.

1reaction
mikkelbucommented, Feb 24, 2021

@kswoll Can you include a minimal test showing the problem, as I cannot make it fail. E.g. the following works on my machine

        [Test]
        public void TestConsoleWriteLine()
        {
            Console.WriteLine();
            Console.WriteLine("a");
            Console.WriteLine((string)null);
            Console.WriteLine("b");
            Console.WriteLine(" ");
        }
Read more comments on GitHub >

github_iconTop Results From Across the Web

The argument 'name' cannot be null, empty or contain only ...
ArgumentException : The argument 'name' cannot be null, empty or contain only white space. at System.ComponentModel.DataAnnotations.Schema.
Read more >
ArgumentException Class (System)
ArgumentException is thrown when a method is invoked and at least one of the passed arguments does not meet the parameter specification of...
Read more >
Adapter V4 Release Notes
This is a bug fix release, with the following fixes: 516 ArgumentException when whitespace sent to logger. Thanks to Matt Jones - mthjones...
Read more >
Error: [The file name is empty or contains only whitespace ...
You see the following error in the Event Log: ... ArgumentException: The file name is empty or contains only whitespace.
Read more >
Save As GoldMine Linked Document button does nothing ...
Errors this session: System.ArgumentException: Path cannot be the empty string or all whitespace. at System.IO.Directory.CreateDirectory(String ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found