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
Add BeValidJson
extensions for strings
#2558
base: develop
Are you sure you want to change the base?
Add BeValidJson
extensions for strings
#2558
Conversation
Qodana for .NETIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at qodana-support@jetbrains.com
|
Pull Request Test Coverage Report for Build 7519123647
💛 - Coveralls |
d46683f
to
c82b18e
Compare
c82b18e
to
fc41d92
Compare
.FailWith("Expected {context:string} to be valid JSON{reason}, but parsing failed with {0}.", jsonException.Message); | ||
} | ||
|
||
return new AndWhichConstraint<TAssertions, JsonDocument>((TAssertions)this, json); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way of using JsonDocument seems to be against the documentation that states that it is important to dispose (or clone) JsonDocument instances. I'm not sure I fully understand the consequences they warn about here, but my suggestion would be to use the raw Utf8JsonReader
for BeValidJson
and not provide the document for further usage.
JsonDocument builds an in-memory view of the data into a pooled buffer. Therefore the JsonDocument type implements IDisposable and needs to be used inside a using block.
Draft for #2556
Add the following methods to the
StringAssertions
(similar toStringAssertionsExtensions
inFluentAssertions.Json
):These methods should assert that the string is a valid JSON document.
IMPORTANT
./build.sh --target spellcheck
or.\build.ps1 --target spellcheck
before pushing and check the good outcome