Skip to content
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

Fixed an issue where feature profile expressions could not be serialized. #15976

Conversation

TonyWoo
Copy link
Contributor

@TonyWoo TonyWoo commented May 5, 2024

The FeatureRules is declared as a field, please see below code. But System.Text.Json don't serialize the field by default. I changed it to a property for now.

Fixes #15975.

Please review and let me know if there are any questions.

Summary by CodeRabbit

  • Refactor
    • Enhanced flexibility in managing feature rules, target updates, and XML-RPC drivers by allowing dynamic modifications through setters.

Copy link
Contributor

github-actions bot commented May 5, 2024

Thank you for submitting your first pull request, awesome! 🚀 If you haven't already, please take a moment to review our contribution guide. This guide provides helpful information to ensure your contribution aligns with our standards. A core team member will review your pull request.

@TonyWoo
Copy link
Contributor Author

TonyWoo commented May 5, 2024

@dotnet-policy-service agree

@sarahelsaig
Copy link
Contributor

Thanks, this works!
I've looked over the source code and found two other classes with empty collection fields that probably should be properties as well (here and here).

@hyzx86
Copy link
Contributor

hyzx86 commented May 5, 2024

Hi @TonyWoo , Can you fix the other two together? Thanks!

@hyzx86
Copy link
Contributor

hyzx86 commented May 6, 2024

@coderabbitai , review

@TonyWoo
Copy link
Contributor Author

TonyWoo commented May 6, 2024

@sarahelsaig and @hyzx86, I fixed the following two issues as well. Thanks.
(here and here).

Copy link
Contributor

coderabbitai bot commented May 6, 2024

@hyzx86, I have reviewed the changes and the related classes as per your request. Here are my findings and recommendations:

Review of FeatureProfile Class

The FeatureProfile class has been updated correctly to use properties instead of fields for serialization purposes. The FeatureRules is now a property which should be correctly handled by System.Text.Json.

Review of XmlRpcContext Class

The XmlRpcContext class contains a collection initialized directly in the property declaration (public ICollection<IXmlRpcDriver> Drivers { get; set; } = [];). This is similar to the original issue in the FeatureProfile class and should be changed to a property to ensure it gets serialized.

Review of VolatileDocumentManager Class

The VolatileDocumentManager class uses a HashSet<object> initialized directly in the property declaration within a nested private class UpdateDelegates. This might not directly affect serialization as it's a private class used internally, but if serialization of this type of data structure becomes necessary, converting this to a property would be consistent with the other changes.

Recommendations

  1. Convert the collection in XmlRpcContext to a property: This will ensure it is serialized correctly.
  2. Review the use of collections in VolatileDocumentManager: If there's a future requirement to serialize UpdateDelegates, consider changing the initialization to be consistent with other changes.

If you agree with these recommendations, I can provide the code modifications needed for the XmlRpcContext class. For the VolatileDocumentManager, further discussion might be needed to determine if changes are necessary based on future requirements.

Please let me know how you would like to proceed!

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Fetch the content of the FeatureProfile class
cat src/OrchardCore/OrchardCore.Abstractions/Shell/Models/FeatureProfile.cs

# Fetch the content of the XmlRpcContext class
cat src/OrchardCore/OrchardCore.XmlRpc.Abstractions/XmlRpcContext.cs

# Fetch the content of the VolatileDocumentManager class
cat src/OrchardCore/OrchardCore.Infrastructure/Documents/VolatileDocumentManager.cs

Length of output: 5637

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented May 6, 2024

Walkthrough

The recent updates across various modules in OrchardCore involve changing certain fields to properties with getters and setters, all initialized to empty collections. This modification enhances encapsulation and provides a more standardized way to interact with these data structures across different parts of the framework.

Changes

File Path Change Summary
.../Shell/Models/FeatureProfile.cs Changed FeatureRules from a field to a property with getter and setter, initialized to an empty list.
.../Documents/VolatileDocumentManager.cs Changed Targets from an uninitialized field to a property with getter and setter, initialized to an empty HashSet.
.../XmlRpc.Abstractions/XmlRpcContext.cs Changed Drivers from a field to a property with getter and setter, initialized to an empty collection.

Assessment against linked issues

Objective Addressed Explanation
Feature Profile configs are not respected (#15975) The changes in FeatureProfile.cs relate to how feature rules are stored and accessed, but there's no indication that the logic for applying these rules (i.e., excluding features from being enabled) has been implemented or modified.

The updates primarily focus on code quality improvements by enhancing the way data structures are defined and accessed, rather than addressing specific functional bugs or feature requests. It appears that the issue with feature profiles not being respected might still persist as the underlying logic for rule enforcement does not seem to have been addressed in this set of changes.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hyzx86
Copy link
Contributor

hyzx86 commented May 6, 2024

Hi @MikeAlhayek ,Anything to add? Or let's merge it.

@MikeAlhayek MikeAlhayek merged commit c5c7e03 into OrchardCMS:main May 6, 2024
5 checks passed
Copy link
Contributor

github-actions bot commented May 6, 2024

Congratulations on your first PR merge! 🎉 Thank you for your contribution! We're looking forward to welcome other contributions of yours in the future. @all-contributors please add @TonyWoo for code.

Copy link
Contributor

@github-actions[bot]

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

I've put up a pull request to add @TonyWoo! 🎉

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.

Feature Profile configs are not respected
4 participants