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

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

Closed
1 of 3 tasks
MarcoVdE opened this issue Nov 22, 2023 · 1 comment · Fixed by #449
Closed
1 of 3 tasks

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

MarcoVdE opened this issue Nov 22, 2023 · 1 comment · Fixed by #449

Comments

@MarcoVdE
Copy link

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:

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.

@MarcoVdE MarcoVdE changed the title .Net 8 Support xUnit - MonoMod Dependency .Net 8 Support xUnit - Harmony -> MonoMod Dependency Nov 22, 2023
@delatrie delatrie assigned delatrie and unassigned delatrie Nov 24, 2023
@AlexBar
Copy link

AlexBar commented Nov 24, 2023

I've tried to build code from PR MonoMod/MonoMod#150 for .net 8, then I've built Harmony with these new references for .net 8 and then I've built allure-csharp using these new deps (MonoMod+Harmony for .net 8). It started working.

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

Successfully merging a pull request may close this issue.

3 participants