Git Product home page Git Product logo

Comments (7)

Meir017 avatar Meir017 commented on May 31, 2024

I'm not sure how to approach this feature yet. I opened an issue on the Roslyn project, maybe they have a helper for something like this

dotnet/roslyn#22698

from fluentassertions.analyzers.

Meir017 avatar Meir017 commented on May 31, 2024

@jnyrup any idea what the code fix should be in the following case?

actual.Should().NotBeNull("collection should not be null")
    .And.NotBeEmpty("collection should not be empty")
    .And.HaveCount(2);

from fluentassertions.analyzers.

jnyrup avatar jnyrup commented on May 31, 2024

Are you referring to the problem about which becauseArgs to choose when merging NotBeNull and NotBeEmpty?

If it was my own code using FA I would just write:

actual.Should().NotBeNullOrEmpty("collection should not be empty")
    .And.HaveCount(2);

But of course the analyzer needs to be general.
How about this:

  • If both NotBeNull and NotBeEmpty has an becauseArgs suggest they could be merged, but without providing a codefix,
  • otherwise merge them and there is at most a single becauseArgs.

from fluentassertions.analyzers.

Meir017 avatar Meir017 commented on May 31, 2024

Are you referring to the problem about which becauseArgs to choose when merging NotBeNull and NotBeEmpty?

exactly!

@jnyrup just came up with a way to do the replacement - here is a snippet https://gist.github.com/Meir017/48eef45a5b2525ce21ff12de0bae5dc0 how weird is this? ;)

I tried using DocumentEditor as mentioned in the stackoverflow post but after the second replacement if threw a NullReferenceException since it couldn't find the second node after the first replacement

from fluentassertions.analyzers.

Meir017 avatar Meir017 commented on May 31, 2024

started work on the branch feature/replacing-part-of-assertion

from fluentassertions.analyzers.

jnyrup avatar jnyrup commented on May 31, 2024

Sounds great!
My colleagues are already eager to know when they can start using this tool.

from fluentassertions.analyzers.

Meir017 avatar Meir017 commented on May 31, 2024

@jnyrup 0.4.0 is up on NuGet now

from fluentassertions.analyzers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.