Closed AntiGuideAkquinet closed 6 months ago
Closing this issue means that the following line in the README.md
can 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.
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
AssertValidLicense
behavior 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.