Skip to content

Conversation

FAUST-BENCHOU
Copy link
Contributor

@FAUST-BENCHOU FAUST-BENCHOU commented Sep 24, 2025

Fix: #358

@hsluoyz hsluoyz requested a review from Copilot September 27, 2025 02:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends the policy size limit from 12 to 14 parameters in the Casbin.NET library to address issue #358. The changes systematically add support for two additional parameter positions (Value13 and Value14) across all relevant data structures and operations.

Key changes include:

  • Updated field index validation limits from 12 to 14 in policy filtering logic
  • Added new Value13 and Value14 properties to persistence interfaces and implementations
  • Extended generic type support with new RequestValues and PolicyValues variants for 13 and 14 parameters

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Casbin/Persist/PolicyFilter.cs Updated field index limits and added filtering logic for Value13 and Value14
Casbin/Persist/PersistantPolicy.cs Added Value13/Value14 properties and cases for 13/14 parameter creation
Casbin/Model/RequestValues.cs Added RequestValues structs for 13 and 14 generic parameters with indexer fixes
Casbin/Model/Request.cs Extended generic support limit and added factory methods for 13/14 parameters
Casbin/Model/PolicyValues.cs Added PolicyValues records for 13 and 14 parameters
Casbin/Model/Policy.cs Updated support limits and added factory methods for 13/14 parameter policies
Casbin/Extensions/Enforcer/EnforcerExtension.GenericEnforce.cs Added complete enforcement method sets for 13 and 14 generic parameters
Casbin/Enforcer.Internal.cs Added internal enforcement cases for 13 and 14 parameter policies
Casbin/Abstractions/Persist/IReadOnlyPersistPolicy.cs Added Value13 and Value14 properties to interface
Casbin/Abstractions/Persist/IPersistPolicy.cs Added Value13 and Value14 properties to interface
Casbin.UnitTests/GenericTests/SupportCountTest.cs Updated test loop limit and added test case for 14 parameters
Casbin.UnitTests/Examples/support_count_model.conf Added r14/p14/m14 definitions and updated comments

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if (fieldIndex <= 10 && lastIndex >= 10)
{
string field = values[5 - fieldIndex];
string field = values[10 - fieldIndex];
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

The array index calculation appears incorrect. For fieldIndex 10 and lastIndex 10, this calculates values[0], but it should access values[10] to get the 11th value (Value11). The formula should be values[fieldIndex] not values[10 - fieldIndex].

Copilot uses AI. Check for mistakes.

}

if (lastIndex is 11) // and fieldIndex <= 11
if (fieldIndex <= 11 && lastIndex >= 11)
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

This condition change from lastIndex is 11 to fieldIndex <= 11 && lastIndex >= 11 is inconsistent with the pattern used in other field checks. The original pattern lastIndex is 11 was more specific and should be maintained for consistency, or all other conditions should be updated to match this new pattern.

Suggested change
if (fieldIndex <= 11 && lastIndex >= 11)
if (lastIndex == 11)

Copilot uses AI. Check for mistakes.

@hsluoyz hsluoyz merged commit 80c72ed into casbin:master Sep 27, 2025
5 of 6 checks passed
Copy link

🎉 This PR is included in version 2.16.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@sagilio sagilio self-assigned this Oct 3, 2025
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.

Eval not supported in non-generic enforces (request of policy size > 12)

3 participants