SerilogSinksInMemory icon indicating copy to clipboard operation
SerilogSinksInMemory copied to clipboard

Issue with FluentAssertions 8.0.1

Open Robert-Ed-Smith opened this issue 10 months ago • 28 comments

Upon upgrading from Fluent Assertions from 7.1.0 to 8.0.1 I see

System.MissingMethodException : Method not found: 'Void FluentAssertions.Primitives.ReferenceTypeAssertions`2..ctor(!0)'.

This looks very similar to the issue https://github.com/serilog-contrib/SerilogSinksInMemory/issues/22 for a previous upgrade.

The generating code is very simple

InMemorySink.Instance .Should() .HaveMessage();

Works with 7.1.0, fails with given message on 8.0.1

Robert-Ed-Smith avatar Jan 27 '25 11:01 Robert-Ed-Smith

It sure looks similar but the solution will be much more complicated unfortunately.

FluentAssertions 8 introduces a lot of breaking changes which means I can no longer depend on whatever someone includes in their project when using Serilog.Sinks.InMemory.Assertions.

I need to have a think about how to solve this.

sandermvanvliet avatar Jan 27 '25 15:01 sandermvanvliet

Maybe consider to go away from FluentAssertions after they changed the licensing in version 8. Shouldly (https://github.com/shouldly/shouldly) seems like a good replacement,

jimmyrn avatar Jan 29 '25 08:01 jimmyrn

That’s immaterial to this library.

If there are enough requests to provide extensions to Shouldly I might consider adding that but right now this library supports FluentAssertions and that won’t change.

sandermvanvliet avatar Jan 29 '25 10:01 sandermvanvliet

@Robert-Ed-Smith i have a potential solution that I’m testing right now although that comes at the cost of dropping support for .Net Framework (4.8 and below)

So far the tests for net core look good and I think it’s a workable solution but I want to ensure I have a working approach before I bump the package to NuGet

sandermvanvliet avatar Jan 29 '25 10:01 sandermvanvliet

Thank-you - we will probably revert to the prior version of FluentAssertions - I think the new licensing costs are very high. We will look into the alternative you suggest as well. Thank you for the suggestion

Robert-Ed-Smith avatar Jan 30 '25 09:01 Robert-Ed-Smith

@Robert-Ed-Smith would you mind having a test of the pre release packages available here and let me know if that works?

Even if using FluentAssertions 6, that would be helpful to know if I didn't introduce any breaking changes.

sandermvanvliet avatar Jan 30 '25 09:01 sandermvanvliet

Yes will test with the upgraded version (8.0.1) and then roll back to 7.1.0 and test with that

Robert-Ed-Smith avatar Jan 30 '25 09:01 Robert-Ed-Smith

Sorry, just noticed you're using version 7 so i just pushed a new version that supports it.

Have a look at these packages

sandermvanvliet avatar Jan 30 '25 09:01 sandermvanvliet

The first version (as you expected) worked fine with 8 but failed on 7.

That (latest) version works with both version 8 and version 7.

As I mention, because of the licensing costs we will revert back to version 7 of Fluent Assertions anyway, at least for now

Robert-Ed-Smith avatar Jan 30 '25 09:01 Robert-Ed-Smith

Thanks for testing it. I’ll let it percolate for a few days and then push out a new package to NuGet

sandermvanvliet avatar Jan 30 '25 10:01 sandermvanvliet

Will you consider using AwesomeAssertions? It's a fork of FluentAssertions that preserves the latest developments up until the license change. We keep the same namespace, so nothing breaks. By switching, you'll be supporting OpenSource and calling out a decision that disrespected previous contributors.

jcfnomada avatar Feb 04 '25 11:02 jcfnomada

Yes definitely. We will take a look at that.

Robert-Ed-Smith avatar Feb 05 '25 16:02 Robert-Ed-Smith

We've tried to swich from FluentAssertions 7.1 to AwesomeAssertions on version 8.0

Everything works fine with those two patched versions - which are not yet pushed to NuGet repository I think.. If you could push .those versions then we can switch across to AwesomeAssertions

Robert-Ed-Smith avatar Feb 06 '25 11:02 Robert-Ed-Smith

@Robert-Ed-Smith you can find 7.1.0 and 8.0.0 version in nuget: https://www.nuget.org/packages/AwesomeAssertions

jcfnomada avatar Feb 06 '25 12:02 jcfnomada

Sorry no, unless I misunderstand you, I mean the SeriLog.Sinks.InMemory and Seriloig.Sinks.InMemory.Assertions - we need to use the patches (version 12.1) that you listed in this ticket for it to work. (Otherwise we get a similar error to what we were seeing at the top of this post).

I can still only see version 11.0 in NuGet.

Robert-Ed-Smith avatar Feb 06 '25 12:02 Robert-Ed-Smith

@Robert-Ed-Smith the assertions package here does not support AwesomeAssertions (not yet anyway). Using those packages in your project will not make these assertions provided by this package work.

sandermvanvliet avatar Feb 06 '25 13:02 sandermvanvliet

Yes AwesomeAssertions doesn't solve exactly this issue. It will require some rework, and actually moving away from FluentAssertions. The only and probably best solution would be to create a new package for example Serilog.Sinks.InMemory.AwesomeAssertions. But that is another issue, so sorry for messing with your work.

jcfnomada avatar Feb 06 '25 14:02 jcfnomada

No need to be sorry 🙂

With the changes I’ve made it actually may be much simpler to support that.

It’s just that I need to have a little bit of free time to work on that, only free time is a bit limited right now…

sandermvanvliet avatar Feb 06 '25 17:02 sandermvanvliet

Image

Ok so version 0.13.0 should hit NuGet soonish which will support:

  • FluentAssertions 5, 6, 7 and 8
  • AwesomeAssertions 8
  • Shouldly 4

Hope that helps 😀

sandermvanvliet avatar Feb 10 '25 15:02 sandermvanvliet

That's great - thank you.

Robert-Ed-Smith avatar Feb 10 '25 15:02 Robert-Ed-Smith

Thanks a lot @sandermvanvliet! :)

