mirror of
https://github.com/junian/Standard.Licensing.git
synced 2026-04-25 13:55:53 +03:00
[GH-ISSUE #12] validationFailures.ToList() not working #10
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#10
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 @Manfrons on GitHub (Jan 23, 2020).
Original GitHub issue: https://github.com/junian/Standard.Licensing/issues/12
It seems that after iterate over the failures collection, calling ToList() or ToArray() doesn't populate it again.
You can test with this code.
I've generated an xml license file (copy/paste from main page), changed the expiration date inside the xml file and called the verification.
Any returns true, but the foreach is skipped.
if (validationFailures.Any()) { validationFailures.ToList(); foreach (var failure in validationFailures.ToList()) list.Items.Add(failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve); } else list.Items.Add("All ok");@sylvainonweb commented on GitHub (Mar 31, 2020):
Hi @Manfrons, I also encountered this errror and the solution was to call validationFailures.ToList() to retrieve the failures. This was written on the README.MD page.
@dragonfly22000 commented on GitHub (May 7, 2020):
Hello, i have the same problem.....
What i do:
StringBuilder sb = new StringBuilder(); var license = Standard.Licensing.License.Load(text); var validationFailures = license.Validate() .ExpirationDate() .When(lic => lic.Type == LicenseType.Trial) .And() .Signature(publicKey) .AssertValidLicense(); var failures = validationFailures.ToList(); if (failures.Count > 0) { StringBuilder builder = new StringBuilder(); foreach (var failure in failures) { builder.AppendLine(failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve); } }When i change date in License file to have a failure i have an exception before putting something in failures list....
Help me please,thanks a lot.
@sylvainonweb commented on GitHub (May 7, 2020):
@dragonfly22000 it seems to be because the date you entered isn't a valid date.
On my side I tried with a file like this
=> certainly need to change the library to take it into account or do a try/catch for this kind of error and return that the license is invalid.
@dragonfly22000 commented on GitHub (May 8, 2020):
@sylvainonweb Thanks for the answer ,effectively, i'm going to put a Try catch and make a pop-up in case of exception.
Thank you again.