-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialized input -> Deserialization -> Reserialization should be symmetrical #45
Comments
…able. Some minor updates to broken serialization unit tests: style, formatting. #45
Did this work in previous versions of ical.net, or is this a recent regression? Do you know? |
I will see about writing a whopper test in the next few days that takes all of the ICS files and deserializes, reserializes, and compares the two strings to assert the symmetry of these operations. I think they should be equal, or equal if we sort each subcomponent. If they aren't equal, I want to know how bad it is... |
I’ll run a git bisect and get back to you (I should have thought to do this when I made the ticket) |
nuget packages (not commits) SerializeDeserialize - pass so it is 2.1.4 (current) where the serialization stops working completely (although attendee properties are no longer being clobbered). |
Immensely frustrating, thanks. |
Fix regression bug introduced during a 'minor cleanup' ugh #45
I just merged a PR that fixes a bunch of the serialization unit tests. Only 3 fail now. While I was there, I fixed the platform-specific I unlisted the broken nuget package, too. |
It appears that serializing an I should figure out what, specifically, is happening here. Ceiling? Floor? Rounding? Anyway, this is a problem. Business rules should be enforced during object instantiation, not during serialization. |
…ents. Equality and hashing working for Events, CalDateTimes, and Calendars. Fixed bug where DateTimes didn't have their sub-second precision truncated #45
…. Related to work on Attendees #45. Perhaps useful for API changes in v3, too?
…s and Equality working as expected #45
I have thought a bit more time about the discussions in pull request #49 and how best to test serialization. To summarise: Object -> Serialise -> Deserialise -> Compare objectsif any properties are not serialised, or are serialised incorrectly, these are important tests and will pick that up straight away. Weaknesses of using this as the only test of serialisation are:
Current, hastily designed tests of mineText parsing will not be as robust as a dedicated library. They are not IMHO useless at this stage of development, as they have helped clarify the nature of a few flaws in serialization. File -> Deserialise -> Serialise -> Compare textI do not know enough about how rigid the spec is in terms of the order of properties & values, but it could be argued the 'overly restrictive' nature of the tests I wrote and discussed in the point above would persist or be even more restrictive, and therefore do not offer a great advantage. Separate spec validation libraryThis would to some extent be the best solution because it is applicable beyond the tests - when designing a consuming application, having a GetSpecValidationErrors type of function would be very useful - for example returning problems like an Event with a missing Organiser, or METHOD:PUBLISH calendar erroneously including an event with an attendee. using (var client = new HttpClient())
{
...
var response = await client.PostAsync("http://icalendar.org/validator.html", content);
var responseString = await response.Content.ReadAsStringAsync();
//will then have to parse html using an appropriate library
} Obviously this will be too slow for running regularly, but might be a good idea before updating nuget packages. The clearest weakness will be it will be have to parse HTML output, which has been designed for visual assessment by a human, and might reasonably change over time without warning. Another solution which does nothing about the speed aspect, but makes things a whole lot more robust is to ask the owners of http://iCalendar.org or http://severinghaus.org if they would be willing to add an AJAX type service, which returns a JSON array of problems discovered. |
So interestingly... I went back to a very old version of dday.ical. (Before I started making changes.) Here's what happened with your simple attendee case, @mcshaz : var simple = new Attendee("MAILTO:[email protected]")
{
CommonName = "James James",
Role = "CHAIR",
RSVP = true,
ParticipationStatus = ParticipationStatus.Tentative
};
var serialized = SerializeToString(calendar); The output, once I replaced the
|
So, your arguments, as I understand them are:
I think I don't agree with these assertions. If you look at the branch I'm working on now, I have implemented several symmetric serialization/deserialization tests, focusing on what If an objects-to-objects comparison isn't catching a bug, I would prefer to write a test targeting the component that's misbehaving, even if it's as simple as: var simple = new Attendee("MAILTO:[email protected]")
{
CommonName = "James James",
Role = "CHAIR",
RSVP = true,
ParticipationStatus = ParticipationStatus.Tentative
};
Assert.AreEqual("CHAIR", simple.Role); If we have to write tests at the parsing level, we can do that, too. In general, comparing text isn't a good idea. The spec doesn't specify an ordering for various attributes (that I am aware of), so comparing text would be problematic and brittle. Determining whether one attendee is equal to another attendee would be difficult. (Have you looked at how Outlook serializes things? Omg.) The only time this would be appropriate would be comparing serialized outputs in a concurrency scenario to make sure the serialization is stable, deterministic, and thread-safe. (For what it's worth, ordering is implied in some of my RE: Separate spec validation library... I'm not averse to this idea, but I'm not going to take it on. Btw, your code sample should be written as: using (var client = new HttpClient())
{
using (var response = await client.PostAsync("http://icalendar.org/validator.html", content))
{
var responseString = await response.Content.ReadAsStringAsync();
}
//will then have to parse html using an appropriate library
}
|
…s and Equality working as expected #45
Hmm, Attendees are starting with |
I think we have somewhat crossed wires here - I have tried to list out 4 alternatives each with positives and negatives, and I think we agree on almost everything:
|
Appologies - clicked close and comment by mistake - reopened. As per the comment on online validation in my 'experimental' branch, the tests are validating or not validating serialised output appropriately using the online icalendar.org validator. each test takes 1-2 seconds, and as stated, a single post could be used with an icalendar object containing just about every feature imaginable. If you think this feature would be worth pursuing, I will ask the site owners about the possibility of providing a web service which responds with a JSON array of validation errors, as the current method of parsing the HTML is too unstable to be of real use. |
…s and Equality working as expected #45
…s and Equality working as expected #45
Yes, I misread your ideas. I'm on board with the first three bullets. The validator thing, though... in theory I'm OK with it, but it fails several valid serializations for time zone reasons. ("America/New_York is an invalid time zone", which is bollocks.) I think the actual problem is the way the DATE-TIME time zones are specified which is actually OK unless it's UTC, as you noted in your PR recently. I haven't had the time or energy to pull on that particular thread any more, however, as I have a need for working attachments at work, so that's where my efforts are focused at this moment. Feel free to reach out to the validator folks... I wouldn't be surprised if the validator itself is just a wrapper around a REST endpoint that you'd just need to know how to call. (That's how I would implement it, anyway.) |
I could be wrong, but I think the timezones I have seen do not validate - issue #58 raised in an attempt to clarify |
Incredibly, all line folds are technically wrong, and always have been. This is why https://tools.ietf.org/html/rfc5545#section-3.1
The function that purports to do this is I have implemented a replacement: |
…"line folding" where lines are meant to wrap after the 75th character. This was implemented, but the second part of a fold is the indentation by one space or tab character on folded lines 2..n. I have re-written the fold function so that it works properly, which has fixed several serialization failures. We are now down to 2 broken unit tests instead of 6! #45
@mcshaz - you may be interested in my last commit message:
This fixes binary attachment serialization and deserialization. I'll merge this in this afternoon, and publish a new nuget package. I also want to have a closer look at @ghentsch's issue ( #60 ) which I suspect may be related... |
…ents. Equality and hashing working for Events, CalDateTimes, and Calendars. Fixed bug where DateTimes didn't have their sub-second precision truncated #45
…. Related to work on Attendees #45. Perhaps useful for API changes in v3, too?
…s and Equality working as expected #45
…"line folding" where lines are meant to wrap after the 75th character. This was implemented, but the second part of a fold is the indentation by one space or tab character on folded lines 2..n. I have re-written the fold function so that it works properly, which has fixed several serialization failures. We are now down to 2 broken unit tests instead of 6! #45
Big steps forward in 4f3e4b5 We may be able to close this, but I want to have a look at @mcshaz's broken "remove attendee" test case. A secondary time zone serialization ticket exists at #58 which will carry that shortcoming forward. @mcshaz - I would appreciate your comments on what might be missing/broken still. |
This is largely the case for a while. Closing old tickets. |
The previous nuget release (2.1.3) was not serializing any of the timezone info, but was serializing events (albeit setting any and all attendee properties other than uri to null as part of the Attendees.Add operation).
In the current github master branch, events are not serialized either.
Test cases are included with a pull request, but as a brief example:
will currently produce
The text was updated successfully, but these errors were encountered: