rebus-org / Rebus.TestHelpers

:bus: Test helpers for Rebus (i.e. fake bus, saga fixture, etc.)
https://mookid.dk/category/rebus
Other
4 stars 2 forks source link

Fixed JSON serialization of dynamic assemblies #5

Closed fishie closed 3 years ago

fishie commented 3 years ago

Hej hej! Just in time for Christmas I have some treats for you to look into over the holidays ;) Here is the backstory: At our company we use Rebus, xUnit and FakeItEasy. One of our projects has flaky tests, and everyone hates flaky tests. So after looking into it, I was able to create a smaller example that still was flaky. I'll attach it here Flaky-v2.zip. Based on a guess on where the problem might be I created an issue on FakeItEasy here https://github.com/FakeItEasy/FakeItEasy/issues/1794. They were also very confused but recently @blairconrad was able to find the issue and circumvent it by the change in this PR. From what I understand the issue is that Castle.Core which FakeItEasy uses sometimes creates a dynamic assembly with a public key and sometimes without a public key. And when xUnit runs tests in parallel a situation can occur where there are two dynamic assemblies with the same name but with different public keys. Newtonsoft, which Rebus.TestHelpers uses, then tries to load the assembly with Assembly.LoadWithPartialName but it fails and throws an exception. This change circumvents the issue by telling Newtonsoft to include the full assembly name when serializing. I don't know if this can have any unintended consequences! But I hope not! Do you have some tests can be run to verify that this doesn't break existing tests? Thank you very much!


Rebus is MIT-licensed. The code submitted in this pull request needs to carry the MIT license too. By leaving this text in, I hereby acknowledge that the code submitted in the pull request has the MIT license and can be merged with the Rebus codebase.

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

mookid8000 commented 3 years ago

It's out as Rebus.TestHelpers 6.0.1 on NuGet.org now 🙂 thanks for fixing this!

fishie commented 3 years ago

Excellent! I tested the new version and the flakiness is gone, thank you!