Skip to content

Conversation

@jonpryor
Copy link
Contributor

@jonpryor jonpryor commented May 3, 2018

Fixes: #1400

Related: #1421

The mono/corefx xUnit test
TaskSchedulerTests.GetTaskSchedulersForDebugger_ReturnsDefaultScheduler()
fails when built in Release mode:

System.NullReferenceException : Object reference not set to an instance of an object
+++++++++++++++++++
STACK TRACE:
  at System.Threading.Tasks.Tests.TaskSchedulerTests.GetTaskSchedulersForDebugger_ReturnsDefaultScheduler ()

The cause is that the test grabs the MethodInfo for the
TaskScheduler.GetTaskSchedulersForDebugger() method, which the
linker removes -- correctly! as there are no references to it -- and
the test then attempts to invoke the MethodInfo, but the
MethodInfo is null (linked away!), resulting in the
NullReferenceException.

The test should be fixed, but in the meantime we can instead ignore
the xUnit category of this test when building for Release.

Fixes: dotnet#1400

Related: dotnet#1421

The mono/corefx xUnit test
[`TaskSchedulerTests.GetTaskSchedulersForDebugger_ReturnsDefaultScheduler()`][0]
[fails when built in Release mode][1]:

[0]: https://github.com/dotnet/corefx/blob/893708a4c46047af6fb14bc0f2c33b3ca6adc527/src/System.Threading.Tasks/tests/TaskScheduler/TaskSchedulerTests.cs#L293-L301
[1]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/980/testReport/junit/Test%20collection%20for%20System.Threading.Tasks.Tests/TaskSchedulerTests/System_Threading_Tasks_Tests_TaskSchedulerTests_GetTaskSchedulersForDebugger_ReturnsDefaultScheduler___Release/

	System.NullReferenceException : Object reference not set to an instance of an object
	+++++++++++++++++++
	STACK TRACE:
	  at System.Threading.Tasks.Tests.TaskSchedulerTests.GetTaskSchedulersForDebugger_ReturnsDefaultScheduler ()

The cause is that the test grabs the `MethodInfo` for the
`TaskScheduler.GetTaskSchedulersForDebugger()` method, which the
linker removes -- correctly! as there are no references to it -- and
the test then attempts to *invoke* the `MethodInfo`, but the
`MethodInfo` is `null` (linked away!), resulting in the
`NullReferenceException`.

The test should be fixed, but in the meantime we can instead ignore
the xUnit *category* of this test when building for Release.
@jonpryor jonpryor merged commit 81ef825 into dotnet:master May 3, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BCL test 'TaskSchedulerTests.GetTaskSchedulersForDebugger_ReturnsDefaultScheduler' fails when the linker is enabled.

1 participant