Comments (7)
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
from fluentassertions.analyzers.
@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.
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
andNotBeEmpty
has anbecauseArgs
suggest they could be merged, but without providing a codefix, - otherwise merge them and there is at most a single
becauseArgs
.
from fluentassertions.analyzers.
Are you referring to the problem about which
becauseArgs
to choose when mergingNotBeNull
andNotBeEmpty
?
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.
started work on the branch feature/replacing-part-of-assertion
from fluentassertions.analyzers.
Sounds great!
My colleagues are already eager to know when they can start using this tool.
from fluentassertions.analyzers.
@jnyrup 0.4.0 is up on NuGet now
from fluentassertions.analyzers.
Related Issues (20)
- Lot of warnings after upgrading to 0.15.0 HOT 4
- Suggestions to use fluent assertions instead of MSTest Asserts do not work if "using Microsoft.VisualStudio.TestTools.UnitTesting;" is located inside of the namespace. HOT 8
- Suggestions to use fluent assertions instead of MSTest Asserts do not work if Assert is not on the top level of nesting in a test method HOT 1
- AssertIsTrue: Simplify Assertion does not offer automatic fix to apply HOT 13
- Analyzers do not work with GlobalUsings HOT 10
- Common DiagnosticId prefix for all analyzer rules
- AssertAreEqual analyzer does not trigger if the expected value is null HOT 2
- Fix suggested by AssertAreEqual does not compile if type casting is used when specifying the actual value
- Version 0.17.3 doesn't seem to work HOT 1
- upgrade project to dotnet 6
- add benchmark tests
- FluentAssertions.Analyzers 0.19.0 causes compile errors in .NET 7 projects HOT 4
- Warnings related to an old version HOT 4
- Analyzers 0.19.1 cannot be used with the .net 6 SDKs HOT 1
- add support for mstest Assert.IsInstanceOfType<T>
- Various bugs running on large codebase
- Collection analyzers are not running on arrays
- Collection analyzers are not running on dictionaries
- Collection analyzers are not running on properties of types
- `NullReferenceException` in `CollectionAnalyzer.ShouldAnalyzeVariableType` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentassertions.analyzers.