-
Notifications
You must be signed in to change notification settings - Fork 727
Fix issue when an empty ArraySegment is a member of a class. #2445
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
Fix issue when an empty ArraySegment is a member of a class. #2445
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/[email protected]
with:
upload-result: true Contact Qodana teamContact us at [email protected]
|
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.
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. |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
Addressed in #2511
// Act | ||
Action act = () => actual.Should().BeEquivalentTo(expected); | ||
|
||
// Assert | ||
act.Should().NotThrow(); |
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.
// 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.
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.
Addressed in #2511
@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 spellcheck
or.\build.ps1 --target spellcheck
before pushing and check the good outcome