Skip to content

Conversation

@IT-VBFK
Copy link
Contributor

@IT-VBFK IT-VBFK commented Nov 27, 2023

This refers to Excluding() / .For().Exclude() and Including().

This closes #2479

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

@IT-VBFK IT-VBFK changed the title SAVEPOINT Excluding properties with anonymous object Nov 27, 2023
@coveralls
Copy link

coveralls commented Nov 27, 2023

Pull Request Test Coverage Report for Build 7036088817

  • 24 of 24 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 97.485%

Totals Coverage Status
Change from base Build 7033738205: 0.01%
Covered Lines: 11756
Relevant Lines: 11940

💛 - Coveralls

@IT-VBFK IT-VBFK force-pushed the feat/excluding-with-anonymous-object branch 2 times, most recently from 552be02 to c1e2441 Compare November 28, 2023 16:28
@IT-VBFK IT-VBFK marked this pull request as ready for review November 28, 2023 16:29
@github-actions
Copy link

github-actions bot commented Nov 28, 2023

Qodana for .NET

It 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

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/qodana-action@v2023.2.8
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@IT-VBFK IT-VBFK changed the title Excluding properties with anonymous object Excluding fields and properties with anonymous object Nov 28, 2023
@IT-VBFK IT-VBFK force-pushed the feat/excluding-with-anonymous-object branch 3 times, most recently from e869e49 to 1a87f18 Compare November 28, 2023 20:42
@IT-VBFK IT-VBFK changed the title Excluding fields and properties with anonymous object Allow anonymous object for selecting fields/properties at Exclude and Include Nov 28, 2023
@IT-VBFK IT-VBFK force-pushed the feat/excluding-with-anonymous-object branch from 1a87f18 to 1ac4b66 Compare November 28, 2023 21:19
@IT-VBFK
Copy link
Contributor Author

IT-VBFK commented Nov 29, 2023

Hmm.. discovered a bad bug...

Will fix it in the evening 🫣

@github-actions
Copy link

github-actions bot commented Oct 31, 2024

Qodana for .NET

It 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
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@IT-VBFK IT-VBFK force-pushed the feat/excluding-with-anonymous-object branch 2 times, most recently from 8191b33 to b363b4b Compare October 31, 2024 22:19
@coveralls
Copy link

coveralls commented Oct 31, 2024

Pull Request Test Coverage Report for Build 11767671047

Details

  • 32 of 32 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 97.771%

Totals Coverage Status
Change from base Build 11754697332: 0.01%
Covered Lines: 12357
Relevant Lines: 12516

💛 - Coveralls

@IT-VBFK IT-VBFK marked this pull request as ready for review November 2, 2024 08:06
@IT-VBFK IT-VBFK force-pushed the feat/excluding-with-anonymous-object branch from b363b4b to ba177ab Compare November 2, 2024 08:35
@IT-VBFK IT-VBFK force-pushed the feat/excluding-with-anonymous-object branch 2 times, most recently from 6aa70b4 to fb28d7f Compare November 3, 2024 11:24
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.

👍🏻 Very nice feature
🔧 We only use var if the type is obvious.

segments.Add($"[{argumentExpression.Value}]");
singlePath = $"[{argumentExpression.Value}].{singlePath}";
break;
case ExpressionType.New:
Copy link
Member

Choose a reason for hiding this comment

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

♻️ This entire method is become too bloated and needs some refactoring (but maybe not now). An implementation of the Strategy Pattern might be a better fit.


IEnumerable<string> reversedSegments = segments.AsEnumerable().Reverse();
string segmentPath = string.Join(".", reversedSegments);
if (singlePath is null)
Copy link
Member

Choose a reason for hiding this comment

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

❓ What happens if singlePath is non-null and selectors isn't empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I can see, this cannot happen, because you either have: .Excluding(p => p.NestedField)(which results in singlePath to be non-null and segments to be empty) or .Excluding(p => new { p.NestedField } ) (which results in singlePath null + segments not empty).

Copy link
Member

Choose a reason for hiding this comment

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

My point was that the code doesn't make that clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I add a comment for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, we have do do it exactly like this, because in case of .Excluding(p => new { }) singlePath stays null and the segments stays empty.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, I would make it an if, else if and else. Even though the huge switch is difficult to process, you at least can see what will happen at the end.

@IT-VBFK IT-VBFK force-pushed the feat/excluding-with-anonymous-object branch 2 times, most recently from d3d766f to fe0e37c Compare November 10, 2024 13:11
@IT-VBFK IT-VBFK requested a review from dennisdoomen November 10, 2024 13:11
@IT-VBFK
Copy link
Contributor Author

IT-VBFK commented Nov 10, 2024

I think I've addressed all the blocking changes.

IT-VBFK and others added 3 commits November 10, 2024 19:51
This refers to `Excluding` / `For.Exclude` and `Including`
Co-authored-by: Dennis Doomen <dennis.doomen@avivasolutions.nl>
Co-authored-by: Dennis Doomen <dennis.doomen@avivasolutions.nl>
@IT-VBFK IT-VBFK force-pushed the feat/excluding-with-anonymous-object branch from fe0e37c to b0c2ff7 Compare November 10, 2024 18:51
@dennisdoomen dennisdoomen merged commit f8700b2 into fluentassertions:develop Nov 11, 2024
@IT-VBFK IT-VBFK deleted the feat/excluding-with-anonymous-object branch November 11, 2024 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Support for selecting multiple properties in single expression.

3 participants