Fix issue when an empty ArraySegment is a member of a class.#2445
Fix issue when an empty ArraySegment is a member of a class.#2445ShaharPrishMSFT wants to merge 4 commits intofluentassertions:developfrom
Conversation
With latest, it crashes when trying to access the array members.
Qodana for .NET2 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2023.2.8
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
dennisdoomen
left a comment
There was a problem hiding this comment.
Please also check out the contribution guidelines on release notes.
Src/FluentAssertions/Equivalency/Steps/EnumerableEquivalencyStep.cs
Outdated
Show resolved
Hide resolved
|
Typo in PR title ;) ArraySegmnet -> ArraySegment |
Updated to include an ArraySegment fix. fluentassertions#2445
|
Fixed and addressed comments in the PR. Please take another look. |
|
Can I see what the issues found by Qodana is without registering to something? It gives the errors, but not where they are. |
Src/FluentAssertions/Equivalency/Steps/EnumerableEquivalencyStep.cs
Outdated
Show resolved
Hide resolved
|
Also don't forget about a mention in the release notes :) |
Did :) |
|
I don't contribute often, so not sure if there's anything else I need to do here. |
No? I see only two files changed? And btw.. new qodana issues ;) |
|
Pull Request Test Coverage Report for Build 6811806552Warning: This coverage report may be inaccurate.We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
💛 - Coveralls |
|
Ah, no, you're supposed to do that as part of this PR. Then, when we release the change, the docs will be in sync with the code. |
No, they are not (yet). Notice the little black box. It isn't a green checkbox. |
jnyrup
left a comment
There was a problem hiding this comment.
I tried to search the BCL for other types having this behavior, but couldn't find others, so I'm fine with hack rather than finding a more general solution.
| return value.GetType() is { } type && | ||
| (type.Name.Equals("ImmutableArray`1", StringComparison.Ordinal) || | ||
| (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(ArraySegment<>))); |
There was a problem hiding this comment.
I would prefer either of these two
private static bool IsIgnorableArrayLikeType1(object value)
{
var type = value.GetType();
return type.Name.Equals("ImmutableArray`1", StringComparison.Ordinal) ||
(type.IsGenericType && type.GetGenericTypeDefinition() == typeof(ArraySegment<>));
}
private static bool IsIgnorableArrayLikeType2(object value)
{
return value.GetType().Name.Equals("ImmutableArray`1", StringComparison.Ordinal) ||
(value.GetType().IsGenericType && value.GetType().GetGenericTypeDefinition() == typeof(ArraySegment<>));
}All three variants JITs to the same assembly code
| // Act | ||
| Action act = () => actual.Should().BeEquivalentTo(expected); | ||
|
|
||
| // Assert | ||
| act.Should().NotThrow(); |
There was a problem hiding this comment.
| // Act | |
| Action act = () => actual.Should().BeEquivalentTo(expected); | |
| // Assert | |
| act.Should().NotThrow(); | |
| // Act / Assert | |
| actual.Should().BeEquivalentTo(expected); |
Just call the assertion. If it fails, it fails anyway.
|
@ShaharPrishMSFT did you give up on us? |
|
I am willing to finish this, if @ShaharPrishMSFT does not want to. :) Edit: I will wait until 8th of december :) |
Updated to include an ArraySegment fix. fluentassertions#2445


With latest, it crashes when trying to access the array members of an empty ArraySegment.
How do I change the release notes? Where do I add the bug fix?
IMPORTANT
./build.sh --target spellcheckor.\build.ps1 --target spellcheckbefore pushing and check the good outcome