I'm trying to get work with Shouldly, bit it seems like I'm missing Serilog.Sinks.InMemory.Assertions.Abstractions in the package.

I get The type 'InMemorySinkAssertions' is defined in an assembly that is not referenced. You must add a reference to assembly 'Serilog.Sinks.InMemory.Assertions.Abstractions, Version=0.13.0.0, Culture=neutral, PublicKeyToken=null'.

jimmyrn avatar Feb 11 '25 07:02 jimmyrn

That’s really odd 🤔

I actually have integration tests that specifically use the package to catch these kinds of problems but it seems that’s not working as expected 😅

sandermvanvliet avatar Feb 11 '25 16:02 sandermvanvliet

Yes, I saw your tests, but I think what makes it work there is that you have a project reference to .Abstractions, but the dll is not included in the package 🙂

jimmyrn avatar Feb 11 '25 21:02 jimmyrn

It should likewise fail for the Fluent/AwesomeAssertions as those don’t have that reference

sandermvanvliet avatar Feb 12 '25 07:02 sandermvanvliet

I also get The type 'InMemorySinkAssertions' is defined in an assembly that is not referenced. You must add a reference to assembly 'Serilog.Sinks.InMemory.Assertions.Abstractions, Version=0.13.0.0, Culture=neutral, PublicKeyToken=null'. using FluentAssertions 7.1.0

timozn avatar Feb 12 '25 09:02 timozn

Yeah something went really wonky with the packaging in the GitHub workflow.

I'm investigating this now but in the meantime I'll de-list 0.13.0 from NuGet because that's now a known-bad version...

Apologies for that.

sandermvanvliet avatar Feb 12 '25 14:02 sandermvanvliet

Ok, this is fixed in 0.14.0

Listing of the actual package:

Image

sandermvanvliet avatar Feb 13 '25 13:02 sandermvanvliet

Sorry for the late reply. I have tested with Shouldly, and it works perfectly. Thanks a ton @sandermvanvliet! :)

jimmyrn avatar Feb 18 '25 11:02 jimmyrn