mirror of
https://github.com/junian/Standard.Licensing.git
synced 2026-04-25 13:55:53 +03:00
[GH-ISSUE #28] Multiple enumeration of AssertValidLicense results in incorrect validation #27
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Standard.Licensing#27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AntiGuideAkquinet on GitHub (Feb 24, 2023).
Original GitHub issue: https://github.com/junian/Standard.Licensing/issues/28
When given an invalid license, AssertValidLicense returns an IEnumerable with a ValidationFailure on the first enumeration but an empty IEnumerable on the second enumeration.
As a workaround, I suggest users of the library use ToArray or alike to enumerate the IEnumerable only once.
The reason for this behavior is the current implementation of the validators collection in ValidationChainBuilder as a queue. In AssertValidLicense, all validators will be dequeued every time, resulting in different results.
I suggest either the usage of a list or the change of
AssertValidLicensebehavior to throw instead of returning failures. The name indicates a throw on invalid licenses and could potentially be dangerous to people relying on the implied behavior.@skst commented on GitHub (Apr 27, 2024):
Closing this issue means that the following line in the
README.mdcan be deleted. (I didn't think it was worth a pull request, but I'm happy to create one if that's preferred.) 🙂Make sure to call validationFailures.ToList() or validationFailures.ToArray() before using the result multiple times.