feat: extend policy size limit from 12 to 14 parameters#388
feat: extend policy size limit from 12 to 14 parameters#388hsluoyz merged 2 commits intoapache:masterfrom
Conversation
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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].
| } | ||
|
|
||
| if (lastIndex is 11) // and fieldIndex <= 11 | ||
| if (fieldIndex <= 11 && lastIndex >= 11) |
There was a problem hiding this comment.
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.
| if (fieldIndex <= 11 && lastIndex >= 11) | |
| if (lastIndex == 11) |
|
🎉 This PR is included in version 2.16.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Fix: #358