Skip to content
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

Associate attachments with their events when VALUE is BINARY. #411

Merged
merged 2 commits into from
Oct 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions net-core/Ical.Net.CoreUnitTests/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Ical.Net.CalendarComponents;
using Ical.Net.DataTypes;
Expand Down Expand Up @@ -486,5 +487,30 @@ public void LibraryMetadataTests()
var expectedVersion = $"VERSION:{LibraryMetadata.Version}";
Assert.IsTrue(serialized.Contains(expectedVersion, StringComparison.Ordinal));
}

[Test]
public void AttachmentFormatType()
{
var cal1 = new Calendar
{
Events =
{
new CalendarEvent
{
Attachments =
{
new Attachment(Encoding.UTF8.GetBytes("{}"))
{
FormatType = "application/json",
},
},
},
},
};
var serializer = new CalendarSerializer();
var serializedCalendar = serializer.SerializeToString(cal1);
var cal2 = Calendar.Load(serializedCalendar);
Assert.AreEqual("application/json", cal2.Events.Single().Attachments.Single().FormatType);
}
}
}
2 changes: 1 addition & 1 deletion net-core/Ical.Net.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Ical.Net</id>
<version>4.1.8</version>
<version>4.1.9</version>
<title>Ical.Net</title>
<authors>Rian Stockbower, Douglas Day</authors>
<owners>Rian Stockbower</owners>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public Attachment Deserialize(string attachment)
{
// If the VALUE type is specifically set to BINARY,
// then set the Data property instead.
return new Attachment(data) {ValueEncoding = a.ValueEncoding};
return new Attachment(data)
{
ValueEncoding = a.ValueEncoding,
AssociatedObject = a.AssociatedObject,
};
}

// The default VALUE type for attachments is URI. So, let's
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
A listing of what each [Nuget package](https://www.nuget.org/packages/Ical.Net) version represents.

### v4
* 4.1.9 - (2018-07-18) - Associate attachments with their events when VALUE is BINARY. Without the association, parameters such as FMTTYPE would be lost. [PR 411](https://github.com/rianjs/ical.net/pull/411)
* 4.1.8 - (2018-06-12) - `PRODID` and `VERSION` are unconditionally set when serializing a calendar so as not to mislead consumers about where the serialized output came from. Previous behavior would use the values that came from deserialization. #403
* 4.1.6 - (2018-06-01) - Target `net46` instead of `net45`. It seems that [`System.Reflection.TypeExtensions`](https://www.nuget.org/packages/System.Reflection.TypeExtensions/), doesn't support framework versions below 4.6. Bummer.
* 4.1.5 - (2018-05-28)
Expand Down