Skip to content

Conversation

ShaharPrishMSFT
Copy link
Contributor

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

  • If the PR touches the public API, the changes have been approved in a separate issue with the "api-approved" label.
  • The code complies with the Coding Guidelines for C#.
  • The changes are covered by unit tests which follow the Arrange-Act-Assert syntax and the naming conventions such as is used in these tests.
  • If the PR adds a feature or fixes a bug, please update the release notes with a functional description that explains what the change means to consumers of this library, which are published on the website.
  • If the PR changes the public API the changes needs to be included by running AcceptApiChanges.ps1 or AcceptApiChanges.sh.
  • If the PR affects the documentation, please include your changes in this pull request so the documentation will appear on the website.
    • Please also run ./build.sh --target spellcheck or .\build.ps1 --target spellcheck before pushing and check the good outcome

With latest, it crashes when trying to access the array members.
Copy link

github-actions bot commented Nov 8, 2023

Qodana for .NET

2 new problems were found

Inspection name Severity Problems
Redundant using directive 🔶 Warning 1
Remove redundant parentheses ◽️ Notice 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

  1. Register at Qodana Cloud and configure the action
  2. Use GitHub Code Scanning with Qodana
  3. Host Qodana report at GitHub Pages
  4. Inspect and use qodana.sarif.json (see the Qodana SARIF format for details)

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/[email protected]
        with:
          upload-result: true
Contact Qodana team

Contact us at [email protected]

Copy link
Member

@dennisdoomen dennisdoomen left a 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.

@ITaluone
Copy link
Contributor

ITaluone commented Nov 9, 2023

Typo in PR title ;) ArraySegmnet -> ArraySegment

@ShaharPrishMSFT ShaharPrishMSFT changed the title Fix issue when an empty ArraySegmnet is a member of a class. Fix issue when an empty ArraySegment is a member of a class. Nov 9, 2023
ShaharPrishMSFT added a commit to ShaharPrishMSFT/fluentassertions that referenced this pull request Nov 9, 2023
Updated to include an ArraySegment fix.

fluentassertions#2445
@ShaharPrishMSFT
Copy link
Contributor Author

Please also check out the contribution guidelines on release notes.

Fixed: develop...ShaharPrishMSFT:fluentassertions:patch-1

@ShaharPrishMSFT
Copy link
Contributor Author

Typo in PR title ;) ArraySegmnet -> ArraySegment

Fixed and addressed comments in the PR. Please take another look.

@ShaharPrishMSFT
Copy link
Contributor Author

@dennisdoomen

Can I see what the issues found by Qodana is without registering to something?

It gives the errors, but not where they are.

@ITaluone
Copy link
Contributor

ITaluone commented Nov 9, 2023

Since the Qodana scan does not include the direct link to the report anymore.. it is a little pain in the ass ;)

  1. click on "Details" besides the qodana run
  2. un-fold the "Qodana Scan" in the logs
  3. scoll to the bottom until you see something like this:
    image
  4. the qodana.cloud/XXXXXX is the link to go

https://qodana.cloud/projects/AgRgk/reports/M6a24

@ITaluone
Copy link
Contributor

ITaluone commented Nov 9, 2023

Also don't forget about a mention in the release notes :)

@ShaharPrishMSFT
Copy link
Contributor Author

Also don't forget about a mention in the release notes :)

Did :)

@ShaharPrishMSFT
Copy link
Contributor Author

@ITaluone / @dennisdoomen

I don't contribute often, so not sure if there's anything else I need to do here.

@ITaluone
Copy link
Contributor

ITaluone commented Nov 9, 2023

Did :)

No? I see only two files changed?

And btw.. new qodana issues ;)

@dennisdoomen
Copy link
Member

don't contribute often, so not sure if there's anything else I need to do here.

  1. Update the releases.md
  2. Fix the Qodana issues

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6811806552

Warning: 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.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 97.426%

Totals Coverage Status
Change from base Build 6773593369: 0.03%
Covered Lines: 11744
Relevant Lines: 11929

💛 - Coveralls

@ShaharPrishMSFT
Copy link
Contributor Author

don't contribute often, so not sure if there's anything else I need to do here.

  1. Update the releases.md
  2. Fix the Qodana issues
  1. I thought I did... I sent a link. What else am I missing here? develop...ShaharPrishMSFT:fluentassertions:patch-1

  2. They all seem to be fixed, no?

image

@dennisdoomen
Copy link
Member

  1. I thought I did... I sent a link. What else am I missing here? develop...ShaharPrishMSFT:fluentassertions:patch-1

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.

@dennisdoomen
Copy link
Member

2. They all seem to be fixed, no?

No, they are not (yet). Notice the little black box. It isn't a green checkbox.

Copy link
Member

@jnyrup jnyrup left a 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.

Comment on lines +73 to +75
return value.GetType() is { } type &&
(type.Name.Equals("ImmutableArray`1", StringComparison.Ordinal) ||
(type.IsGenericType && type.GetGenericTypeDefinition() == typeof(ArraySegment<>)));
Copy link
Member

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

SharpLab

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #2511

@jnyrup jnyrup added the bug label Nov 11, 2023
Comment on lines +656 to +660
// Act
Action act = () => actual.Should().BeEquivalentTo(expected);

// Assert
act.Should().NotThrow();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #2511

@dennisdoomen
Copy link
Member

@ShaharPrishMSFT did you give up on us?

@ITaluone
Copy link
Contributor

ITaluone commented Nov 30, 2023

I am willing to finish this, if @ShaharPrishMSFT does not want to. :)

Edit: I will wait until 8th of december :)

ITaluone pushed a commit to ITaluone/fluentassertions that referenced this pull request Dec 12, 2023
Updated to include an ArraySegment fix.

fluentassertions#2445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Types that contain an empty ArraySegment<>s cannot be checked with IsEquivalentTo.
6 participants