Skip to content

.Net 8 Support xUnit - Harmony -> MonoMod Dependency #434

Description

@MarcoVdE

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

Running dotnet test will result in an error:

[xUnit.net 00:00:00.20] Unable to patch XunitTestRunner's Void .ctor(Xunit.Abstractions.ITest, Xunit.Sdk.IMessageBus, System.Type, System.Object[], System.Reflection.MethodInfo, System.Object[], System.String, System.Collections.Generic.IReadOnlyList`1[Xunit.Sdk.BeforeAfterTestAttribute], Xunit.Sdk.ExceptionAggregator, System.Threading.CancellationTokenS
ource): System.TypeInitializationException: The type initializer for 'MonoMod.Utils.DMDEmitDynamicMethodGenerator' threw an exception.
 ---> System.InvalidOperationException: Cannot find returnType fieeld on DynamicMethod
   at MonoMod.Utils.DMDEmitDynamicMethodGenerator..cctor()
   --- End of inner exception stack trace ---
   at MonoMod.Utils.DMDEmitDynamicMethodGenerator.GenerateCore(DynamicMethodDefinition dmd, Object context)
   at MonoMod.Utils.DMDGenerator`1.Generate(DynamicMethodDefinition dmd, Object context)
   at MonoMod.Utils.DynamicMethodDefinition.Generate(Object context)
   at MonoMod.Utils.DynamicMethodDefinition.Generate()
   at HarmonyLib.MethodPatcher.CreateReplacement(Dictionary`2& finalInstructions)
   at HarmonyLib.PatchFunctions.UpdateWrapper(MethodBase original, PatchInfo patchInfo)
   at HarmonyLib.PatchProcessor.Patch()
   at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer)
   at Allure.XUnit.AllureXunitPatcher.PatchXunitTestRunnerCtors(Harmony patcher)
[xUnit.net 00:00:00.20] No constructors of XunitTestRunner were pathched. Some theories may miss their parameters in the report

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

Run dotnet test with an xUnit project in .net 8

What is the expected behavior?

Report is generated

What is the motivation / use case for changing the behavior?

Support .Net 8, make others aware that base dependency needs to be updated to support it.

Please tell us about your environment:

  • Allure version: 2.10.0
  • Test framework: xunit@2.6.2
  • Allure adaptor: allure-xunit@2.10.0
  • Generate report using: dotnet test for a .Net 8 project

Other information

I cloned the project, started updating dependencies, testing with .net 8, and have found this error:

OneTimeSetUp: System.TypeInitializationException : The type initializer for 'MonoMod.Utils.DMDEmitDynamicMethodGenerator' threw an exception.
  ----> System.InvalidOperationException : Cannot find returnType fieeld on DynamicMethod
   at MonoMod.Utils.DMDEmitDynamicMethodGenerator.GenerateCore(DynamicMethodDefinition dmd, Object context)
   at MonoMod.Utils.DMDGenerator`1.Generate(DynamicMethodDefinition dmd, Object context)
   at MonoMod.Utils.DynamicMethodDefinition.Generate(Object context)
   at MonoMod.Utils.DynamicMethodDefinition.Generate()
   at HarmonyLib.MethodPatcher.CreateReplacement(Dictionary`2& finalInstructions)
   at HarmonyLib.PatchFunctions.UpdateWrapper(MethodBase original, PatchInfo patchInfo)
   at HarmonyLib.PatchProcessor.Patch()
   at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer)
   at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.PatchRunnerFactory(Harmony patcher, MethodBase factoryCandidate) in C:\projects\other\allure-csharp\Allure.SpecFlowPlugin\SelectiveRun\AllureSpecFlowPatcher.cs:line 84
   at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.PatchRunnerFactories(Harmony patcher, IEnumerable`1 factoryCandidates) in C:\projects\other\allure-csharp\Allure.SpecFlowPlugin\SelectiveRun\AllureSpecFlowPatcher.cs:line 75
   at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.InjectTestPlanCheckToTestRunner(Harmony patcher) in C:\projects\other\allure-csharp\Allure.SpecFlowPlugin\SelectiveRun\AllureSpecFlowPatcher.cs:line 38
   at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.InjectTestPlanSupport(IUnitTestRuntimeProvider unitTestRuntimeProvider) in C:\projects\other\allure-csharp\Allure.SpecFlowPlugin\SelectiveRun\AllureSpecFlowPatcher.cs:line 33
   at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.EnsureTestPlanSupportInjected(IUnitTestRuntimeProvider unitTestRuntimeProvider) in C:\projects\other\allure-csharp\Allure.SpecFlowPlugin\SelectiveRun\AllureSpecFlowPatcher.cs:line 24
   at Allure.SpecFlowPlugin.AllureBindingInvoker..ctor(SpecFlowConfiguration specFlowConfiguration, IErrorProvider errorProvider, ISynchronousBindingDelegateInvoker synchronousBindingDelegateInvoker, ITestRunnerManager testRunnerManager, IUnitTestRuntimeProvider unitTestRuntimeProvider) in C:\projects\other\allure-csharp\Allure.SpecFlowPlugin\AllureBindingInvoker.cs:line 45
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithManyArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
--InvalidOperationException
   at MonoMod.Utils.DMDEmitDynamicMethodGenerator..cctor()

Which points to this code:

And I'd guess then that this applies:
MonoMod/MonoMod#149

.Net 8 support PR's are:
MonoMod/MonoMod#150

Hoping this saves others time, just need to wait for MonoMod .Net 8 support it seems, which has an open PR for it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions